diff options
author | Alex Early <alexander.early@gmail.com> | 2018-07-08 16:58:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-08 16:58:36 -0700 |
commit | e4751178540a3c6e64598b93977481ec599704d2 (patch) | |
tree | dce5731bdb1076971d2e4a0a42fbe0d95c720185 /lib/seq.js | |
parent | 6405b109fe60541ff42d7638ac891d321d6a7bb3 (diff) | |
download | async-e4751178540a3c6e64598b93977481ec599704d2.tar.gz |
ES6-ify codebase (#1553)
* cancelable foreach
* cancelable waterfall
* cancellable auto
* fix lint
* fix tests
* cancelable whilst/until/during/forever
* fix waterfall test. It WILL get there
* docs
* use rest params instead of slice
* clean up internals
* remove property func
* clarify uses of createTester
* happy path async funtions in asyncify
* stop using arguments
* DLL to class
* moar arrows
* fix merge issues
* remove forOwn
* moar arrows
* fix merge mistake
* even more arrows, what can stop him
* mo more fn.apply(null,...)
* remove more spurious uses of apply
* update lint config
* just when you thought there couldn't possibly be more arrows
* use eslint:recommended
* even less uses or aguments
* get rid of prototype cuteness
* fix concat tests
* fix more tests
Diffstat (limited to 'lib/seq.js')
-rw-r--r-- | lib/seq.js | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -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)); }; } |