batch-promises
batch-promises copied to clipboard
Changing arguments order
Would be nice to change the arguments order in order to put the collection at the end. This would allow the following usage:
import batchPromises from 'batch-promises';
Promise.resolve([1, 2, 3, 4, 5])
.then(batchPromises.bind(null, function() { }, 4));
Note i also put the Iteratee as the first argument since we also could want to set the batch size dynamically:
import batchPromises from 'batch-promises';
Promise.all([
4,
[1, 2, 3, 4, 5]
])
.spread(batchPromises.bind(null, function() { }));
It could be an occasion to publish a 1.0.0 version and embrace semver at the same time ;).
Let me know if you want me to do a PR according to those changes.
This + the option to return a function that takes a collection if none is passed through could lead to a nice api, eg:
import batchPromises from 'batch-promises';
Promise.resolve([1, 2, 3, 4, 5])
.then(batchPromises(somethingAsync, 3))
.then(batchPromises(somethingElseAsync, 3));
thoughts?
Also, down to embrace semver :D
Not sure if it worth currying by default since most people would rather use their own library for it. Some libraries like R also allow to flip arguments etc. It is also very simple to achieve currying in ES6 http://macr.ae/article/es6-and-currying.html