1.1.3 • Published 8 years ago

reject-error v1.1.3

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

reject-error

Build Status

Strong guarantee to return a promise

Usage

Call a function and return a promise, no matter what.

const promisify = require( "reject-error" );

function throws() {
	throw new Error( "boom" );
}

promisify( throws ); // returns a rejected promise

Get a function that, when called, returns a promise, no matter what.

const promisify = require( "reject-error" );

function throws() {
	throw new Error( "boom" );
}

const safe = promisify.proxy( throws );
safe(); // returns a rejected promise

Use a different promise library

const Promise   = require( "bluebird" );
const promisify = require( "reject-error" );

promisify.Promise = Promise;

function throws() {
	throw new Error( "boom" );
}

promisify( throws )
	.bind( this )
	.catch( { message : "boom" }, console.log ); // Bluebird-specific methods work
1.1.3

8 years ago

1.1.0

8 years ago

1.1.1

8 years ago

1.1.2

8 years ago

1.0.0

8 years ago