Merge pull request #2447 from jmoenig/foreach-bug

fix for each bug
pull/89/head
Jens Mönig 2019-07-01 11:18:33 +02:00 zatwierdzone przez GitHub
commit a6d1a2c6ab
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 12 dodań i 19 usunięć

Wyświetl plik

@ -2183,29 +2183,22 @@ Process.prototype.doForEach = function (upvar, list, script) {
var next;
this.assertType(list, 'list');
if (list.isLinked) {
if (this.context.accumulator === null) {
this.context.accumulator = {
source : list,
remaining : list.length()
};
}
if (this.context.accumulator.remaining === 0) {
return;
}
if (this.context.accumulator === null) {
this.context.accumulator = {
source : list,
remaining : list.length(),
idx : 0
};
}
if (this.context.accumulator.remaining === 0) {
return;
}
this.context.accumulator.remaining -= 1;
if (this.context.accumulator.source.isLinked) {
next = this.context.accumulator.source.at(1);
this.context.accumulator.remaining -= 1;
this.context.accumulator.source =
this.context.accumulator.source.cdr();
} else { // arrayed
if (this.context.accumulator === null) {
this.context.accumulator = {
idx : 0
};
}
if (this.context.accumulator.idx === list.length()) {
return;
}
this.context.accumulator.idx += 1;
next = list.at(this.context.accumulator.idx);
}