summaryrefslogtreecommitdiff
path: root/lib/seq.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/seq.js')
-rw-r--r--lib/seq.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/seq.js b/lib/seq.js
index 5672195..6dc28d8 100644
--- a/lib/seq.js
+++ b/lib/seq.js
@@ -1,5 +1,4 @@
import noop from './internal/noop';
-import slice from './internal/slice';
import reduce from './reduce';
import wrapAsync from './internal/wrapAsync';
@@ -41,10 +40,9 @@ import wrapAsync from './internal/wrapAsync';
* });
* });
*/
-export default function seq(/*...functions*/) {
- var _functions = Array.prototype.map.call(arguments, wrapAsync);
- return function(/*...args*/) {
- var args = slice(arguments);
+export default function seq(...functions) {
+ var _functions = functions.map(wrapAsync);
+ return function (...args) {
var that = this;
var cb = args[args.length - 1];
@@ -54,14 +52,11 @@ export default function seq(/*...functions*/) {
cb = noop;
}
- reduce(_functions, args, function(newargs, fn, cb) {
- fn.apply(that, newargs.concat(function(err/*, ...nextargs*/) {
- var nextargs = slice(arguments, 1);
+ reduce(_functions, args, (newargs, fn, cb) => {
+ fn.apply(that, newargs.concat((err, ...nextargs) => {
cb(err, nextargs);
}));
},
- function(err, results) {
- cb.apply(that, [err].concat(results));
- });
+ (err, results) => cb(err, ...results));
};
}