Skip to content

Commit 0665d2f

Browse files
committed
refactor: more efficient flatten (#222)
1 parent 8b85bc8 commit 0665d2f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
],
5858
"license": "BSD-3-Clause",
5959
"main": "./dist/src/index.js",
60-
"files": ["dist/src/"],
60+
"files": [
61+
"dist/src/"
62+
],
6163
"name": "table",
6264
"repository": {
6365
"type": "git",

Diff for: src/utils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,13 @@ export const extractTruncates = (config: BaseConfig): number[] => {
124124
};
125125

126126
export const flatten = <T>(array: T[][]): T[] => {
127-
return ([] as T[]).concat(...array);
127+
const destination = [];
128+
const arrayLength = array.length;
129+
for (let index = 0; index < arrayLength; index++) {
130+
destination.push(...array[index]);
131+
}
132+
133+
return destination;
128134
};
129135

130136
export const calculateRangeCoordinate = (spanningCellConfig: SpanningCellConfig): RangeCoordinate => {

0 commit comments

Comments
 (0)