Async - sgml/signature GitHub Wiki

Async

Promisified setTimeout

async function wait(ms) {
  await new Promise(resolve => {
    setTimeout(resolve, ms);
  });
}

Simple Async/DOM comparison

if (String(this.xhr.keyword).trim() === String(this.handleChange.keyword).trim()) {
    GO();
    }


userIDs.reduce( async (previousPromise, nextID) => {
  await previousPromise;
  return methodThatReturnsAPromise(nextID);
}, Promise.resolve());

while (k < len) {
  if (k in o) {
    value = callback(value, o[k], k, o);
  }
  k++;
}

function methodThatReturnsAPromise(id) {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log(`Processing ${id}`);
      resolve(id);
    }, 1000);
  });
}

let result = [1,2,3].reduce( (accumulatorPromise, nextID) => {
  return accumulatorPromise.then(() => {
    return methodThatReturnsAPromise(nextID);
  });
}, Promise.resolve());

result.then(e => {
  console.log("Resolution is complete! Let's party.")
});

Debounce

Destructuring

Refactoring

Flow Control

Boilerplate

Testing

Idioms and Gotchas

Promisification

Generators

⚠️ **GitHub.com Fallback** ⚠️