Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lodash.isequal in favor of built-in array method #1038

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

amccarthy1
Copy link
Contributor

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Summary

I recently installed fast-xml as a replacement for csv-stringify, and while I was happy to see a bundle size reduction, I noticed that around half of the bundle size from its usage was coming from lodash.isequal.

I noticed that this package is only used for one call that can be easily replaced with a native call to Array.every. The result should shave around 10KB (roughly half the total size) off bundle sizes in the browser.

image

Test coverage

This case seems to be covering the case where headers=true is passed, but the headers are inferred from the first row, which is an array of strings, to prevent double-writing the headers. I verified that, when I changed this to return true, 33 tests failed, implying significant coverage of this case.

I also verified that there is a specific test covering exactly this behavior, at RowFormatter.ts:119-124 (pasted here for clarity)

                describe('with headers=true', () => {
                    it('should only write the first row', async () => {
                        const formatter = createFormatter({ headers: true });
                        await expect(formatRow(headerRow, formatter)).resolves.toEqual([headerRow.join(',')]);
                    });
                });

@amccarthy1 amccarthy1 force-pushed the remove-lodash-isequal branch from 934f87a to 35e6197 Compare October 22, 2024 15:52
@juanri0s
Copy link
Contributor

@amccarthy1 thanks for contributing! Mind rebasing and resolving conflicts please?

@terrymun
Copy link

terrymun commented Feb 8, 2025

Thanks for the PR @amccarthy1. @juanri0s It seems that lodash.isequal has been officially deprecated: I'm wondering if there's any way we could get this PR merged in soon?

juanri0s
juanri0s previously approved these changes Feb 8, 2025
@juanri0s
Copy link
Contributor

juanri0s commented Feb 8, 2025

Thank you! Will merge on Monday

@amccarthy1 amccarthy1 force-pushed the remove-lodash-isequal branch from 35e6197 to 1621f79 Compare February 8, 2025 15:50
@c2fo-cibot c2fo-cibot bot added the size/XS Denotes a PR that changes 0-9 lines label Feb 8, 2025
@amccarthy1
Copy link
Contributor Author

Apologies for the delay -- I no longer really work in JS so I had to setup a new dev environment 😅 Rebased and resolved conflicts, this should hopefully be ready to merge now

@dustinsmith1024 dustinsmith1024 merged commit 2445b0e into C2FO:main Feb 10, 2025
4 checks passed
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13242705212

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 95.907%

Totals Coverage Status
Change from base Build 13227746193: 0.02%
Covered Lines: 753
Relevant Lines: 771

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 13217113594

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 95.907%

Totals Coverage Status
Change from base Build 13227746193: 0.02%
Covered Lines: 753
Relevant Lines: 771

💛 - Coveralls

@terrymun
Copy link

Thanks for looking into this so quickly, @juanri0s and @dustinsmith1024 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes 0-9 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants