mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Fix bugs in reduceLeft and reduceRight
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user