Type Parameters

  • R

Hierarchy

  • Bluebird

Implements

Constructors

  • Create a new promise. The passed in function will receive functions resolve and reject as its arguments which can be called to seal the fate of the created promise.

    If promise cancellation is enabled, passed in function will receive one more function argument onCancel that allows to register an optional cancellation callback.

    Type Parameters

    • R

    Parameters

    • callback: ((resolve: ((thenableOrResult?: Resolvable<R>) => void), reject: ((error?: any) => void), onCancel?: ((callback: (() => void)) => void)) => void)
        • (resolve: ((thenableOrResult?: Resolvable<R>) => void), reject: ((error?: any) => void), onCancel?: ((callback: (() => void)) => void)): void
        • Parameters

          • resolve: ((thenableOrResult?: Resolvable<R>) => void)
              • (thenableOrResult?: Resolvable<R>): void
              • Parameters

                Returns void

          • reject: ((error?: any) => void)
              • (error?: any): void
              • Parameters

                • Optional error: any

                Returns void

          • Optional onCancel: ((callback: (() => void)) => void)
              • (callback: (() => void)): void
              • Parameters

                • callback: (() => void)
                    • (): void
                    • Returns void

                Returns void

          Returns void

    Returns Bluebird<R>

Properties

[toStringTag]: "Object"
caught: {
    <U>(onReject: undefined | null | ((error: any) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2, E3, E4, E5>(filter1: Constructor<E1>, filter2: Constructor<E2>, filter3: Constructor<E3>, filter4: Constructor<E4>, filter5: Constructor<E5>, onReject: ((error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2, E3, E4, E5>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, filter3: Constructor<E3> | CatchFilter<E3>, filter4: Constructor<E4> | CatchFilter<E4>, filter5: Constructor<E5> | CatchFilter<E5>, onReject: ((error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2, E3, E4>(filter1: Constructor<E1>, filter2: Constructor<E2>, filter3: Constructor<E3>, filter4: Constructor<E4>, onReject: ((error: E1 | E2 | E3 | E4) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2, E3, E4>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, filter3: Constructor<E3> | CatchFilter<E3>, filter4: Constructor<E4> | CatchFilter<E4>, onReject: ((error: E1 | E2 | E3 | E4) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2, E3>(filter1: Constructor<E1>, filter2: Constructor<E2>, filter3: Constructor<E3>, onReject: ((error: E1 | E2 | E3) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2, E3>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, filter3: Constructor<E3> | CatchFilter<E3>, onReject: ((error: E1 | E2 | E3) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2>(filter1: Constructor<E1>, filter2: Constructor<E2>, onReject: ((error: E1 | E2) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1, E2>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, onReject: ((error: E1 | E2) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1>(filter1: Constructor<E1>, onReject: ((error: E1) => Resolvable<U>)): Bluebird<R | U>;
    <U, E1>(filter1: Constructor<E1> | CatchFilter<E1>, onReject: ((error: E1) => Resolvable<U>)): Bluebird<R | U>;
}

Type declaration

    • <U>(onReject: undefined | null | ((error: any) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U = R

      Parameters

      • onReject: undefined | null | ((error: any) => Resolvable<U>)

      Returns Bluebird<R | U>

    • <U, E1, E2, E3, E4, E5>(filter1: Constructor<E1>, filter2: Constructor<E2>, filter3: Constructor<E3>, filter4: Constructor<E4>, filter5: Constructor<E5>, onReject: ((error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      • E3

      • E4

      • E5

      Parameters

      Returns Bluebird<R | U>

    • <U, E1, E2, E3, E4, E5>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, filter3: Constructor<E3> | CatchFilter<E3>, filter4: Constructor<E4> | CatchFilter<E4>, filter5: Constructor<E5> | CatchFilter<E5>, onReject: ((error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      • E3

      • E4

      • E5

      Parameters

      Returns Bluebird<R | U>

    • <U, E1, E2, E3, E4>(filter1: Constructor<E1>, filter2: Constructor<E2>, filter3: Constructor<E3>, filter4: Constructor<E4>, onReject: ((error: E1 | E2 | E3 | E4) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      • E3

      • E4

      Parameters

      Returns Bluebird<R | U>

    • <U, E1, E2, E3, E4>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, filter3: Constructor<E3> | CatchFilter<E3>, filter4: Constructor<E4> | CatchFilter<E4>, onReject: ((error: E1 | E2 | E3 | E4) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      • E3

      • E4

      Parameters

      Returns Bluebird<R | U>

    • <U, E1, E2, E3>(filter1: Constructor<E1>, filter2: Constructor<E2>, filter3: Constructor<E3>, onReject: ((error: E1 | E2 | E3) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      • E3

      Parameters

      Returns Bluebird<R | U>

    • <U, E1, E2, E3>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, filter3: Constructor<E3> | CatchFilter<E3>, onReject: ((error: E1 | E2 | E3) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      • E3

      Parameters

      Returns Bluebird<R | U>

    • <U, E1, E2>(filter1: Constructor<E1>, filter2: Constructor<E2>, onReject: ((error: E1 | E2) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      Parameters

      Returns Bluebird<R | U>

    • <U, E1, E2>(filter1: Constructor<E1> | CatchFilter<E1>, filter2: Constructor<E2> | CatchFilter<E2>, onReject: ((error: E1 | E2) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      • E2

      Parameters

      Returns Bluebird<R | U>

    • <U, E1>(filter1: Constructor<E1>, onReject: ((error: E1) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      Parameters

      Returns Bluebird<R | U>

    • <U, E1>(filter1: Constructor<E1> | CatchFilter<E1>, onReject: ((error: E1) => Resolvable<U>)): Bluebird<R | U>
    • This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise.

      Any exception happening in a .then-chain will propagate to nearest .catch handler.

      Alias .caught(); for compatibility with earlier ECMAScript version.

      Type Parameters

      • U

      • E1

      Parameters

      Returns Bluebird<R | U>

lastly: ((handler: (() => any)) => Bluebird<R>)

Type declaration

    • (handler: (() => any)): Bluebird<R>
    • Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise.

      There are special semantics for .finally() in that the final value cannot be modified from the handler.

      Alias .lastly(); for compatibility with earlier ECMAScript version.

      Parameters

      • handler: (() => any)
          • (): any
          • Returns any

      Returns Bluebird<R>

Promise: typeof Bluebird

Create a new promise. The passed in function will receive functions resolve and reject as its arguments which can be called to seal the fate of the created promise. If promise cancellation is enabled, passed in function will receive one more function argument onCancel that allows to register an optional cancellation callback.

version: string

The version number of the library

Methods

  • Same as calling Promise.any(thisPromise). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Type Parameters

    • Q

    Parameters

    Returns Bluebird<Q>

  • Same as calling Promise.any(thisPromise). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Returns Bluebird<never>

  • Parameters

    • callback: ((err: any, value?: R) => void)
        • (err: any, value?: R): void
        • Parameters

          • err: any
          • Optional value: R

          Returns void

    • Optional options: SpreadOption

    Returns Bluebird<R>

  • Parameters

    • Rest ...sink: any[]

    Returns Bluebird<R>

  • Create a promise that follows this promise, but is bound to the given thisArg value. A bound promise will call its handlers with the bound value set to this.

    Additionally promises derived from a bound promise will also be bound promises with the same thisArg binding as the original promise.

    Parameters

    • thisArg: any

    Returns Bluebird<R>

  • This is a convenience method for doing:

    promise.then(function(obj){ return obj[propertyName].call(obj, arg...); });

    Type Parameters

    • U extends string | number | symbol

    • Q

    Parameters

    • this: Bluebird<Q>
    • propertyName: U
    • Rest ...args: any[]

    Returns Bluebird<Q[U] extends ((...args: any[]) => any) ? ReturnType<any[any]> : never>

  • Cancel this promise. Will not do anything if this promise is already settled or if the cancellation feature has not been enabled

    Returns void

  • Same as calling Promise.delay(ms, this).

    Parameters

    • ms: number

    Returns Bluebird<R>

  • A meta method used to specify the disposer method that cleans up a resource when using Promise.using.

    Returns a Disposer object which encapsulates both the resource as well as the method to clean it up. The user can pass this object to Promise.using to get access to the resource when it becomes available, as well as to ensure its automatically cleaned up.

    The second argument passed to a disposer is the result promise of the using block, which you can inspect synchronously.

    Parameters

    Returns Disposer<R>

  • Like .then(), but any unhandled rejection that ends up here will be thrown as an error.

    Type Parameters

    • U

    Parameters

    Returns void

  • Same as calling Bluebird.each(thisPromise, iterator). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Type Parameters

    • Q

    Parameters

    Returns Bluebird<R>

  • Like .catch but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.

    Type Parameters

    • U

    Parameters

    Returns Bluebird<U>

  • Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise.

    There are special semantics for .finally() in that the final value cannot be modified from the handler.

    Alias .lastly(); for compatibility with earlier ECMAScript version.

    Parameters

    • handler: (() => any)
        • (): any
        • Returns any

    Returns Bluebird<R>

  • This is a convenience method for doing:

    promise.then(function(obj){ return obj[propertyName]; });

    Type Parameters

    • U extends string | number | symbol

    Parameters

    • key: U

    Returns Bluebird<R[U]>

  • See if this promise has been cancelled.

    Returns boolean

  • See if this promise has been fulfilled.

    Returns boolean

  • See if this promise is still defer.

    Returns boolean

  • See if this promise has been rejected.

    Returns boolean

  • See if this promise is resolved -> either fulfilled or rejected.

    Returns boolean

  • Same as calling Bluebird.mapSeries(thisPromise, iterator). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Type Parameters

    • U

    • Q

    Parameters

    Returns Bluebird<U[]>

  • Register a node-style callback on this promise.

    When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument.

    The error argument will be null in case of success. If the callback argument is not a function, this method does not do anything.

    Parameters

    • callback: ((err: any, value?: R) => void)
        • (err: any, value?: R): void
        • Parameters

          • err: any
          • Optional value: R

          Returns void

    • Optional options: SpreadOption

    Returns Bluebird<R>

  • Parameters

    • Rest ...sink: any[]

    Returns Bluebird<R>

  • Same as calling Promise.race(thisPromise, count). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Type Parameters

    • Q

    Parameters

    Returns Bluebird<Q>

  • Same as calling Promise.race(thisPromise, count). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Returns Bluebird<never>

  • Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.

    throws TypeError

    Returns any

  • Same as calling Promise.reduce(thisPromise, Function reducer, initialValue). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Type Parameters

    • U

    • Q

    Parameters

    • this: Bluebird<R & Iterable<Q>>
    • reducer: ((memo: U, item: Q, index: number, arrayLength: number) => Resolvable<U>)
        • (memo: U, item: Q, index: number, arrayLength: number): Resolvable<U>
        • Parameters

          • memo: U
          • item: Q
          • index: number
          • arrayLength: number

          Returns Resolvable<U>

    • Optional initialValue: U

    Returns Bluebird<U>

  • Synchronously inspect the state of this promise. The PromiseInspection will represent the state of the promise as snapshotted at the time of calling .reflect().

    Returns Bluebird<Inspection<R>>

  • Convenience method for:

    .then(function() { return value; });

    in the case where value doesn't change its value. That means value is bound at the time of calling .return()

    Alias .thenReturn(); for compatibility with earlier ECMAScript version.

    Returns Bluebird<void>

  • Type Parameters

    • U

    Parameters

    • value: U

    Returns Bluebird<U>

  • Same as calling Promise.some(thisPromise). With the exception that if this promise is bound to a value, the returned promise is bound to that value too. Same as calling Promise.some(thisPromise). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Type Parameters

    • Q

    Parameters

    Returns Bluebird<R>

  • Same as calling Promise.some(thisPromise). With the exception that if this promise is bound to a value, the returned promise is bound to that value too. Same as calling Promise.some(thisPromise). With the exception that if this promise is bound to a value, the returned promise is bound to that value too.

    Parameters

    • count: number

    Returns Bluebird<never>

  • Like calling .then, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.

    Type Parameters

    • U

    • Q

    Parameters

    Returns Bluebird<U>

  • Basically sugar for doing: somePromise.catch(function(){});

    Which is needed in case error handlers are attached asynchronously to the promise later, which would otherwise result in premature unhandled rejection reporting.

    Returns void

  • Like .finally(), but not called for rejections.

    Parameters

    • onFulFill: ((value: R) => any)
        • (value: R): any
        • Parameters

          • value: R

          Returns any

    Returns Bluebird<R>

  • Based on PromiseLike.then, but returns a Bluebird instance.

    Type Parameters

    • U

    Parameters

    Returns Bluebird<U>

  • Type Parameters

    • TResult1 = R

    • TResult2 = never

    Parameters

    • Optional onfulfilled: null | ((value: R) => Resolvable<TResult1>)
    • Optional onrejected: null | ((reason: any) => Resolvable<TResult2>)

    Returns Bluebird<TResult1 | TResult2>

  • Returns Bluebird<void>

  • Type Parameters

    • U

    Parameters

    • value: U

    Returns Bluebird<U>

  • Parameters

    Returns Bluebird<never>

  • Convenience method for:

    .then(function() { throw reason; }); Same limitations apply as with `.return()`.

    Alias .thenThrow(); for compatibility with earlier ECMAScript version.

    Parameters

    Returns Bluebird<never>

  • Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within ms milliseconds, the returned promise is rejected with a TimeoutError or the error as the reason.

    You may specify a custom error message with the message parameter.

    Parameters

    • ms: number
    • Optional message: string | Error

    Returns Bluebird<R>

  • This is implicitly called by JSON.stringify when serializing the object. Returns a serialized representation of the Promise.

    Returns object

  • Convert to String.

    Returns string

  • Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.

    throws TypeError

    Returns R

  • Sugar for Promise.resolve(undefined).bind(thisArg);. See .bind().

    Parameters

    • thisArg: any

    Returns Bluebird<void>

  • Cast the given value to a trusted promise.

    If value is already a trusted Promise, it is returned as is. If value is not a thenable, a fulfilled is: Promise returned with value as its fulfillment value. If value is a thenable (Promise-like object, like those returned by jQuery's $.ajax), returns a trusted that: Promise assimilates the state of the thenable.

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R>

  • Configure long stack traces, warnings, monitoring and cancellation. Note that even though false is the default here, a development environment might be detected which automatically enables long stack traces and warnings.

    Parameters

    • options: {
          asyncHooks?: boolean;
          cancellation?: boolean;
          longStackTraces?: boolean;
          monitoring?: boolean;
          warnings?: boolean | {
              wForgottenReturn: boolean;
          };
      }
      • Optional asyncHooks?: boolean

        Enable async hooks

      • Optional cancellation?: boolean

        Enable cancellation

      • Optional longStackTraces?: boolean

        Enable long stack traces

      • Optional monitoring?: boolean

        Enable monitoring

      • Optional warnings?: boolean | {
            wForgottenReturn: boolean;
        }

        Enable warnings

    Returns void

  • TODO: After https://github.com/Microsoft/TypeScript/issues/2983 is implemented, we can use the return type propagation of generators to automatically infer the return type T.

    Type Parameters

    • T

    Parameters

    Returns (() => Bluebird<T>)

  • Type Parameters

    • T

    • A1

    Parameters

    Returns ((a1: A1) => Bluebird<T>)

  • Type Parameters

    • T

    • A1

    • A2

    Parameters

    Returns ((a1: A1, a2: A2) => Bluebird<T>)

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    Parameters

    Returns ((a1: A1, a2: A2, a3: A3) => Bluebird<T>)

      • (a1: A1, a2: A2, a3: A3): Bluebird<T>
      • Parameters

        • a1: A1
        • a2: A2
        • a3: A3

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    • A4

    Parameters

    Returns ((a1: A1, a2: A2, a3: A3, a4: A4) => Bluebird<T>)

      • (a1: A1, a2: A2, a3: A3, a4: A4): Bluebird<T>
      • Parameters

        • a1: A1
        • a2: A2
        • a3: A3
        • a4: A4

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    Parameters

    Returns ((a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Bluebird<T>)

      • (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): Bluebird<T>
      • Parameters

        • a1: A1
        • a2: A2
        • a3: A3
        • a4: A4
        • a5: A5

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    • A6

    Parameters

    Returns ((a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Bluebird<T>)

      • (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): Bluebird<T>
      • Parameters

        • a1: A1
        • a2: A2
        • a3: A3
        • a4: A4
        • a5: A5
        • a6: A6

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    • A6

    • A7

    Parameters

    Returns ((a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Bluebird<T>)

      • (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): Bluebird<T>
      • Parameters

        • a1: A1
        • a2: A2
        • a3: A3
        • a4: A4
        • a5: A5
        • a6: A6
        • a7: A7

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    • A6

    • A7

    • A8

    Parameters

    • generatorFunction: ((a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>)
        • (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): IterableIterator<any>
        • Parameters

          • a1: A1
          • a2: A2
          • a3: A3
          • a4: A4
          • a5: A5
          • a6: A6
          • a7: A7
          • a8: A8

          Returns IterableIterator<any>

    • Optional options: CoroutineOptions

    Returns ((a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Bluebird<T>)

      • (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): Bluebird<T>
      • Parameters

        • a1: A1
        • a2: A2
        • a3: A3
        • a4: A4
        • a5: A5
        • a6: A6
        • a7: A7
        • a8: A8

        Returns Bluebird<T>

  • Returns a promise that will be resolved with value (or undefined) after given ms milliseconds. If value is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the value promise.

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R>

  • Parameters

    • ms: number

    Returns Bluebird<void>

  • Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.

    Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R[]>

  • Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given filterer function with the signature (item, index, arrayLength) where item is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.

    The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.

    *The original array is not modified.

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R[]>

  • Type Parameters

    • T

    Parameters

    • resolver: ((callback: ((err: any, result?: T) => void)) => void)
        • (callback: ((err: any, result?: T) => void)): void
        • Parameters

          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: FromNodeOptions

    Returns Bluebird<T>

  • Returns a promise that is resolved by a node style callback function.

    Type Parameters

    • T

    Parameters

    • resolver: ((callback: ((err: any, result?: T) => void)) => void)
        • (callback: ((err: any, result?: T) => void)): void
        • Parameters

          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: FromNodeOptions

    Returns Bluebird<T>

  • See if value is a trusted Promise.

    Parameters

    • value: any

    Returns boolean

  • Promise.join( Promise|any values..., function handler ) -> Promise For coordinating multiple concurrent discrete promises.

    Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array. This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply

    Type Parameters

    • R

    • A1

    Parameters

    Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    • A2

    Parameters

    Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    • A2

    • A3

    Parameters

    Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    • A2

    • A3

    • A4

    Parameters

    Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    • A2

    • A3

    • A4

    • A5

    Parameters

    Returns Bluebird<R>

  • Deprecated

    use .all instead

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R[]>

  • Call this right after the library is loaded to enabled long stack traces.

    Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.

    Returns void

  • Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given mapper function with the signature (item, index, arrayLength) where item is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.

    If the mapper function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.

    The original array is not modified.

    Type Parameters

    • R

    • U

    Parameters

    Returns Bluebird<U[]>

  • Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order.

    Returns a promise for an array that contains the values returned by the iterator function in their respective positions. The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled. This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach.

    If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well.

    Type Parameters

    • R

    • U

    Parameters

    Returns Bluebird<U[]>

  • Returns a new function that wraps the given function fn. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. This method is convenient when a function can sometimes return synchronously or throw synchronously.

    Type Parameters

    • R

    Parameters

    Returns (() => Bluebird<R>)

      • (): Bluebird<R>
      • Returns a new function that wraps the given function fn. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. This method is convenient when a function can sometimes return synchronously or throw synchronously.

        Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    Parameters

    Returns ((arg1: A1) => Bluebird<R>)

  • Type Parameters

    • R

    • A1

    • A2

    Parameters

    Returns ((arg1: A1, arg2: A2) => Bluebird<R>)

      • (arg1: A1, arg2: A2): Bluebird<R>
      • Parameters

        • arg1: A1
        • arg2: A2

        Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    • A2

    • A3

    Parameters

    • fn: ((arg1: A1, arg2: A2, arg3: A3) => Resolvable<R>)
        • (arg1: A1, arg2: A2, arg3: A3): Resolvable<R>
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3

          Returns Resolvable<R>

    Returns ((arg1: A1, arg2: A2, arg3: A3) => Bluebird<R>)

      • (arg1: A1, arg2: A2, arg3: A3): Bluebird<R>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3

        Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    • A2

    • A3

    • A4

    Parameters

    • fn: ((arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Resolvable<R>)
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4): Resolvable<R>
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4

          Returns Resolvable<R>

    Returns ((arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<R>)

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4): Bluebird<R>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4

        Returns Bluebird<R>

  • Type Parameters

    • R

    • A1

    • A2

    • A3

    • A4

    • A5

    Parameters

    • fn: ((arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Resolvable<R>)
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5): Resolvable<R>
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4
          • arg5: A5

          Returns Resolvable<R>

    Returns ((arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<R>)

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5): Bluebird<R>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4
        • arg5: A5

        Returns Bluebird<R>

  • Type Parameters

    • R

    Parameters

    Returns ((...args: any[]) => Bluebird<R>)

      • (...args: any[]): Bluebird<R>
      • Parameters

        • Rest ...args: any[]

        Returns Bluebird<R>

  • Add handler as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or console.error in browsers.

    Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.

    Parameters

    • handler: ((reason: any) => any)
        • (reason: any): any
        • Parameters

          • reason: any

          Returns any

    Returns void

  • Add handler as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or console.error in browsers.

    Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.

    Note: this hook is specific to the bluebird instance its called on, application developers should use global rejection events.

    Parameters

    Returns void

  • Returns a function that will wrap the given nodeFunction.

    Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.

    If the nodeFunction calls its callback with multiple success values, the fulfillment value will be an array of them.

    If you pass a receiver, the nodeFunction will be called as a method on the receiver.

    Type Parameters

    • T

    Parameters

    • func: ((callback: ((err: any, result?: T) => void)) => void)
        • (callback: ((err: any, result?: T) => void)): void
        • Parameters

          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: PromisifyOptions

    Returns (() => Bluebird<T>)

      • (): Bluebird<T>
      • Returns a function that will wrap the given nodeFunction.

        Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.

        If the nodeFunction calls its callback with multiple success values, the fulfillment value will be an array of them.

        If you pass a receiver, the nodeFunction will be called as a method on the receiver.

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    Parameters

    • func: ((arg1: A1, callback: ((err: any, result?: T) => void)) => void)
        • (arg1: A1, callback: ((err: any, result?: T) => void)): void
        • Parameters

          • arg1: A1
          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: PromisifyOptions

    Returns ((arg1: A1) => Bluebird<T>)

  • Type Parameters

    • T

    • A1

    • A2

    Parameters

    • func: ((arg1: A1, arg2: A2, callback: ((err: any, result?: T) => void)) => void)
        • (arg1: A1, arg2: A2, callback: ((err: any, result?: T) => void)): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: PromisifyOptions

    Returns ((arg1: A1, arg2: A2) => Bluebird<T>)

      • (arg1: A1, arg2: A2): Bluebird<T>
      • Parameters

        • arg1: A1
        • arg2: A2

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    Parameters

    • func: ((arg1: A1, arg2: A2, arg3: A3, callback: ((err: any, result?: T) => void)) => void)
        • (arg1: A1, arg2: A2, arg3: A3, callback: ((err: any, result?: T) => void)): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: PromisifyOptions

    Returns ((arg1: A1, arg2: A2, arg3: A3) => Bluebird<T>)

      • (arg1: A1, arg2: A2, arg3: A3): Bluebird<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    • A4

    Parameters

    • func: ((arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: ((err: any, result?: T) => void)) => void)
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: ((err: any, result?: T) => void)): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4
          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: PromisifyOptions

    Returns ((arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<T>)

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4): Bluebird<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4

        Returns Bluebird<T>

  • Type Parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    Parameters

    • func: ((arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: ((err: any, result?: T) => void)) => void)
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: ((err: any, result?: T) => void)): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4
          • arg5: A5
          • callback: ((err: any, result?: T) => void)
              • (err: any, result?: T): void
              • Parameters

                • err: any
                • Optional result: T

                Returns void

          Returns void

    • Optional options: PromisifyOptions

    Returns ((arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<T>)

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5): Bluebird<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4
        • arg5: A5

        Returns Bluebird<T>

  • Parameters

    • nodeFunction: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional options: PromisifyOptions

    Returns ((...args: any[]) => Bluebird<any>)

      • (...args: any[]): Bluebird<any>
      • Parameters

        • Rest ...args: any[]

        Returns Bluebird<any>

  • Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.

    Note If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R>

  • Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given reducer function with the signature (total, current, index, arrayLength) where item is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.

    If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.

    *The original array is not modified. If no initialValue is given and the array doesn't contain at least 2 items, the callback will not be called and undefined is returned.

    If initialValue is given and the array doesn't have at least 1 item, initialValue is returned.*

    Type Parameters

    • R

    • U

    Parameters

    • values: Resolvable<Iterable<Resolvable<R>>>
    • reducer: ((total: U, current: R, index: number, arrayLength: number) => Resolvable<U>)
        • (total: U, current: R, index: number, arrayLength: number): Resolvable<U>
        • Parameters

          • total: U
          • current: R
          • index: number
          • arrayLength: number

          Returns Resolvable<U>

    • Optional initialValue: U

    Returns Bluebird<U>

  • Create a promise that is rejected with the given reason.

    Parameters

    • reason: any

    Returns Bluebird<never>

  • Create a promise that is resolved with the given value. If value is a thenable or promise, the returned promise will assume its state.

    Returns Bluebird<void>

  • Type Parameters

    • R

    Parameters

    Returns Bluebird<R>

  • Initiate a competitive race between multiple promises or values (values will become immediately fulfilled promises). When count amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.

    If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.

    The original array is not modified.

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R[]>

  • Start the chain of promises with Promise.try. Any synchronous exceptions will be turned into rejections on the returned promise.

    Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.

    Alias for attempt(); for compatibility with earlier ECMAScript version.

    Type Parameters

    • R

    Parameters

    Returns Bluebird<R>

  • In conjunction with .disposer, using will make sure that no matter what, the specified disposer will be called when the promise returned by the callback passed to using has settled. The disposer is necessary because there is no standard interface in node for disposing resources.

    Type Parameters

    • R

    • T

    Parameters

    Returns Bluebird<T>

  • Type Parameters

    • R1

    • R2

    • T

    Parameters

    Returns Bluebird<T>

  • Type Parameters

    • R1

    • R2

    • R3

    • T

    Parameters

    • disposer: Disposer<R1>
    • disposer2: Disposer<R2>
    • disposer3: Disposer<R3>
    • executor: ((transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike<T>)
        • (transaction1: R1, transaction2: R2, transaction3: R3): PromiseLike<T>
        • Parameters

          • transaction1: R1
          • transaction2: R2
          • transaction3: R3

          Returns PromiseLike<T>

    Returns Bluebird<T>