Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

invert-promise

brigand5.4kMIT2.0.0TypeScript support: included

if the promise resolves, reject, else resolve

readme

invert-promise

If the promise rejects, the resulting promise will resolve with the rejection value. Likewise with resolving becoming a rejection.

install

npm install invert-promise

usage

Examples from test.js:

var invertPromise = require('invert-promise');

test('positive', (t) => {
  t.plan(1);
  invertPromise(Promise.resolve(1)).catch(x => t.equal(x, 1));
});

test('negative', (t) => {
  t.plan(1);
  invertPromise(Promise.reject(1)).then(x => t.equal(x, 1));
});

changelog

2.0.0

A simple TypeScript definition file - #3

1.0.1

Documentation.

1.0.0

Initial release.