Function promise_withResolvers

alias for Promise.withResolvers. create a promise with external resolver and rejecter functions, provided in an object form.

if you'd like a more minifiable version, consider using the array equivalent: promise_outside.

Warning

don't invoke this alias on node <= 20, since it isn't available there, and the deno-to-node transformer does not polyfill this function for some reason.

TODO: in the future, when this is no longer an issue, get rid of the optional chaining operator ("?").

  • Creates a new Promise and returns it in an object, along with its resolve and reject functions.

    Type Parameters

    • T

    Returns PromiseWithResolvers<T>

    An object with the properties promise, resolve, and reject.

    const { promise, resolve, reject } = Promise.withResolvers<T>();