summaryrefslogtreecommitdiff
path: root/lib/internal/applyEach.js
diff options
context:
space:
mode:
authorAlex Early <alexander.early@gmail.com>2016-02-23 16:19:38 -0800
committerAlex Early <alexander.early@gmail.com>2016-02-23 16:19:38 -0800
commit3d1781cbb9a215b30fc03c2135309fe3579e5689 (patch)
treee26f489e37ae3a227867b3d1dfe6c04afa361c23 /lib/internal/applyEach.js
parent01205e053b16c7843a3d4d3c9075b33de5adb2d0 (diff)
parent070ed49496d5cf0b3c31a8091608610961191238 (diff)
downloadasync-3d1781cbb9a215b30fc03c2135309fe3579e5689.tar.gz
Merge pull request #996 from caolan/modularization
Modularization
Diffstat (limited to 'lib/internal/applyEach.js')
-rw-r--r--lib/internal/applyEach.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/internal/applyEach.js b/lib/internal/applyEach.js
new file mode 100644
index 0000000..25bcce1
--- /dev/null
+++ b/lib/internal/applyEach.js
@@ -0,0 +1,22 @@
+'use strict';
+
+import rest from 'lodash/rest';
+
+export default function applyEach(eachfn) {
+ return rest(function(fns, args) {
+ var go = rest(function(args) {
+ var that = this;
+ var callback = args.pop();
+ return eachfn(fns, function (fn, _, cb) {
+ fn.apply(that, args.concat([cb]));
+ },
+ callback);
+ });
+ if (args.length) {
+ return go.apply(this, args);
+ }
+ else {
+ return go;
+ }
+ });
+}