Vinyl
    Preparing search index...

    Function promise

    • Creates a promise that can be rejected early from an abort signal and can optionally provide cleanup handling when the promise is settled.

      Common cases that require clean-up would be promises based on event listeners that must be removed, or timers that need to be cleared.

      Promises are always expected to settle. They cannot be canceled, but they can be rejected. This promise wrapper can be given an ReadonlyAbort object which rejects the promise if abort is emitted before the promise settles.

      Type Parameters

      • T

      Parameters

      • executor: (
            resolve: (value: T | PromiseLike<T>) => void,
            reject: (reason?: any) => void,
        ) => void | Unsubscribe

        A method that will be invoked at most once immediately with two arguments, resolve and reject. resolve must be called when the promise should be resolved, reject may be called if the promise should be rejected. An optional function may be returned that performs any cleanup necessary when the promise settles. This is called immediately before resolve or reject. The executor may not be invoked if the abortSignal is already in an aborted state.

      • Optionalabort: Maybe<ReadonlyAbort>

        If provided, will reject the returned promise with the signal's abort reason when aborted.

      Returns Promise<T>