diff --git a/src/Array.ts b/src/Array.ts index d49925c41..8f004ca91 100644 --- a/src/Array.ts +++ b/src/Array.ts @@ -404,7 +404,10 @@ export const chainWithIndex = (as: Array): Array => { const out: Array = [] for (let i = 0; i < as.length; i++) { - out.push(...f(i, as[i])) + const bs = f(i, as[i]) + for (let j = 0; j < bs.length; j++) { + out.push(bs[j]) + } } return out } diff --git a/src/NonEmptyArray.ts b/src/NonEmptyArray.ts index 4a135abcd..38a1df417 100644 --- a/src/NonEmptyArray.ts +++ b/src/NonEmptyArray.ts @@ -569,7 +569,10 @@ export const chainWithIndex = (as: NonEmptyArray): NonEmptyArray => { const out: NonEmptyArray = fromReadonlyNonEmptyArray(f(0, head(as))) for (let i = 1; i < as.length; i++) { - out.push(...f(i, as[i])) + const bs = f(i, as[i]) + for (let j = 0; j < bs.length; j++) { + out.push(bs[j]) + } } return out } diff --git a/src/ReadonlyArray.ts b/src/ReadonlyArray.ts index fc413bd48..41c367086 100644 --- a/src/ReadonlyArray.ts +++ b/src/ReadonlyArray.ts @@ -289,7 +289,10 @@ export const chainWithIndex = } const out: Array = [] for (let i = 0; i < as.length; i++) { - out.push(...f(i, as[i])) + const bs = f(i, as[i]) + for (let j = 0; j < bs.length; j++) { + out.push(bs[j]) + } } return out } diff --git a/src/ReadonlyNonEmptyArray.ts b/src/ReadonlyNonEmptyArray.ts index cce5f2713..65875678e 100644 --- a/src/ReadonlyNonEmptyArray.ts +++ b/src/ReadonlyNonEmptyArray.ts @@ -565,7 +565,10 @@ export const chainWithIndex = (as: ReadonlyNonEmptyArray): ReadonlyNonEmptyArray => { const out: NonEmptyArray = _.fromReadonlyNonEmptyArray(f(0, head(as))) for (let i = 1; i < as.length; i++) { - out.push(...f(i, as[i])) + const bs = f(i, as[i]) + for (let j = 0; j < bs.length; j++) { + out.push(bs[j]) + } } return out }