1.0.0 • Published 7 years ago

@dynacom/futures v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

Futures

A Promise extension library.

That provides the ability to resolve multiple arguments and then call .next to run call a method that handles those multiple callbacks.

Resolving with Future.resolve will pass all of the provided arguments into a single array to pass to the next item in the chain.

Chaining with a .then will pass the full array into the first arguent of the callback.

Chaining with .next will spread the returned array into the callback as separate arguments.

let Future = require( './index.js' );

let f1 = Future.resolve( 'test', 'arg' )
	.next(
		( arg1, arg2 ) => {
			console.log( 'arg1: ' + arg1 ); // === 'test'
			console.log( 'arg2: ' + arg2 ); // === 'arg'
			return Future.resolve( 'second', 'stuff' );
		}
	)
	.next(
		( arg1, arg2 ) => {
			console.log( 'arg1: ' + arg1 ); // === 'second'
			console.log( 'arg2: ' + arg2 ); // === 'stuff'
		}
	);