Skip to content

Instantly share code, notes, and snippets.

@oleggrishechkin
Last active May 27, 2021 17:09
Show Gist options
  • Save oleggrishechkin/e2ae56b148d7a3fb6810e8a6e826a12d to your computer and use it in GitHub Desktop.
Save oleggrishechkin/e2ae56b148d7a3fb6810e8a6e826a12d to your computer and use it in GitHub Desktop.

шаблон

// написать функцию-промисификацию для setTimeout

const promisedTimeout = (timeout) => {
  // код
};

promisedTimeout(1000).then(() => {
  console.log('resolved!'); // log after 1000ms
});

решение

const promisedTimeout = (timeout) => new Promise((resolve) => {
  setTimeout(() => {
    resolve();
  }, timeout);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment