promise

  • Version 8.3.0
  • Published
  • 109 kB
  • 1 dependency
  • MIT license

Install

npm i promise
yarn add promise
pnpm add promise

Overview

Bare bones Promises/A+ implementation

Index

Variables

variable ThenPromise

var ThenPromise: ThenPromiseConstructor;

    Interfaces

    interface ThenPromise

    interface ThenPromise<T> extends Promise<T> {}
    • Represents the completion of an asynchronous operation

    method catch

    catch: <TResult = never>(
    onrejected?: (reason: any) => TResult | PromiseLike<TResult>
    ) => ThenPromise<T | TResult>;
    • Attaches a callback for only the rejection of the ThenPromise.

      Parameter onrejected

      The callback to execute when the ThenPromise is rejected.

      Returns

      A ThenPromise for the completion of the callback.

    method done

    done: (
    onfulfilled?: (value: T) => any,
    onrejected?: (reason: any) => any
    ) => void;
    • Attaches callbacks for the resolution and/or rejection of the ThenPromise, without returning a new promise.

      Parameter onfulfilled

      The callback to execute when the ThenPromise is resolved.

      Parameter onrejected

      The callback to execute when the ThenPromise is rejected.

    method nodeify

    nodeify: {
    (callback: void | null): ThenPromise<T>;
    (callback: (err: Error, value: T) => void): void;
    };
    • Calls a node.js style callback. If none is provided, the promise is returned.

    method then

    then: <TResult1 = T, TResult2 = never>(
    onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>,
    onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>
    ) => ThenPromise<TResult1 | TResult2>;
    • Attaches callbacks for the resolution and/or rejection of the ThenPromise.

      Parameter onfulfilled

      The callback to execute when the ThenPromise is resolved.

      Parameter onrejected

      The callback to execute when the ThenPromise is rejected.

      Returns

      A ThenPromise for the completion of which ever callback is executed.

    Package Files (1)

    Dependencies (1)

    Dev Dependencies (6)

    Peer Dependencies (0)

    No peer dependencies.

    Badge

    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/promise.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/promise)
    • HTML
      <a href="https://www.jsdocs.io/package/promise"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>