Skip to content

Commit

Permalink
refactor: more efficient flatten (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Dec 3, 2024
1 parent 8b85bc8 commit 0665d2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
],
"license": "BSD-3-Clause",
"main": "./dist/src/index.js",
"files": ["dist/src/"],
"files": [
"dist/src/"
],
"name": "table",
"repository": {
"type": "git",
Expand Down
8 changes: 7 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ export const extractTruncates = (config: BaseConfig): number[] => {
};

export const flatten = <T>(array: T[][]): T[] => {
return ([] as T[]).concat(...array);
const destination = [];
const arrayLength = array.length;
for (let index = 0; index < arrayLength; index++) {
destination.push(...array[index]);
}

return destination;
};

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

0 comments on commit 0665d2f

Please sign in to comment.