neder
v0.0.1
Published
really simple and jewish javascript promises
Downloads
8
Readme
Neder
really simple and jewish javascript promises. suitable for both browsers and node environments.
Le'Chaiym! :beer:
Installation
npm
npm install --save neder
bower
bower install --save neder
Usage
Neder
var myAsyncMethod = function() {
var neder = new Neder();
somethingAsync("some input data", function(err, data) {
if (err) return neder.reject("some reason");
neder.resolve(data);
});
return neder;
};
Neder#then
accepts a callback with the format of function(data, next)
.
next
evaluates your next block. pass it your errors and data: next(err, data)
myAsyncMethod().then(function(data, next) {
// Do whatever and call "next" to pass your data to the next block
next(null, "some data");
});
Shorthand Neder.amen
function
Neder.amen(function(next) {
doSomethingAsync("next", "is a callback", "with next(err, data) format", next);
}).then(function(data, next) {
doSomethingElse("now you can use", data, "when you pipe it", next);
}).then(function(data, next) {
// You can call "next" explicitly:
doSomething(function(response) {
if (response.isError) return next(response.error);
next(null, response.data);
});
}).then(function(data, next) {
console.log("results: ", data);
});
Contributing
- Clone this repo
- Make sure the tests run awesomely in your machine (
npm test
) - Branch this mofo :smirk:
- Write fantastic code
- Pull request me
- That's it :shipit:
TODO
Neder#catch
method and using theerror
in thenext
blocks.