Commit b2606aaae852e50f39ef35d8630a33ac2a744e71
Fix forEachAsync
Charles Lehner committed on 10/13/2016, 6:21:56 PMParent: b53631fba4f93f901e325267c230dc8f2ea06f91
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -16,11 +16,11 @@ | ||
16 | 16 … | |
17 | 17 … | function forEachAsync(arr, fn, cb) { |
18 | 18 … | var i = 0 |
19 | 19 … | loop(function (next) { |
20 | - if (i >= arr.length) return cb() | |
20 … | + if (i >= arr.length) return cb && cb() | |
21 | 21 … | fn(arr[i++], function (err) { |
22 | - if (err) return cb(err) | |
22 … | + if (err) return cb && cb(err) | |
23 | 23 … | next() |
24 | 24 … | }) |
25 | 25 … | }) |
26 | 26 … | } |
@@ -103,9 +103,9 @@ | ||
103 | 103 … | |
104 | 104 … | function closePacks(packs, cb) { |
105 | 105 … | forEachAsync(packs, function (pack, cb) { |
106 | 106 … | pack.read(true, cb) |
107 | - }) | |
107 … | + }, cb) | |
108 | 108 … | } |
109 | 109 … | |
110 | 110 … | module.exports = function concatPacks(packs) { |
111 | 111 … | /* packs: [{read: source, numObjects: int}] */ |
Built with git-ssb-web