Skip to content


Resolve promise after given amount of time

Creates a promise that resolves after a given amount of time to the provided value.

const resolveAfter = (value, delay) =>
  new Promise(resolve => {
    setTimeout(() => resolve(value, delay));

resolveAfter('Hello', 1000);
// Returns a promise that resolves to 'Hello' after 1s

More like this

Start typing a keyphrase to see matching snippets.