summaryrefslogtreecommitdiff
path: root/lib/internal
diff options
context:
space:
mode:
authorStéphane MBAPE <smbape@yahoo.fr>2018-02-14 21:20:35 +0100
committerStéphane MBAPE <smbape@yahoo.fr>2018-02-14 21:20:35 +0100
commitcd6beba687bec8112357ff72b6a610cf245590cd (patch)
tree58d631183ac8c4fbc9b7080667f6dd99511f8347 /lib/internal
parentd02807894d9bcf6bff076413e3c7230e7df0f35a (diff)
downloadasync-cd6beba687bec8112357ff72b6a610cf245590cd.tar.gz
fix "RangeError: Maximum call stack size exceeded"
Diffstat (limited to 'lib/internal')
-rw-r--r--lib/internal/eachOfLimit.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/internal/eachOfLimit.js b/lib/internal/eachOfLimit.js
index da46fa4..0a1f5bc 100644
--- a/lib/internal/eachOfLimit.js
+++ b/lib/internal/eachOfLimit.js
@@ -15,6 +15,7 @@ export default function _eachOfLimit(limit) {
var nextElem = iterator(obj);
var done = false;
var running = 0;
+ var looping = false;
function iterateeCallback(err, value) {
running -= 1;
@@ -26,12 +27,13 @@ export default function _eachOfLimit(limit) {
done = true;
return callback(null);
}
- else {
+ else if (!looping) {
replenish();
}
}
function replenish () {
+ looping = true;
while (running < limit && !done) {
var elem = nextElem();
if (elem === null) {
@@ -44,6 +46,7 @@ export default function _eachOfLimit(limit) {
running += 1;
iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
}
+ looping = false;
}
replenish();