Promise.withResolvers
Less than 1 minute
Promise.withResolvers
Module
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
const d = Promise.withResolvers();
d.resolve(42);
d.promise.then(console.log); // => 42