Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

Commit e63d985

Browse files
hugomrdiasjacobheun
authored andcommitted
fix: bundle size (#46)
* fix: reduce bundle size * fix: update deps * fix: fix lint * chore: update deps
1 parent 973aaec commit e63d985

File tree

9 files changed

+25
-101
lines changed

9 files changed

+25
-101
lines changed

.travis.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

circle.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,14 @@
3737
"labs"
3838
],
3939
"engines": {
40-
"node": ">=4.0.0",
41-
"npm": ">=3.0.0"
40+
"node": ">=10.0.0",
41+
"npm": ">=6.0.0"
4242
},
4343
"license": "MIT",
4444
"dependencies": {
4545
"interface-connection": "~0.3.2",
4646
"async": "^2.6.0",
47-
"debug": "^3.1.0",
48-
"lodash.isfunction": "^3.0.9",
49-
"lodash.range": "^3.2.0",
47+
"debug": "^4.1.0",
5048
"once": "^1.4.0",
5149
"pull-handshake": "^1.1.4",
5250
"pull-length-prefixed": "^1.3.1",
@@ -55,11 +53,11 @@
5553
"varint": "^5.0.0"
5654
},
5755
"devDependencies": {
58-
"aegir": "^15.1.0",
56+
"aegir": "^18.0.3",
5957
"chai": "^4.1.2",
6058
"dirty-chai": "^2.0.1",
6159
"libp2p-multiplex": "~0.5.1",
62-
"libp2p-spdy": "~0.12.1",
60+
"libp2p-spdy": "~0.13.1",
6361
"pull-pair": "^1.1.0",
6462
"pump": "^3.0.0",
6563
"run-parallel": "^1.1.9",

src/dialer/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
'use strict'
22

33
const varint = require('varint')
4-
const pull = require('pull-stream')
4+
const pull = require('pull-stream/pull')
5+
const map = require('pull-stream/throughs/map')
6+
const collect = require('pull-stream/sinks/collect')
7+
const take = require('pull-stream/throughs/take')
58
const pullLP = require('pull-length-prefixed')
69
const Connection = require('interface-connection').Connection
710
const util = require('../util')
@@ -113,8 +116,8 @@ class Dialer {
113116
conn,
114117
pullLP.decode(),
115118
collectLs(conn),
116-
pull.map(stringify),
117-
pull.collect((err, list) => {
119+
map(stringify),
120+
collect((err, list) => {
118121
if (err) {
119122
return callback(err)
120123
}
@@ -139,7 +142,7 @@ function collectLs (conn) {
139142
let first = true
140143
let counter = 0
141144

142-
return pull.take((msg) => {
145+
return take((msg) => {
143146
if (first) {
144147
varint.decode(msg)
145148
counter = varint.decode(msg, varint.decode.bytes)

src/listener/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22

3-
const pull = require('pull-stream')
4-
const isFunction = require('lodash.isfunction')
3+
const pull = require('pull-stream/pull')
54
const assert = require('assert')
65
const select = require('../select')
76
const selectHandler = require('./select-handler')
@@ -77,7 +76,7 @@ class Listener {
7776
*/
7877
addHandler (protocol, handlerFunc, matchFunc) {
7978
this.log('adding handler: ' + protocol)
80-
assert(isFunction(handlerFunc), 'handler must be a function')
79+
assert(typeof handlerFunc === 'function', 'handler must be a function')
8180

8281
if (this.handlers[protocol]) {
8382
this.log('overwriting handler for ' + protocol)

src/listener/ls-handler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

3-
const pull = require('pull-stream')
3+
const pull = require('pull-stream/pull')
4+
const values = require('pull-stream/sources/values')
45
const pullLP = require('pull-length-prefixed')
56
const varint = require('varint')
67

@@ -24,10 +25,9 @@ function lsHandler (self, conn) {
2425
const encodedProtos = protos.map((proto) => {
2526
return Buffer.from(proto + '\n')
2627
})
27-
const values = [buf].concat(encodedProtos)
2828

2929
pull(
30-
pull.values(values),
30+
values([buf].concat(encodedProtos)),
3131
pullLP.encode(),
3232
conn
3333
)

src/util.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict'
22

3-
const pull = require('pull-stream')
3+
const pull = require('pull-stream/pull')
4+
const values = require('pull-stream/sources/values')
5+
const collect = require('pull-stream/sinks/collect')
46
const pullLP = require('pull-length-prefixed')
57
const debug = require('debug')
68

@@ -13,12 +15,10 @@ function randomId () {
1315
// prefixes a message with a varint
1416
// TODO this is a pull-stream 'creep' (pull stream to add a byte?')
1517
function encode (msg, callback) {
16-
const values = Buffer.isBuffer(msg) ? [msg] : [Buffer.from(msg)]
17-
1818
pull(
19-
pull.values(values),
19+
values(Buffer.isBuffer(msg) ? [msg] : [Buffer.from(msg)]),
2020
pullLP.encode(),
21-
pull.collect((err, encoded) => {
21+
collect((err, encoded) => {
2222
if (err) {
2323
return callback(err)
2424
}

test/handshake.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const util = require('./util')
1717
const createPair = util.createPair
1818

1919
const options = [
20-
{name: 'over pull-pair'},
21-
{name: 'over spdy', muxer: spdy},
22-
{name: 'over multiplex', muxer: multiplex}
20+
{ name: 'over pull-pair' },
21+
{ name: 'over spdy', muxer: spdy },
22+
{ name: 'over multiplex', muxer: multiplex }
2323
]
2424

2525
options.forEach((option) => {

0 commit comments

Comments
 (0)