Skip to content

fix: remove lodash functions to decrease bundle size #37

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

Merged
merged 4 commits into from
Dec 5, 2022

Conversation

gismya
Copy link
Contributor

@gismya gismya commented Nov 14, 2022

  • I have added automatic tests where applicable
  • The PR title is suitable as a release note
  • The PR contains a description of what has been changed
  • The description contains manual test instructions

Changes

In an effort to reduce package size lodash was replaced by native functions. Packages were also updated.

Test

Make sure everything works as before.

@gismya gismya requested a review from a team as a code owner November 14, 2022 09:29
decode(data, identityMap = {}) {
if (data == null) {
return data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened with this initial null check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it. The rest of the checks are not picking up null, and the "default" return is also data. That, combined with it being loose equality and thus probably subject to some kind of weird quirks that I didn't feel like googling, made me remove it.

Copy link
Contributor

@lucaas lucaas Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loose equality for null can be used for null or undefined:

> "null == null:	" true
> "undefined == null:	" true
> "0 == null:		" false
> "false == null:	" false

Since undefined is not valid JSON (which is what is being decoded), this will only be null. null fails the checks, and is returned as passed in as before. All good!

@gismya gismya requested a review from jimmycallin November 24, 2022 14:11
Copy link
Contributor

@jimmycallin jimmycallin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work!

@gismya gismya merged commit 589434c into main Dec 5, 2022
@gismya gismya deleted the decrease-bundle-size branch December 5, 2022 08:50
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.

3 participants