perform

0.1.1 • Public • Published

perform

A sensible deferred library

A current work in progress, so don't use this yet

 
// for the sake of example, a simple log funtion
var log = function( x ) { console.log( x ); };
 
// so you have a deffered just like normal
var dfdA = perform.er();
dfdA.done( log, 'Yay! The deferred resolved!' );
dfdA.fail( log, 'Uh oh, it failed :(' );
 
// and this one
var dfdB = perform.er();
dfdB.done( log, 'B is so cool!' );
dfdB.fail( log, 'whatever....' );
 
// and now the reveal
perform( log, 'All done bitches' )
  .when( dfdA )
  .unless( dfdB );
 
dfdA.resolve();
dfdB.reject();
 
// CONSOLE:
// => Yay! The deferred resolved!
// => whatever...
// => All done bitches

As for arguments, you can still do a function like normal:

var dfdA = perform.er();
dfdA.done( function( arg1 ) {
  console.log( arg1 );
});
dfdA.resolve( 'hi there' );
 
// CONSOLE:
// => hi there

Or specify stuff inline like this:

 
var doSomething = function( x, y ) {
  console.log( x * y );
};
var dfdA = perform.er();
dfdA.done( doSomething, 5, perform.arg(0) );
dfdA.resolve( 20 );
 
// CONSOLE:
// => 100

Getting Started

Install the module with: npm install perform

Documentation

(Coming soon)

Examples

(Coming soon)

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

(Nothing yet)

License

Copyright (c) 2012 Dan Heberden
Licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i perform

Weekly Downloads

2

Version

0.1.1

License

none

Last publish

Collaborators

  • danheberden