Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

perf: use lodash #1414

Merged
merged 1 commit into from
Jul 1, 2018
Merged

perf: use lodash #1414

merged 1 commit into from
Jul 1, 2018

Conversation

alanshaw
Copy link
Member

Other modules we depend on also depend on lodash.

screen shot 2018-06-29 at 10 19 53

We actually save around 100KB on bundle size if we use lodash like we use async (require functions we need from the main package) since the functions we require can be deduped because they're already being depended on.

Other modules we depend on also depend on lodash. We actually save around 100KB on bundle size if we use lodash like we use async (require functions we need from the main package) since the functions we require can be deduped because they're already being depended on.

License: MIT
Signed-off-by: Alan Shaw <[email protected]>
@ghost ghost assigned alanshaw Jun 29, 2018
@ghost ghost added the status/in-progress In progress label Jun 29, 2018
@vasco-santos
Copy link
Member

All in for this change! 🚀

@vasco-santos
Copy link
Member

I will change those for:

js-libp2p-connection-manager
js-libp2p-railing

@alanshaw
Copy link
Member Author

Other modules that IPFS are in charge of that are using individual lodash modules that would help our bundle size if they switched:

  • multiaddr
    • lodash.filter -> lodash/filter
    • lodash.map -> lodash/map
  • ipfs-bitswap
    • lodash.groupby -> lodash/groupBy
    • lodash.find -> lodash/find
    • lodash.sortBy -> lodash/sortBy
    • lodash.isequalwith -> lodash.isEqualWith
    • lodash.uniqwith -> lodash/uniqWith
    • lodash.values -> lodash/values
    • lodash.debounce -> lodash/debounce
    • lodash.pullallwith -> lodash/pullAllWith
  • peer-info
    • lodash.uniqby -> lodash/uniqBy
  • ipfs-repo
    • lodash.has -> lodash/has
    • lodash.set -> lodash/set
    • lodash.get -> lodash/get
  • ipld
    • lodash.includes => lodash/includes
  • libp2p-switch
    • lodash.includes => lodash/includes
  • libp2p-websockets
    • lodash.includes => lodash/includes
  • libp2p-tcp
    • lodash.includes => lodash/includes
  • libp2p-floodsub
    • lodash.values -> lodash/values

@hugomrdias
Copy link
Member

All maintainers should aim to keep these types of requires consistent.
There's also other types that should be normalised to keep node and browser happy, like setimmediate, buffer, stream and promisify/nodify are some i can remember from the top of my head.

@hugomrdias
Copy link
Member

also consider native methods if they can be used in the repo context. includes is a good example probably

@vasco-santos
Copy link
Member

Maybe we should create a endeavour listing everything. What do you think?

Meanwhile, I created a PR also for js-libp2p-floodsub

Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

Super interesting. Thought these would be the same.

@alanshaw alanshaw merged commit 5637330 into master Jul 1, 2018
@ghost ghost removed the status/in-progress In progress label Jul 1, 2018
@alanshaw alanshaw deleted the perf/use-lodash branch July 1, 2018 10:27
@hugomrdias hugomrdias mentioned this pull request Jul 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants