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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amccarthy1
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants