Functional promises. It's like lodash/underscore for promises.
Using promises as functional values allows the developer to write asynchronous code in a synchronous way.
Method signature
lag.methodName(function, promise_array)
Lag uses the "function first" method signature in order to take advantage of the functional approach to programming.
If you prefer the put the values first and the method second, you can call the lag.promiseFirst() method to switch the parameter order to lag.methodName(promise_array, function).
NPM
npm install lag --save
Bower
bower install lag --save
var _ = require('lag');
var xhr = require('xhr');
var promises = [
_.asPromise(123),
_.asPromise(456),
_.promise(function (resolve, reject) {
http.get('http://someapi.com', function (err, res) {
if (err) return reject(err);
resolve(res)
});
})
];
_.map(_.add(1), promises)
.then(_.filter(_.lessThan(400)))
.then(function (values) {
// values === [124]
});npm install
npm run build
npm install
npm test