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

import * as
import _
_
from 'radashi'
const {
const resolve: (value: unknown) => void
resolve
,
const reject: (reason?: any) => void
reject
,
const promise: Promise<unknown>
promise
} =
import _
_
.
withResolvers<unknown>(): _.PromiseWithResolvers<unknown>
export withResolvers

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

@seehttps://radashi.js.org/reference/async/withResolvers

@example

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

@version12.2.0

withResolvers
()
const resolve: (value: unknown) => void
resolve
(42)