do-then

1.0.1 • Public • Published

DO-THEN

Realise sync or async tasks as promises, resolve to do the next step or reject and catch an error.

INSTALL

npm i do-then

USE / EXAMPLE

new Do(function( resolve, reject ){

	resolve("nope");

})
.then(function( resolve, reject, promise ){

	if( promise == "foo" ){

		resolve("bar");

	}
	else {

		reject("promise is not equal to 'foo' but '" + promise + "'");

	};

})
.then(function( resolve, reject, promise ){

	if( promise == "bar" ){

		console.info("Promise is correct");

	}
	else {

		reject("Promise is not correct");

	};


})
.catch(function( retry, promise ){

	console.error("catch error: ", promise);

	retry(false, function( resolve, reject ){

		console.log("restart")

		resolve("foo");

	}, function( retry, promise ){

		console.error("Cant do nothing at all...");

	});

});

Package Sidebar

Install

npm i do-then

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • jordandelcros