Commit 475e344db407a8f7d1b682b4cc3866f09f5131e3
Fix readOnce
Inner function was getting called twicecel committed on 5/1/2020, 5:14:46 PM
Parent: 92589aebf8f4f4f91d38ee6062b424ed041c7f34
Files changed
lib/util.js | changed |
lib/util.js | ||
---|---|---|
@@ -36,12 +36,12 @@ | ||
36 | 36 … | |
37 | 37 … | u.readOnce = function (fn) { |
38 | 38 … | var ended |
39 | 39 … | return function (end, cb) { |
40 … | + if (ended) return cb(ended) | |
40 | 41 … | fn(function (err, data) { |
41 | - if (err || ended) return cb(err || ended) | |
42 | - ended = true | |
43 | - cb(null, data) | |
42 … | + ended = err || true | |
43 … | + cb(err, data) | |
44 | 44 … | }) |
45 | 45 … | } |
46 | 46 … | } |
47 | 47 … |
Built with git-ssb-web