Promise
javascript promise built on top of findhit-class
Instalation
npm install findhit-promise --save
Usage
var Promise = ; // Implementing on your async function { // ... process }; async a1 b1 { // ... } // Will be { var self = {} {} {} return { // ... if somethingGoesWrong // You can throw Error, Promise will catch it... throw ; // Or you can send it to done // return done( new Error () ); // Then promise will redirect to right method // Otherwise ; } // If you have more actions on the same environment // you can configure them to be chained to this promise by: // specifying function // .extend( name, fn, context ) // giving an object with some functions // .extend( { name: fn, ... }, context ) // Or give an existent instance and the list of keys you want to use // This will run thoose functions with the first object as context // .extend( context, [ 'methodName', ... ] ) }; // You can: // Receive error on a separate function async a1 b1 // or async a1 b1 // Always receive err async a1 b1 // Chain multiple thens async a1 b1 // Chain multiple actions Promiseall async a1 b1 async a2 b2 async a3 b3 Promiseall async a1 b1 async a2 b2 async a3 b3 // Or if they provide some action context async a1 b1 async a2 b2 async a3 b3 // since .error catches current promise error, you can also configure a catch all errors async a1 b1
Thanks
Huge thanks to Forbes Lindesay.