We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 40e089e commit 4341d22Copy full SHA for 4341d22
src/Array.ts
@@ -16,10 +16,10 @@ define(Array.prototype, {
16
return this;
17
},
18
19
- flat: function (depth: number = 1) {
+ flat: function <T>(depth: number = 1) {
20
return this.reduce(
21
(acc: any, val: any) =>
22
- (Array.isArray(val) && depth >= 1) || depth === -1 ? acc.concat(val.flat(depth--)) : acc.concat(val),
+ (Array.isArray(val) && depth >= 1) || depth === -1 ? acc.push(...val.flat(depth--)) : acc.push(val),
23
[]
24
);
25
0 commit comments