@hyperfrontend/immutable-api-utils/built-in-copy/promisepromise
Locked, prototype-pollution-resistant copy of the global Promise constructor and its statics.
The Promise constructor is wrapped in a createPromise factory and its statics (resolve, reject, all, race, allSettled, any, withResolvers) are captured at module-load time and frozen into a tamper-proof namespace, so async control flow keeps working even if the global Promise is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.
API Reference
ƒ Functions
§function
createPromise<T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void): Promise<T>
(Safe copy) Creates a new Promise using the captured Promise constructor. Use this instead of
new Promise().Parameters
| Name | Type | Description |
|---|---|---|
§executor | (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void | The executor function. |
Returns
Promise<T>A new Promise instance.
● Variables
(Safe copy) Namespace object containing all Promise factory functions. Note: Importing this imports all methods in this namespace (no tree-shaking).
(Safe copy) Returns a Promise that resolves when all promises resolve.
(Safe copy) Returns a Promise that resolves when all promises settle.
(Safe copy) Returns a Promise that resolves with the first fulfilled promise.
(Safe copy) Returns a Promise that resolves/rejects with the first settled promise.
(Safe copy) Returns a Promise that rejects with the given reason.
(Safe copy) Returns a Promise that resolves with the given value.
(Safe copy) Creates a Promise along with its resolve and reject functions. Note: Available only in ES2024+ environments.