From 76e5d1d1918bbc2a320f4dac9a48be0973835ea9 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Fri, 11 Jan 2019 18:34:34 +0000 Subject: [PATCH] fix: reduce bundle size (#292) * fix: reduce bundle size * fix: use bignumber everywhere * chore: update deps --- package.json | 28 +++++++++++++--------------- src/limit-dialer/queue.js | 5 +++-- src/observe-connection.js | 2 +- src/observer.js | 4 ++-- src/stats/stat.js | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index aee591ff13..0cad6f1b3f 100644 --- a/package.json +++ b/package.json @@ -40,41 +40,39 @@ "npm": ">=3.0.0" }, "devDependencies": { - "aegir": "^17.1.1", + "aegir": "^18.0.3", "chai": "^4.2.0", "chai-checkmark": "^1.0.1", "dirty-chai": "^2.0.1", "libp2p-mplex": "~0.8.4", "libp2p-pnet": "~0.1.0", - "libp2p-secio": "~0.10.1", + "libp2p-secio": "~0.11.0", "libp2p-spdy": "~0.13.1", "libp2p-tcp": "~0.13.0", - "libp2p-webrtc-star": "~0.15.6", - "libp2p-websockets": "~0.12.0", - "peer-book": "~0.9.0", + "libp2p-webrtc-star": "~0.15.8", + "libp2p-websockets": "~0.12.1", + "peer-book": "~0.9.1", "portfinder": "^1.0.20", "sinon": "^7.2.0", "webrtcsupport": "^2.2.0" }, "dependencies": { "async": "^2.6.1", - "big.js": "^5.2.2", + "bignumber.js": "^8.0.1", "class-is": "^1.1.0", - "debug": "^4.1.0", + "debug": "^4.1.1", "err-code": "^1.1.2", "fsm-event": "^2.1.0", "hashlru": "^2.3.0", "interface-connection": "~0.3.3", - "ip-address": "^5.8.9", - "libp2p-circuit": "~0.3.1", - "libp2p-identify": "~0.7.2", - "lodash.includes": "^4.3.0", + "libp2p-circuit": "~0.3.4", + "libp2p-identify": "~0.7.5", "moving-average": "^1.0.0", - "multiaddr": "^6.0.0", - "multistream-select": "~0.14.3", + "multiaddr": "^6.0.3", + "multistream-select": "~0.14.4", "once": "^1.4.0", - "peer-id": "~0.12.0", - "peer-info": "~0.15.0", + "peer-id": "~0.12.2", + "peer-info": "~0.15.1", "pull-stream": "^3.6.9", "retimer": "^2.0.0" }, diff --git a/src/limit-dialer/queue.js b/src/limit-dialer/queue.js index d003cbd070..56672c0eaf 100644 --- a/src/limit-dialer/queue.js +++ b/src/limit-dialer/queue.js @@ -1,7 +1,8 @@ 'use strict' const Connection = require('interface-connection').Connection -const pull = require('pull-stream') +const pull = require('pull-stream/pull') +const empty = require('pull-stream/sources/empty') const timeout = require('async/timeout') const queue = require('async/queue') const debug = require('debug') @@ -50,7 +51,7 @@ class DialQueue { if (token.cancel) { log(`${transport.constructor.name}:work:cancel`) // clean up already done dials - pull(pull.empty(), conn) + pull(empty(), conn) // If we can close the connection, do it if (typeof conn.close === 'function') { return conn.close((_) => callback(null, { cancel: true })) diff --git a/src/observe-connection.js b/src/observe-connection.js index ead6a23b71..c6e928c04e 100644 --- a/src/observe-connection.js +++ b/src/observe-connection.js @@ -1,7 +1,7 @@ 'use strict' const Connection = require('interface-connection').Connection -const pull = require('pull-stream') +const pull = require('pull-stream/pull') /** * Creates a pull stream to run the given Connection stream through diff --git a/src/observer.js b/src/observer.js index e908757624..d117762869 100644 --- a/src/observer.js +++ b/src/observer.js @@ -1,6 +1,6 @@ 'use strict' -const pull = require('pull-stream') +const map = require('pull-stream/throughs/map') const EventEmitter = require('events') /** @@ -30,7 +30,7 @@ module.exports = (swtch) => { function observe (direction) { return (transport, protocol, peerInfo) => { - return pull.map((buffer) => { + return map((buffer) => { willObserve(peerInfo, transport, protocol, direction, buffer.length) return buffer }) diff --git a/src/stats/stat.js b/src/stats/stat.js index 16d8852c5c..85137441ee 100644 --- a/src/stats/stat.js +++ b/src/stats/stat.js @@ -1,7 +1,7 @@ 'use strict' const EventEmitter = require('events') -const Big = require('big.js').Big +const Big = require('bignumber.js') const MovingAverage = require('moving-average') const retimer = require('retimer')