Commit cd76eff3ebf93df1912d899b6453a4b837d2eebb
filter loops if read function is sync
Dominic Tarr committed on 7/20/2014, 6:08:23 PMParent: 047277298060a158af99ed2a8f3162d93553ea61
Files changed
throughs.js | changed |
throughs.js | ||
---|---|---|
@@ -86,13 +86,19 @@ | ||
86 | 86 | function (read, test) { |
87 | 87 | //regexp |
88 | 88 | test = tester(test) |
89 | 89 | return function next (end, cb) { |
90 | - read(end, function (end, data) { | |
91 | - if(!end && !test(data)) | |
92 | - return next(end, cb) | |
93 | - cb(end, data) | |
94 | - }) | |
90 | + var sync, loop = true | |
91 | + while(loop) { | |
92 | + loop = false | |
93 | + sync = true | |
94 | + read(end, function (end, data) { | |
95 | + if(!end && !test(data)) | |
96 | + return sync ? loop = true : next(end, cb) | |
97 | + cb(end, data) | |
98 | + }) | |
99 | + sync = false | |
100 | + } | |
95 | 101 | } |
96 | 102 | } |
97 | 103 | |
98 | 104 | var filterNot = exports.filterNot = |
Built with git-ssb-web