Skip to content

Commit

Permalink
Remove lodash.isequal in favor of built-in array method
Browse files Browse the repository at this point in the history
  • Loading branch information
amccarthy1 committed Oct 22, 2024
1 parent 1b206dd commit 35e6197
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
20 changes: 2 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@
"dependencies": {
"lodash.escaperegexp": "^4.1.2",
"lodash.isboolean": "^3.0.3",
"lodash.isequal": "^4.5.0",
"lodash.isfunction": "^3.0.9",
"lodash.isnil": "^4.0.0"
},
"devDependencies": {
"@types/lodash.escaperegexp": "4.1.9",
"@types/lodash.isboolean": "3.0.9",
"@types/lodash.isequal": "4.5.8",
"@types/lodash.isfunction": "3.0.9",
"@types/lodash.isnil": "4.0.9",
"@types/node": "^20.10.5"
Expand Down
6 changes: 4 additions & 2 deletions packages/format/src/formatter/RowFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import isFunction from 'lodash.isfunction';
import isEqual from 'lodash.isequal';
import { FormatterOptions } from '../FormatterOptions';
import { FieldFormatter } from './FieldFormatter';
import { isSyncTransform, Row, RowArray, RowHashArray, RowTransformCallback, RowTransformFunction } from '../types';
Expand Down Expand Up @@ -145,7 +144,10 @@ export class RowFormatter<I extends Row, O extends Row> {
return { shouldFormatColumns: true, headers: null };
}
// if the row is equal to headers dont format
return { shouldFormatColumns: !isEqual(headers, row), headers };
if (Array.isArray(row) && headers.every((header, i): boolean => header === row[i])) {

Check warning on line 147 in packages/format/src/formatter/RowFormatter.ts

View workflow job for this annotation

GitHub Actions / unit (18.x)

Expected block statement surrounding arrow body

Check warning on line 147 in packages/format/src/formatter/RowFormatter.ts

View workflow job for this annotation

GitHub Actions / unit (20.x)

Expected block statement surrounding arrow body

Check warning on line 147 in packages/format/src/formatter/RowFormatter.ts

View workflow job for this annotation

GitHub Actions / unit (21.x)

Expected block statement surrounding arrow body
return { shouldFormatColumns: false, headers };
}
return { shouldFormatColumns: true, headers };
}

// todo change this method to unknown[]
Expand Down

0 comments on commit 35e6197

Please sign in to comment.