really simple and jewish javascript promises. suitable for both browsers and node environments.
Le'Chaiym! 🍺
npm install --save neder
bower install --save 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;
};
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");
});
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);
});
- Clone this repo
- Make sure the tests run awesomely in your machine (
npm test
) - Branch this mofo 😏
- Write fantastic code
- Pull request me
- That's it
Neder#catch
method and using theerror
in thenext
blocks.