Skip to main content

Promise.withResolvers

Less than 1 minutefeaturees-proposal

Promise.withResolversopen in new window

Module

esnext.promise.with-resolversopen in new window

Types

interface PromiseConstructor {
  withResolvers<T>(): {
    promise: Promise<T>;
    resolve: (value: T | PromiseLike<T>) => void;
    reject: (reason?: any) => void;
  };
}

Entry points

core-js/proposals/promise-with-resolvers
core-js(-pure)/full/promise/with-resolvers

Example

Exampleopen in new window:

const d = Promise.withResolvers();
d.resolve(42);
d.promise.then(console.log); // => 42