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

Commit

Permalink
fix: reduce bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored and daviddias committed Jan 11, 2019
1 parent 80e3420 commit f95a406
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 51 deletions.
29 changes: 0 additions & 29 deletions appveyor.yml

This file was deleted.

11 changes: 7 additions & 4 deletions benchmarks/send.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict'

const Benchmark = require('benchmark')
const pull = require('pull-stream')
const pull = require('pull-stream/pull')
const infinite = require('pull-stream/sources/infinite')
const take = require('pull-stream/throughs/take')
const drain = require('pull-stream/sinks/drain')
const Connection = require('interface-connection').Connection
const parallel = require('async/parallel')
const pair = require('pull-pair/duplex')
Expand All @@ -16,16 +19,16 @@ function sendData (a, b, opts, finish) {
opts = Object.assign({ times: 1, size: 100 }, opts)

pull(
pull.infinite(() => Buffer.allocUnsafe(opts.size)),
pull.take(opts.times),
infinite(() => Buffer.allocUnsafe(opts.size)),
take(opts.times),
a
)

let length = 0

pull(
b,
pull.drain((data) => {
drain((data) => {
length += data.length
}, () => {
if (length !== opts.times * opts.size) {
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,24 @@
"license": "MIT",
"dependencies": {
"async": "^2.6.1",
"debug": "^4.1.1",
"interface-connection": "~0.3.3",
"libp2p-crypto": "~0.15.0",
"debug": "^4.1.0",
"interface-connection": "~0.3.2",
"libp2p-crypto": "libp2p/js-libp2p-crypto#feat/bundle-size",
"multihashing-async": "~0.5.1",
"peer-id": "~0.12.1",
"peer-info": "~0.15.0",
"peer-id": "libp2p/js-peer-id#feat/bundle-size",
"peer-info": "libp2p/js-peer-info#feat/bundle-size",
"protons": "^1.0.1",
"pull-defer": "~0.2.3",
"pull-handshake": "^1.1.4",
"pull-length-prefixed": "^1.3.1",
"pull-stream": "^3.6.9"
},
"devDependencies": {
"aegir": "^18.0.2",
"aegir": "github:ipfs/aegir#feat/make-exp-build-test-default",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"gulp": "^3.9.1",
"libp2p-websockets": "~0.12.0",
"libp2p-websockets": "libp2p/js-libp2p-websockets#fix/bundle-size",
"multistream-select": "~0.14.3",
"pull-goodbye": "~0.0.2",
"pull-pair": "^1.1.0"
Expand Down
10 changes: 6 additions & 4 deletions src/etm.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 map = require('pull-stream/throughs/map')
const asyncMap = require('pull-stream/throughs/async-map')
const lp = require('pull-length-prefixed')

const lpOpts = {
Expand All @@ -11,7 +13,7 @@ const lpOpts = {
exports.createBoxStream = (cipher, mac) => {
return pull(
ensureBuffer(),
pull.asyncMap((chunk, cb) => {
asyncMap((chunk, cb) => {
cipher.encrypt(chunk, (err, data) => {
if (err) {
return cb(err)
Expand All @@ -34,7 +36,7 @@ exports.createUnboxStream = (decipher, mac) => {
return pull(
ensureBuffer(),
lp.decode(lpOpts),
pull.asyncMap((chunk, cb) => {
asyncMap((chunk, cb) => {
const l = chunk.length
const macSize = mac.length

Expand Down Expand Up @@ -69,7 +71,7 @@ exports.createUnboxStream = (decipher, mac) => {
}

function ensureBuffer () {
return pull.map((c) => {
return map((c) => {
if (typeof c === 'string') {
return Buffer.from(c, 'utf-8')
}
Expand Down
5 changes: 3 additions & 2 deletions src/handshake/finish.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 pullError = require('pull-stream/sources/error')
const handshake = require('pull-handshake')
const debug = require('debug')

Expand Down Expand Up @@ -36,7 +37,7 @@ module.exports = function finish (state, callback) {
const fail = (err) => {
log.error(err)
state.secure.resolve({
source: pull.error(err),
source: pullError(err),
sink (read) {
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const pull = require('pull-stream')
const pull = require('pull-stream/pull')
const Connection = require('interface-connection').Connection
const assert = require('assert')
const PeerInfo = require('peer-info')
Expand Down
8 changes: 5 additions & 3 deletions src/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

const mh = require('multihashing-async')
const lp = require('pull-length-prefixed')
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 crypto = require('libp2p-crypto')
const parallel = require('async/parallel')

Expand Down Expand Up @@ -116,9 +118,9 @@ exports.digest = (buf, cb) => {
exports.write = function write (state, msg, cb) {
cb = cb || (() => {})
pull(
pull.values([msg]),
values([msg]),
lp.encode({ fixed: true, bytes: 4 }),
pull.collect((err, res) => {
collect((err, res) => {
if (err) {
return cb(err)
}
Expand Down

0 comments on commit f95a406

Please sign in to comment.