Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "promise/revert"

Index

Functions

Functions

revert

  • revert<T>(promise: Promise<any>): Promise<T>
  • Revert Promise

    Exchanges resolve state with rejection of a promise


    Example usage:

    import { revert } from "@thalesrc/js-utils/promise";
    
    const errorPromise = Promise.reject(new Error('foo'));
    
    revert(errorPromise)
     .then(err => {
       console.log("this will be logged", err);
     })
     .catch(res => {
       console.log("this won't be logged", res);
     });

    Proto usage example:

    import "@thalesrc/js-utils/promise/proto/revert";
    
    Promise.reject(new Error('foo'))
     .revert()
     .then(err => {
       console.log("this will be logged", err);
     })
     .catch(res => {
       console.log("this won't be logged", res);
     });

    Type parameters

    • T

    Parameters

    • promise: Promise<any>

      The promise to revert its statements

    Returns Promise<T>

    the reverted promise

Generated using TypeDoc