0.0.1 • Published 9 years ago
stager v0.0.1
Stager
Because you need to do a lot of asynchronous requests, that you watch to proccess in batches and you don't want to use a huge promise library.
Instead you may prefer a more data-centric approach.
Install
npm install stager
Await
Stager.await({
pizza: my_awesome_async_function( "tasty", 200 ),
kebab: my_awesome_async_function( "yuck", 400 ),
nested_stuff:{
some_string: "Hello",
another_function: my_awesome_async_function("Yes i am a function", 300)
}
}, function( err ){
// after about 400 ms this will be executed
console.log( this.pizza );
console.log( this.kebab );
console.log( this.nested_stuff.some_string );
});
Make a stage
var stager = Stager.make();
stager( function(){
this.pizza = my_awesome_async_function( "tasty", 200 );
this.kebab = my_awesome_async_function( "yuck", 200 );
this.hamburger = my_awesome_async_function( "yuck", 200 );
});
stager( function(){
// gets executed about 200 ms later
console.log( this.pizza );
console.log( this.kebab );
});
Clocking it
# Calling await
✓ Testing await (403ms)
# Setting a stage
✓ Staging 2 stages (208ms)
Testing
npm test
0.0.1
9 years ago