mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Fix bugs in reduceLeft and reduceRight
This commit is contained in:
parent
a0790fba7d
commit
eed4093be5
@ -242,11 +242,9 @@ namespace ts {
|
||||
const count = array.length;
|
||||
if (count > 0) {
|
||||
let pos = 0;
|
||||
let result = arguments.length <= 2 ? array[pos] : initial;
|
||||
pos++;
|
||||
let result = arguments.length <= 2 ? array[pos++] : initial;
|
||||
while (pos < count) {
|
||||
result = f(<U>result, array[pos]);
|
||||
pos++;
|
||||
result = f(<U>result, array[pos++]);
|
||||
}
|
||||
return <U>result;
|
||||
}
|
||||
@ -260,11 +258,9 @@ namespace ts {
|
||||
if (array) {
|
||||
let pos = array.length - 1;
|
||||
if (pos >= 0) {
|
||||
let result = arguments.length <= 2 ? array[pos] : initial;
|
||||
pos--;
|
||||
let result = arguments.length <= 2 ? array[pos--] : initial;
|
||||
while (pos >= 0) {
|
||||
result = f(<U>result, array[pos]);
|
||||
pos--;
|
||||
result = f(<U>result, array[pos--]);
|
||||
}
|
||||
return <U>result;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user