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

Commit

Permalink
perf: use lodash (#1414)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
alanshaw committed Jul 1, 2018
1 parent 6975fb3 commit 5637330
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"hat": "0.0.3",
"interface-ipfs-core": "~0.69.0",
"ipfsd-ctl": "~0.37.3",
"lodash": "^4.17.10",
"mocha": "^5.1.1",
"ncp": "^2.0.0",
"nexpect": "~0.5.0",
Expand Down Expand Up @@ -138,12 +137,7 @@
"libp2p-webrtc-star": "~0.15.0",
"libp2p-websocket-star": "~0.8.0",
"libp2p-websockets": "~0.12.0",
"lodash.flatmap": "^4.5.0",
"lodash.flattendeep": "^4.4.0",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"lodash.sortby": "^4.7.0",
"lodash.values": "^4.3.0",
"lodash": "^4.17.10",
"mafmt": "^6.0.0",
"mime-types": "^2.1.18",
"mkdirp": "~0.5.1",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const sortBy = require('lodash.sortby')
const sortBy = require('lodash/sortBy')
const pull = require('pull-stream')
const paramap = require('pull-paramap')
const zip = require('pull-zip')
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const promisify = require('promisify-es6')
const CID = require('cids')
const pull = require('pull-stream')
const mapAsync = require('async/map')
const flattenDeep = require('lodash.flattendeep')
const flattenDeep = require('lodash/flattenDeep')

module.exports = function dag (self) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// libp2p-nodejs gets replaced by libp2p-browser when webpacked/browserified
const Node = require('../runtime/libp2p-nodejs')
const promisify = require('promisify-es6')
const get = require('lodash.get')
const get = require('lodash/get')

module.exports = function libp2p (self) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const multiaddr = require('multiaddr')
const promisify = require('promisify-es6')
const values = require('lodash.values')
const values = require('lodash/values')

const OFFLINE_ERROR = require('../utils').OFFLINE_ERROR

Expand Down
4 changes: 2 additions & 2 deletions src/http/api/resources/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const debug = require('debug')
const get = require('lodash.get')
const set = require('lodash.set')
const get = require('lodash/get')
const set = require('lodash/set')
const log = debug('jsipfs:http-api:config')
log.error = debug('jsipfs:http-api:config:error')
const multipart = require('ipfs-multipart')
Expand Down

0 comments on commit 5637330

Please sign in to comment.