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

Commit

Permalink
fix: bundle size (#46)
Browse files Browse the repository at this point in the history
* fix: reduce bundle size

* fix: update deps

* fix: fix lint

* chore: update deps
  • Loading branch information
hugomrdias authored and jacobheun committed Jan 11, 2019
1 parent 973aaec commit e63d985
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 101 deletions.
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

29 changes: 0 additions & 29 deletions appveyor.yml

This file was deleted.

15 changes: 0 additions & 15 deletions circle.yml

This file was deleted.

12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@
"labs"
],
"engines": {
"node": ">=4.0.0",
"npm": ">=3.0.0"
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"license": "MIT",
"dependencies": {
"interface-connection": "~0.3.2",
"async": "^2.6.0",
"debug": "^3.1.0",
"lodash.isfunction": "^3.0.9",
"lodash.range": "^3.2.0",
"debug": "^4.1.0",
"once": "^1.4.0",
"pull-handshake": "^1.1.4",
"pull-length-prefixed": "^1.3.1",
Expand All @@ -55,11 +53,11 @@
"varint": "^5.0.0"
},
"devDependencies": {
"aegir": "^15.1.0",
"aegir": "^18.0.3",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"libp2p-multiplex": "~0.5.1",
"libp2p-spdy": "~0.12.1",
"libp2p-spdy": "~0.13.1",
"pull-pair": "^1.1.0",
"pump": "^3.0.0",
"run-parallel": "^1.1.9",
Expand Down
11 changes: 7 additions & 4 deletions src/dialer/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict'

const varint = require('varint')
const pull = require('pull-stream')
const pull = require('pull-stream/pull')
const map = require('pull-stream/throughs/map')
const collect = require('pull-stream/sinks/collect')
const take = require('pull-stream/throughs/take')
const pullLP = require('pull-length-prefixed')
const Connection = require('interface-connection').Connection
const util = require('../util')
Expand Down Expand Up @@ -113,8 +116,8 @@ class Dialer {
conn,
pullLP.decode(),
collectLs(conn),
pull.map(stringify),
pull.collect((err, list) => {
map(stringify),
collect((err, list) => {
if (err) {
return callback(err)
}
Expand All @@ -139,7 +142,7 @@ function collectLs (conn) {
let first = true
let counter = 0

return pull.take((msg) => {
return take((msg) => {
if (first) {
varint.decode(msg)
counter = varint.decode(msg, varint.decode.bytes)
Expand Down
5 changes: 2 additions & 3 deletions src/listener/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const pull = require('pull-stream')
const isFunction = require('lodash.isfunction')
const pull = require('pull-stream/pull')
const assert = require('assert')
const select = require('../select')
const selectHandler = require('./select-handler')
Expand Down Expand Up @@ -77,7 +76,7 @@ class Listener {
*/
addHandler (protocol, handlerFunc, matchFunc) {
this.log('adding handler: ' + protocol)
assert(isFunction(handlerFunc), 'handler must be a function')
assert(typeof handlerFunc === 'function', 'handler must be a function')

if (this.handlers[protocol]) {
this.log('overwriting handler for ' + protocol)
Expand Down
6 changes: 3 additions & 3 deletions src/listener/ls-handler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const pull = require('pull-stream')
const pull = require('pull-stream/pull')
const values = require('pull-stream/sources/values')
const pullLP = require('pull-length-prefixed')
const varint = require('varint')

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

pull(
pull.values(values),
values([buf].concat(encodedProtos)),
pullLP.encode(),
conn
)
Expand Down
10 changes: 5 additions & 5 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const pull = require('pull-stream')
const pull = require('pull-stream/pull')
const values = require('pull-stream/sources/values')
const collect = require('pull-stream/sinks/collect')
const pullLP = require('pull-length-prefixed')
const debug = require('debug')

Expand All @@ -13,12 +15,10 @@ function randomId () {
// prefixes a message with a varint
// TODO this is a pull-stream 'creep' (pull stream to add a byte?')
function encode (msg, callback) {
const values = Buffer.isBuffer(msg) ? [msg] : [Buffer.from(msg)]

pull(
pull.values(values),
values(Buffer.isBuffer(msg) ? [msg] : [Buffer.from(msg)]),
pullLP.encode(),
pull.collect((err, encoded) => {
collect((err, encoded) => {
if (err) {
return callback(err)
}
Expand Down
6 changes: 3 additions & 3 deletions test/handshake.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const util = require('./util')
const createPair = util.createPair

const options = [
{name: 'over pull-pair'},
{name: 'over spdy', muxer: spdy},
{name: 'over multiplex', muxer: multiplex}
{ name: 'over pull-pair' },
{ name: 'over spdy', muxer: spdy },
{ name: 'over multiplex', muxer: multiplex }
]

options.forEach((option) => {
Expand Down

0 comments on commit e63d985

Please sign in to comment.