@types/when

  • Version 2.4.41
  • Published
  • 20.7 kB
  • No dependencies
  • MIT license

Install

npm i @types/when
yarn add @types/when
pnpm add @types/when

Overview

TypeScript definitions for when

Index

Functions

function When

When: typeof When;

    Namespaces

    namespace when

    module 'when' {}

      function all

      all: <T>(promisesOrValues: any[]) => Promise<T>;
      • Return a promise that will resolve only once all the supplied promisesOrValues have resolved. The resolution value of the returned promise will be an array containing the resolution values of each of the promisesOrValues.

        Parameter promisesOrValues

        array of anything, may contain a mix of Promises and values

      function attempt

      attempt: {
      <T>(f: _.Fn0<T>): Promise<T>;
      <A1, T>(f: _.Fn1<A1, T>, arg1: A1 | Promise<A1>): Promise<T>;
      <A1, A2, T>(
      f: _.Fn2<A1, A2, T>,
      arg1: A1 | Promise<A1>,
      arg2: A2 | Promise<A2>
      ): Promise<T>;
      <A1, A2, A3, T>(
      f: _.Fn3<A1, A2, A3, T>,
      arg1: A1 | Promise<A1>,
      arg2: A2 | Promise<A2>,
      arg3: A3 | Promise<A3>
      ): Promise<T>;
      <A1, A2, A3, A4, T>(
      f: _.Fn4<A1, A2, A3, A4, T>,
      arg1: A1 | Promise<A1>,
      arg2: A2 | Promise<A2>,
      arg3: A3 | Promise<A3>,
      arg4: A4 | Promise<A4>
      ): Promise<T>;
      <A1, A2, A3, A4, A5, T>(
      f: _.Fn5<A1, A2, A3, A4, A5, T>,
      arg1: A1 | Promise<A1>,
      arg2: A2 | Promise<A2>,
      arg3: A3 | Promise<A3>,
      arg4: A4 | Promise<A4>,
      arg5: A5 | Promise<A5>
      ): Promise<T>;
      };

        function defer

        defer: <T>() => Deferred<T>;
        • Creates a {promise, resolver} pair, either or both of which may be given out safely to consumers. The resolver has resolve, reject, and progress. The promise has then plus extended promise API.

        function iterate

        iterate: <U>(
        f: (seed: U) => U | Promise<U>,
        predicate: (value: U) => boolean,
        handler: (value: U) => Promise<any> | void,
        seed: U | Promise<U>
        ) => Promise<U>;
        • Generates a potentially infinite stream of promises by repeatedly calling f until predicate becomes true.

          Parameter f

          function that, given a seed, returns the next value or a promise for it.

          Parameter predicate

          function that receives the current iteration value, and should return truthy when the iterating should stop

          Parameter handler

          function that receives each value as it is produced by f. It may return a promise to delay the next iteration.

          Parameter seed

          initial value provided to the handler, and first f invocation. May be a promise.

        function join

        join: {
        <T>(...promises: Array<Promise<T>>): Promise<T[]>;
        <T>(...promises: any[]): Promise<T[]>;
        };
        • Joins multiple promises into a single returned promise. a promise that will fulfill when *all* the input promises have fulfilled, or will reject when *any one* of the input promises rejects.

        function lift

        lift: {
        <T>(f: _.Fn0<T>): _.LiftedFn0<T>;
        <A1, T>(f: _.Fn1<A1, T>): _.LiftedFn1<A1, T>;
        <A1, A2, T>(f: _.Fn2<A1, A2, T>): _.LiftedFn2<A1, A2, T>;
        <A1, A2, A3, T>(f: _.Fn3<A1, A2, A3, T>): _.LiftedFn3<A1, A2, A3, T>;
        <A1, A2, A3, A4, T>(f: _.Fn4<A1, A2, A3, A4, T>): _.LiftedFn4<A1, A2, A3, A4, T>;
        <A1, A2, A3, A4, A5, T>(f: _.Fn5<A1, A2, A3, A4, A5, T>): _.LiftedFn5<
        A1,
        A2,
        A3,
        A4,
        A5,
        T
        >;
        };

          function map

          map: <T>(
          promisesOrValues: any[],
          mapFunc: (value: any, index: number) => any
          ) => Promise<T>;
          • Promise-aware array map function, similar to Array.prototype.map(), but input array may contain promises or values.

            Parameter promisesOrValues

            array of anything, may contain a mix of Promises and values

            Parameter mapFunc

            map function which may return a promise or value

            Returns

            a promise that will fulfill with an array of mapped values or reject if any input promise rejects.

          function promise

          promise: <T>(
          resolver: (resolve: (value: T) => void, reject: (reason: any) => void) => void
          ) => Promise<T>;

            function reduce

            reduce: <T>(
            promisesOrValues: any[],
            reduceFunc: (reduction: T, value: any, index: number) => T | Promise<T>,
            initialValue: T
            ) => Promise<T>;
            • Traditional reduce function, similar to Array.prototype.reduce(), but input may contain promises and/or values, and reduceFunc may return either a value or a promise, *and* initialValue may be a promise for the starting value.

              Parameter promisesOrValues

              array or promise for an array of anything, may contain a mix of promises and values.

              Parameter reduceFunc

              function(accumulated:*, x:*, index:number):*} f reduce function

              Returns

              a promise that will resolve to the final reduced value

            function reduceRight

            reduceRight: <T>(
            promisesOrValues: any[],
            reduceFunc: (reduction: T, value: any, index: number) => T | Promise<T>,
            initialValue: T
            ) => Promise<T>;
            • Traditional reduce function, similar to Array.prototype.reduceRight(), but input may contain promises and/or values, and reduceFunc may return either a value or a promise, *and* initialValue may be a promise for the starting value.

              Parameter promisesOrValues

              array or promise for an array of anything, may contain a mix of promises and values.

              Parameter reduceFunc

              function(accumulated:*, x:*, index:number):*} f reduce function

              Returns

              a promise that will resolve to the final reduced value

            function reject

            reject: <T>(reason: any) => Promise<T>;

              function resolve

              resolve: {
              (): Promise<void>;
              <T>(promiseOrValue: T | Promise<T> | Thenable<T>): Promise<T>;
              };
              • Returns a resolved promise. The returned promise will be - fulfilled with promiseOrValue if it is a value, or - if promiseOrValue is a promise - fulfilled with promiseOrValue's value after it is fulfilled - rejected with promiseOrValue's reason after it is rejected

              function settle

              settle: <T>(promisesOrValues: any[]) => Promise<Array<Descriptor<T>>>;
              • Returns a promise for an array containing the same number of elements as the input array. Each element is a descriptor object describing of the outcome of the corresponding element in the input. The returned promise will only reject if array itself is a rejected promise. Otherwise, it will always fulfill with an array of descriptors. This is in contrast to when.all, which will reject if any element of array rejects.

                Parameter promisesOrValues

                array of anything, may contain a mix of Promises and values

              function unfold

              unfold: <T, U>(
              unspool: (
              seed: U
              ) =>
              | [T | Promise<T>, U | Promise<U>]
              | Promise<[T | Promise<T>, U | Promise<U>]>,
              predicate: (value: U) => boolean | Promise<boolean>,
              handler: (value: T) => Promise<any> | void,
              seed: U | Promise<U>
              ) => Promise<void>;
              • Similar to when/iterate, when.unfold generates a potentially infinite stream of promises by repeatedly calling unspool until predicate becomes true. when.unfold allows you to thread additional state information through the iteration.

                Parameter unspool

                function that, given a seed, returns a [valueToSendToHandler, newSeed] pair. May return an array, array of promises, promise for an array, or promise for an array of promises.

                Parameter predicate

                function that receives the current seed, and should return truthy when the unfold should stop

                Parameter handler

                function that receives the valueToSendToHandler of the current iteration. This function can process valueToSendToHandler in whatever way you need. It may return a promise to delay the next iteration of the unfold.

                Parameter seed

                initial value provided to the first unspool invocation. May be a promise.

              function When

              When: typeof When;

                interface Deferred

                interface Deferred<T> {}

                  property promise

                  promise: Promise<T>;

                    method notify

                    notify: (update: any) => void;

                      method reject

                      reject: (reason: any) => void;

                        method resolve

                        resolve: { (value?: T): void; (value?: Promise<T>): void };

                          interface FulfilledDescriptor

                          interface FulfilledDescriptor<T> {}

                            property state

                            state: 'fulfilled';

                              property value

                              value: T;

                                interface PendingDescriptor

                                interface PendingDescriptor {}

                                  property state

                                  state: 'pending';

                                    interface Promise

                                    interface Promise<T> {}

                                      method catch

                                      catch: {
                                      <U>(onRejected?: (reason: any) => U | Promise<U>): Promise<U>;
                                      <U>(
                                      filter: (reason: any) => boolean,
                                      onRejected?: (reason: any) => U | Promise<U>
                                      ): Promise<U>;
                                      <U>(
                                      exceptionType: any,
                                      onRejected?: (reason: any) => U | Promise<U>
                                      ): Promise<U>;
                                      };

                                        method delay

                                        delay: (milliseconds: number) => Promise<T>;

                                          method done

                                          done: <U>(
                                          onFulfilled?: (value: T) => void,
                                          onRejected?: (reason: any) => void
                                          ) => void;

                                            method else

                                            else: (value: T) => Promise<T>;

                                              method ensure

                                              ensure: (onFulfilledOrRejected: Function) => Promise<T>;

                                                method finally

                                                finally: (onFulfilledOrRejected: Function) => Promise<T>;

                                                  method fold

                                                  fold: <U, V>(
                                                  combine: (value1: T, value2: V) => U | Promise<U>,
                                                  value2: V | Promise<V>
                                                  ) => Promise<U>;

                                                    method inspect

                                                    inspect: () => Snapshot<T>;

                                                      method orElse

                                                      orElse: (value: T) => Promise<T>;

                                                        method otherwise

                                                        otherwise: {
                                                        <U>(onRejected?: (reason: any) => U | Promise<U>): Promise<U>;
                                                        <U>(
                                                        predicate: (reason: any) => boolean,
                                                        onRejected?: (reason: any) => U | Promise<U>
                                                        ): Promise<U>;
                                                        <U>(
                                                        exceptionType: any,
                                                        onRejected?: (reason: any) => U | Promise<U>
                                                        ): Promise<U>;
                                                        };

                                                          method spread

                                                          spread: {
                                                          <T>(onFulfilled: _.Fn0<Promise<T> | T>): Promise<T>;
                                                          <A1, T>(onFulfilled: _.Fn1<A1, T | Promise<T>>): Promise<T>;
                                                          <A1, A2, T>(onFulfilled: _.Fn2<A1, A2, T | Promise<T>>): Promise<T>;
                                                          <A1, A2, A3, T>(onFulfilled: _.Fn3<A1, A2, A3, T | Promise<T>>): Promise<T>;
                                                          <A1, A2, A3, A4, T>(
                                                          onFulfilled: _.Fn4<A1, A2, A3, A4, T | Promise<T>>
                                                          ): Promise<T>;
                                                          <A1, A2, A3, A4, A5, T>(
                                                          onFulfilled: _.Fn5<A1, A2, A3, A4, A5, T | Promise<T>>
                                                          ): Promise<T>;
                                                          };

                                                            method tap

                                                            tap: (onFulfilledSideEffect: (value: T) => void) => Promise<T>;

                                                              method then

                                                              then: {
                                                              <TResult1, TResult2>(
                                                              onFulfilled: (value: T) => TResult1 | Thenable<TResult1>,
                                                              onRejected: (reason: any) => TResult2 | Thenable<TResult2>,
                                                              onProgress?: (update: any) => void
                                                              ): Promise<TResult1 | TResult2>;
                                                              <TResult>(
                                                              onFulfilled: (value: T) => TResult | Thenable<TResult>,
                                                              onRejected?: (reason: any) => TResult | Thenable<TResult>,
                                                              onProgress?: (update: any) => void
                                                              ): Promise<TResult>;
                                                              <TResult>(
                                                              onFulfilled: (value: T) => T | Thenable<T>,
                                                              onRejected: (reason: any) => TResult | Thenable<TResult>,
                                                              onProgress?: (update: any) => void
                                                              ): Promise<T | TResult>;
                                                              (
                                                              onFulfilled?: (value: T) => T | Thenable<T>,
                                                              onRejected?: (reason: any) => T | Thenable<T>,
                                                              onProgress?: (update: any) => void
                                                              ): Promise<T>;
                                                              };

                                                                method timeout

                                                                timeout: (milliseconds: number, reason?: any) => Promise<T>;

                                                                  method with

                                                                  with: (thisArg: any) => Promise<T>;

                                                                    method withThis

                                                                    withThis: (thisArg: any) => Promise<T>;

                                                                      method yield

                                                                      yield: <U>(value: U | Promise<U>) => Promise<U>;

                                                                        interface RejectedDescriptor

                                                                        interface RejectedDescriptor {}

                                                                          property reason

                                                                          reason: any;

                                                                            property state

                                                                            state: 'rejected';

                                                                              interface Thenable

                                                                              interface Thenable<T> {}

                                                                                method then

                                                                                then: <U>(
                                                                                onFulfilled?: (value: T) => U,
                                                                                onRejected?: (reason: any) => U
                                                                                ) => Thenable<U>;

                                                                                  type Descriptor

                                                                                  type Descriptor<T> = FulfilledDescriptor<T> | RejectedDescriptor;
                                                                                  • Describes the outcome of a promise. state may be one of: "fulfilled" - the promise has resolved "rejected" - the promise has rejected

                                                                                  type Snapshot

                                                                                  type Snapshot<T> = FulfilledDescriptor<T> | RejectedDescriptor | PendingDescriptor;
                                                                                  • Snapshot which describes the status of a promise. state may be one of: "fulfilled" - the promise has resolved "rejected" - the promise has rejected "pending" - the promise is still pending to resolve/reject

                                                                                  namespace When

                                                                                  namespace When {}

                                                                                    function all

                                                                                    all: <T>(promisesOrValues: any[]) => Promise<T>;
                                                                                    • Return a promise that will resolve only once all the supplied promisesOrValues have resolved. The resolution value of the returned promise will be an array containing the resolution values of each of the promisesOrValues.

                                                                                      Parameter promisesOrValues

                                                                                      array of anything, may contain a mix of Promises and values

                                                                                    function attempt

                                                                                    attempt: {
                                                                                    <T>(f: _.Fn0<T>): Promise<T>;
                                                                                    <A1, T>(f: _.Fn1<A1, T>, arg1: A1 | Promise<A1>): Promise<T>;
                                                                                    <A1, A2, T>(
                                                                                    f: _.Fn2<A1, A2, T>,
                                                                                    arg1: A1 | Promise<A1>,
                                                                                    arg2: A2 | Promise<A2>
                                                                                    ): Promise<T>;
                                                                                    <A1, A2, A3, T>(
                                                                                    f: _.Fn3<A1, A2, A3, T>,
                                                                                    arg1: A1 | Promise<A1>,
                                                                                    arg2: A2 | Promise<A2>,
                                                                                    arg3: A3 | Promise<A3>
                                                                                    ): Promise<T>;
                                                                                    <A1, A2, A3, A4, T>(
                                                                                    f: _.Fn4<A1, A2, A3, A4, T>,
                                                                                    arg1: A1 | Promise<A1>,
                                                                                    arg2: A2 | Promise<A2>,
                                                                                    arg3: A3 | Promise<A3>,
                                                                                    arg4: A4 | Promise<A4>
                                                                                    ): Promise<T>;
                                                                                    <A1, A2, A3, A4, A5, T>(
                                                                                    f: _.Fn5<A1, A2, A3, A4, A5, T>,
                                                                                    arg1: A1 | Promise<A1>,
                                                                                    arg2: A2 | Promise<A2>,
                                                                                    arg3: A3 | Promise<A3>,
                                                                                    arg4: A4 | Promise<A4>,
                                                                                    arg5: A5 | Promise<A5>
                                                                                    ): Promise<T>;
                                                                                    };

                                                                                      function defer

                                                                                      defer: <T>() => Deferred<T>;
                                                                                      • Creates a {promise, resolver} pair, either or both of which may be given out safely to consumers. The resolver has resolve, reject, and progress. The promise has then plus extended promise API.

                                                                                      function iterate

                                                                                      iterate: <U>(
                                                                                      f: (seed: U) => U | Promise<U>,
                                                                                      predicate: (value: U) => boolean,
                                                                                      handler: (value: U) => Promise<any> | void,
                                                                                      seed: U | Promise<U>
                                                                                      ) => Promise<U>;
                                                                                      • Generates a potentially infinite stream of promises by repeatedly calling f until predicate becomes true.

                                                                                        Parameter f

                                                                                        function that, given a seed, returns the next value or a promise for it.

                                                                                        Parameter predicate

                                                                                        function that receives the current iteration value, and should return truthy when the iterating should stop

                                                                                        Parameter handler

                                                                                        function that receives each value as it is produced by f. It may return a promise to delay the next iteration.

                                                                                        Parameter seed

                                                                                        initial value provided to the handler, and first f invocation. May be a promise.

                                                                                      function join

                                                                                      join: {
                                                                                      <T>(...promises: Array<Promise<T>>): Promise<T[]>;
                                                                                      <T>(...promises: any[]): Promise<T[]>;
                                                                                      };
                                                                                      • Joins multiple promises into a single returned promise. a promise that will fulfill when *all* the input promises have fulfilled, or will reject when *any one* of the input promises rejects.

                                                                                      function lift

                                                                                      lift: {
                                                                                      <T>(f: _.Fn0<T>): _.LiftedFn0<T>;
                                                                                      <A1, T>(f: _.Fn1<A1, T>): _.LiftedFn1<A1, T>;
                                                                                      <A1, A2, T>(f: _.Fn2<A1, A2, T>): _.LiftedFn2<A1, A2, T>;
                                                                                      <A1, A2, A3, T>(f: _.Fn3<A1, A2, A3, T>): _.LiftedFn3<A1, A2, A3, T>;
                                                                                      <A1, A2, A3, A4, T>(f: _.Fn4<A1, A2, A3, A4, T>): _.LiftedFn4<A1, A2, A3, A4, T>;
                                                                                      <A1, A2, A3, A4, A5, T>(f: _.Fn5<A1, A2, A3, A4, A5, T>): _.LiftedFn5<
                                                                                      A1,
                                                                                      A2,
                                                                                      A3,
                                                                                      A4,
                                                                                      A5,
                                                                                      T
                                                                                      >;
                                                                                      };

                                                                                        function map

                                                                                        map: <T>(
                                                                                        promisesOrValues: any[],
                                                                                        mapFunc: (value: any, index: number) => any
                                                                                        ) => Promise<T>;
                                                                                        • Promise-aware array map function, similar to Array.prototype.map(), but input array may contain promises or values.

                                                                                          Parameter promisesOrValues

                                                                                          array of anything, may contain a mix of Promises and values

                                                                                          Parameter mapFunc

                                                                                          map function which may return a promise or value

                                                                                          Returns

                                                                                          a promise that will fulfill with an array of mapped values or reject if any input promise rejects.

                                                                                        function promise

                                                                                        promise: <T>(
                                                                                        resolver: (resolve: (value: T) => void, reject: (reason: any) => void) => void
                                                                                        ) => Promise<T>;

                                                                                          function reduce

                                                                                          reduce: <T>(
                                                                                          promisesOrValues: any[],
                                                                                          reduceFunc: (reduction: T, value: any, index: number) => T | Promise<T>,
                                                                                          initialValue: T
                                                                                          ) => Promise<T>;
                                                                                          • Traditional reduce function, similar to Array.prototype.reduce(), but input may contain promises and/or values, and reduceFunc may return either a value or a promise, *and* initialValue may be a promise for the starting value.

                                                                                            Parameter promisesOrValues

                                                                                            array or promise for an array of anything, may contain a mix of promises and values.

                                                                                            Parameter reduceFunc

                                                                                            function(accumulated:*, x:*, index:number):*} f reduce function

                                                                                            Returns

                                                                                            a promise that will resolve to the final reduced value

                                                                                          function reduceRight

                                                                                          reduceRight: <T>(
                                                                                          promisesOrValues: any[],
                                                                                          reduceFunc: (reduction: T, value: any, index: number) => T | Promise<T>,
                                                                                          initialValue: T
                                                                                          ) => Promise<T>;
                                                                                          • Traditional reduce function, similar to Array.prototype.reduceRight(), but input may contain promises and/or values, and reduceFunc may return either a value or a promise, *and* initialValue may be a promise for the starting value.

                                                                                            Parameter promisesOrValues

                                                                                            array or promise for an array of anything, may contain a mix of promises and values.

                                                                                            Parameter reduceFunc

                                                                                            function(accumulated:*, x:*, index:number):*} f reduce function

                                                                                            Returns

                                                                                            a promise that will resolve to the final reduced value

                                                                                          function reject

                                                                                          reject: <T>(reason: any) => Promise<T>;

                                                                                            function resolve

                                                                                            resolve: {
                                                                                            (): Promise<void>;
                                                                                            <T>(promiseOrValue: T | Promise<T> | Thenable<T>): Promise<T>;
                                                                                            };
                                                                                            • Returns a resolved promise. The returned promise will be - fulfilled with promiseOrValue if it is a value, or - if promiseOrValue is a promise - fulfilled with promiseOrValue's value after it is fulfilled - rejected with promiseOrValue's reason after it is rejected

                                                                                            function settle

                                                                                            settle: <T>(promisesOrValues: any[]) => Promise<Array<Descriptor<T>>>;
                                                                                            • Returns a promise for an array containing the same number of elements as the input array. Each element is a descriptor object describing of the outcome of the corresponding element in the input. The returned promise will only reject if array itself is a rejected promise. Otherwise, it will always fulfill with an array of descriptors. This is in contrast to when.all, which will reject if any element of array rejects.

                                                                                              Parameter promisesOrValues

                                                                                              array of anything, may contain a mix of Promises and values

                                                                                            function unfold

                                                                                            unfold: <T, U>(
                                                                                            unspool: (
                                                                                            seed: U
                                                                                            ) =>
                                                                                            | [T | Promise<T>, U | Promise<U>]
                                                                                            | Promise<[T | Promise<T>, U | Promise<U>]>,
                                                                                            predicate: (value: U) => boolean | Promise<boolean>,
                                                                                            handler: (value: T) => Promise<any> | void,
                                                                                            seed: U | Promise<U>
                                                                                            ) => Promise<void>;
                                                                                            • Similar to when/iterate, when.unfold generates a potentially infinite stream of promises by repeatedly calling unspool until predicate becomes true. when.unfold allows you to thread additional state information through the iteration.

                                                                                              Parameter unspool

                                                                                              function that, given a seed, returns a [valueToSendToHandler, newSeed] pair. May return an array, array of promises, promise for an array, or promise for an array of promises.

                                                                                              Parameter predicate

                                                                                              function that receives the current seed, and should return truthy when the unfold should stop

                                                                                              Parameter handler

                                                                                              function that receives the valueToSendToHandler of the current iteration. This function can process valueToSendToHandler in whatever way you need. It may return a promise to delay the next iteration of the unfold.

                                                                                              Parameter seed

                                                                                              initial value provided to the first unspool invocation. May be a promise.

                                                                                            interface Deferred

                                                                                            interface Deferred<T> {}

                                                                                              property promise

                                                                                              promise: Promise<T>;

                                                                                                method notify

                                                                                                notify: (update: any) => void;

                                                                                                  method reject

                                                                                                  reject: (reason: any) => void;

                                                                                                    method resolve

                                                                                                    resolve: { (value?: T): void; (value?: Promise<T>): void };

                                                                                                      interface FulfilledDescriptor

                                                                                                      interface FulfilledDescriptor<T> {}

                                                                                                        property state

                                                                                                        state: 'fulfilled';

                                                                                                          property value

                                                                                                          value: T;

                                                                                                            interface PendingDescriptor

                                                                                                            interface PendingDescriptor {}

                                                                                                              property state

                                                                                                              state: 'pending';

                                                                                                                interface Promise

                                                                                                                interface Promise<T> {}

                                                                                                                  method catch

                                                                                                                  catch: {
                                                                                                                  <U>(onRejected?: (reason: any) => U | Promise<U>): Promise<U>;
                                                                                                                  <U>(
                                                                                                                  filter: (reason: any) => boolean,
                                                                                                                  onRejected?: (reason: any) => U | Promise<U>
                                                                                                                  ): Promise<U>;
                                                                                                                  <U>(
                                                                                                                  exceptionType: any,
                                                                                                                  onRejected?: (reason: any) => U | Promise<U>
                                                                                                                  ): Promise<U>;
                                                                                                                  };

                                                                                                                    method delay

                                                                                                                    delay: (milliseconds: number) => Promise<T>;

                                                                                                                      method done

                                                                                                                      done: <U>(
                                                                                                                      onFulfilled?: (value: T) => void,
                                                                                                                      onRejected?: (reason: any) => void
                                                                                                                      ) => void;

                                                                                                                        method else

                                                                                                                        else: (value: T) => Promise<T>;

                                                                                                                          method ensure

                                                                                                                          ensure: (onFulfilledOrRejected: Function) => Promise<T>;

                                                                                                                            method finally

                                                                                                                            finally: (onFulfilledOrRejected: Function) => Promise<T>;

                                                                                                                              method fold

                                                                                                                              fold: <U, V>(
                                                                                                                              combine: (value1: T, value2: V) => U | Promise<U>,
                                                                                                                              value2: V | Promise<V>
                                                                                                                              ) => Promise<U>;

                                                                                                                                method inspect

                                                                                                                                inspect: () => Snapshot<T>;

                                                                                                                                  method orElse

                                                                                                                                  orElse: (value: T) => Promise<T>;

                                                                                                                                    method otherwise

                                                                                                                                    otherwise: {
                                                                                                                                    <U>(onRejected?: (reason: any) => U | Promise<U>): Promise<U>;
                                                                                                                                    <U>(
                                                                                                                                    predicate: (reason: any) => boolean,
                                                                                                                                    onRejected?: (reason: any) => U | Promise<U>
                                                                                                                                    ): Promise<U>;
                                                                                                                                    <U>(
                                                                                                                                    exceptionType: any,
                                                                                                                                    onRejected?: (reason: any) => U | Promise<U>
                                                                                                                                    ): Promise<U>;
                                                                                                                                    };

                                                                                                                                      method spread

                                                                                                                                      spread: {
                                                                                                                                      <T>(onFulfilled: _.Fn0<Promise<T> | T>): Promise<T>;
                                                                                                                                      <A1, T>(onFulfilled: _.Fn1<A1, T | Promise<T>>): Promise<T>;
                                                                                                                                      <A1, A2, T>(onFulfilled: _.Fn2<A1, A2, T | Promise<T>>): Promise<T>;
                                                                                                                                      <A1, A2, A3, T>(onFulfilled: _.Fn3<A1, A2, A3, T | Promise<T>>): Promise<T>;
                                                                                                                                      <A1, A2, A3, A4, T>(
                                                                                                                                      onFulfilled: _.Fn4<A1, A2, A3, A4, T | Promise<T>>
                                                                                                                                      ): Promise<T>;
                                                                                                                                      <A1, A2, A3, A4, A5, T>(
                                                                                                                                      onFulfilled: _.Fn5<A1, A2, A3, A4, A5, T | Promise<T>>
                                                                                                                                      ): Promise<T>;
                                                                                                                                      };

                                                                                                                                        method tap

                                                                                                                                        tap: (onFulfilledSideEffect: (value: T) => void) => Promise<T>;

                                                                                                                                          method then

                                                                                                                                          then: {
                                                                                                                                          <TResult1, TResult2>(
                                                                                                                                          onFulfilled: (value: T) => TResult1 | Thenable<TResult1>,
                                                                                                                                          onRejected: (reason: any) => TResult2 | Thenable<TResult2>,
                                                                                                                                          onProgress?: (update: any) => void
                                                                                                                                          ): Promise<TResult1 | TResult2>;
                                                                                                                                          <TResult>(
                                                                                                                                          onFulfilled: (value: T) => TResult | Thenable<TResult>,
                                                                                                                                          onRejected?: (reason: any) => TResult | Thenable<TResult>,
                                                                                                                                          onProgress?: (update: any) => void
                                                                                                                                          ): Promise<TResult>;
                                                                                                                                          <TResult>(
                                                                                                                                          onFulfilled: (value: T) => T | Thenable<T>,
                                                                                                                                          onRejected: (reason: any) => TResult | Thenable<TResult>,
                                                                                                                                          onProgress?: (update: any) => void
                                                                                                                                          ): Promise<T | TResult>;
                                                                                                                                          (
                                                                                                                                          onFulfilled?: (value: T) => T | Thenable<T>,
                                                                                                                                          onRejected?: (reason: any) => T | Thenable<T>,
                                                                                                                                          onProgress?: (update: any) => void
                                                                                                                                          ): Promise<T>;
                                                                                                                                          };

                                                                                                                                            method timeout

                                                                                                                                            timeout: (milliseconds: number, reason?: any) => Promise<T>;

                                                                                                                                              method with

                                                                                                                                              with: (thisArg: any) => Promise<T>;

                                                                                                                                                method withThis

                                                                                                                                                withThis: (thisArg: any) => Promise<T>;

                                                                                                                                                  method yield

                                                                                                                                                  yield: <U>(value: U | Promise<U>) => Promise<U>;

                                                                                                                                                    interface RejectedDescriptor

                                                                                                                                                    interface RejectedDescriptor {}

                                                                                                                                                      property reason

                                                                                                                                                      reason: any;

                                                                                                                                                        property state

                                                                                                                                                        state: 'rejected';

                                                                                                                                                          interface Thenable

                                                                                                                                                          interface Thenable<T> {}

                                                                                                                                                            method then

                                                                                                                                                            then: <U>(
                                                                                                                                                            onFulfilled?: (value: T) => U,
                                                                                                                                                            onRejected?: (reason: any) => U
                                                                                                                                                            ) => Thenable<U>;

                                                                                                                                                              type Descriptor

                                                                                                                                                              type Descriptor<T> = FulfilledDescriptor<T> | RejectedDescriptor;
                                                                                                                                                              • Describes the outcome of a promise. state may be one of: "fulfilled" - the promise has resolved "rejected" - the promise has rejected

                                                                                                                                                              type Snapshot

                                                                                                                                                              type Snapshot<T> = FulfilledDescriptor<T> | RejectedDescriptor | PendingDescriptor;
                                                                                                                                                              • Snapshot which describes the status of a promise. state may be one of: "fulfilled" - the promise has resolved "rejected" - the promise has rejected "pending" - the promise is still pending to resolve/reject

                                                                                                                                                              namespace when/node

                                                                                                                                                              module 'when/node' {}

                                                                                                                                                                function apply

                                                                                                                                                                apply: {
                                                                                                                                                                <T>(fn: _.NodeFn0<T>, args: any[] | IArguments): when.Promise<T>;
                                                                                                                                                                <T>(fn: _.NodeFn1<any, T>, args: IArguments | any[]): when.Promise<T>;
                                                                                                                                                                <T>(fn: _.NodeFn2<any, any, T>, args: IArguments | any[]): when.Promise<T>;
                                                                                                                                                                <T>(fn: _.NodeFn3<any, any, any, T>, args: IArguments | any[]): when.Promise<T>;
                                                                                                                                                                <T>(
                                                                                                                                                                fn: _.NodeFn4<any, any, any, any, T>,
                                                                                                                                                                args: IArguments | any[]
                                                                                                                                                                ): when.Promise<T>;
                                                                                                                                                                <T>(
                                                                                                                                                                fn: _.NodeFn5<any, any, any, any, any, T>,
                                                                                                                                                                args: IArguments | any[]
                                                                                                                                                                ): when.Promise<T>;
                                                                                                                                                                };

                                                                                                                                                                  function bindCallback

                                                                                                                                                                  bindCallback: <TArg>(
                                                                                                                                                                  arg: when.Promise<TArg>,
                                                                                                                                                                  callback: (err: any, arg: TArg) => void
                                                                                                                                                                  ) => when.Promise<TArg>;

                                                                                                                                                                    function call

                                                                                                                                                                    call: {
                                                                                                                                                                    <T>(fn: _.NodeFn0<T>): when.Promise<T>;
                                                                                                                                                                    <A1, T>(fn: _.NodeFn1<A1, T>, arg1: A1 | when.Promise<A1>): when.Promise<T>;
                                                                                                                                                                    <A1, A2, T>(
                                                                                                                                                                    fn: _.NodeFn2<A1, A2, T>,
                                                                                                                                                                    arg1: A1 | when.Promise<A1>,
                                                                                                                                                                    arg2: A2 | when.Promise<A2>
                                                                                                                                                                    ): when.Promise<T>;
                                                                                                                                                                    <A1, A2, A3, T>(
                                                                                                                                                                    fn: _.NodeFn3<A1, A2, A3, T>,
                                                                                                                                                                    arg1: A1 | when.Promise<A1>,
                                                                                                                                                                    arg2: A2 | when.Promise<A2>,
                                                                                                                                                                    arg3: A3 | when.Promise<A3>
                                                                                                                                                                    ): when.Promise<T>;
                                                                                                                                                                    <A1, A2, A3, A4, T>(
                                                                                                                                                                    fn: _.NodeFn4<A1, A2, A3, A4, T>,
                                                                                                                                                                    arg1: A1 | when.Promise<A1>,
                                                                                                                                                                    arg2: A2 | when.Promise<A2>,
                                                                                                                                                                    arg3: A3 | when.Promise<A3>,
                                                                                                                                                                    arg4: A4 | when.Promise<A4>
                                                                                                                                                                    ): when.Promise<T>;
                                                                                                                                                                    <A1, A2, A3, A4, A5, T>(
                                                                                                                                                                    fn: _.NodeFn5<A1, A2, A3, A4, A5, T>,
                                                                                                                                                                    arg1: A1 | when.Promise<A1>,
                                                                                                                                                                    arg2: A2 | when.Promise<A2>,
                                                                                                                                                                    arg3: A3 | when.Promise<A3>,
                                                                                                                                                                    arg4: A4 | when.Promise<A4>,
                                                                                                                                                                    arg5: A5 | when.Promise<A5>
                                                                                                                                                                    ): when.Promise<T>;
                                                                                                                                                                    };

                                                                                                                                                                      function createCallback

                                                                                                                                                                      createCallback: <TArg>(
                                                                                                                                                                      resolver: Resolver<TArg>
                                                                                                                                                                      ) => (err: any, arg: TArg) => void;

                                                                                                                                                                        function lift

                                                                                                                                                                        lift: {
                                                                                                                                                                        <T>(fn: _.NodeFn0<T>): _.LiftedFn0<T>;
                                                                                                                                                                        <A1, T>(fn: _.NodeFn1<A1, T>): _.LiftedFn1<A1, T>;
                                                                                                                                                                        <A1, A2, T>(fn: _.NodeFn2<A1, A2, T>): _.LiftedFn2<A1, A2, T>;
                                                                                                                                                                        <A1, A2, A3, T>(fn: _.NodeFn3<A1, A2, A3, T>): _.LiftedFn3<A1, A2, A3, T>;
                                                                                                                                                                        <A1, A2, A3, A4, T>(fn: _.NodeFn4<A1, A2, A3, A4, T>): _.LiftedFn4<
                                                                                                                                                                        A1,
                                                                                                                                                                        A2,
                                                                                                                                                                        A3,
                                                                                                                                                                        A4,
                                                                                                                                                                        T
                                                                                                                                                                        >;
                                                                                                                                                                        <A1, A2, A3, A4, A5, T>(fn: _.NodeFn5<A1, A2, A3, A4, A5, T>): _.LiftedFn5<
                                                                                                                                                                        A1,
                                                                                                                                                                        A2,
                                                                                                                                                                        A3,
                                                                                                                                                                        A4,
                                                                                                                                                                        A5,
                                                                                                                                                                        T
                                                                                                                                                                        >;
                                                                                                                                                                        };

                                                                                                                                                                          function liftAll

                                                                                                                                                                          liftAll: (
                                                                                                                                                                          srcApi: any,
                                                                                                                                                                          transform?: (destApi: any, liftedFunc: Function, name: string) => any,
                                                                                                                                                                          destApi?: any
                                                                                                                                                                          ) => any;

                                                                                                                                                                            function liftCallback

                                                                                                                                                                            liftCallback: <TArg>(
                                                                                                                                                                            callback: (err: any, arg: TArg) => void
                                                                                                                                                                            ) => (value: when.Promise<TArg>) => when.Promise<TArg>;

                                                                                                                                                                              interface Resolver

                                                                                                                                                                              interface Resolver<T> {}

                                                                                                                                                                                method reject

                                                                                                                                                                                reject: (reason: any) => void;

                                                                                                                                                                                  method resolve

                                                                                                                                                                                  resolve: (value?: T | when.Promise<T>) => void;

                                                                                                                                                                                    Package Files (1)

                                                                                                                                                                                    Dependencies (0)

                                                                                                                                                                                    No dependencies.

                                                                                                                                                                                    Dev Dependencies (0)

                                                                                                                                                                                    No dev dependencies.

                                                                                                                                                                                    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/@types/when.

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