Skip to content

withResolvers

Ponyfill for Promise.withResolvers()

118 bytes

Usage

Creates a new promise and returns the resolve and reject functions along with the promise itself.

The ponyfill for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers

const { resolve, reject, promise } = withResolvers()
resolve(42)