Skip to content

Commit

Permalink
fix: dont rely in node globals
Browse files Browse the repository at this point in the history
This PR removes the dependency on node globals, so the users don't need to rely on browser bundlers magic.

related to ipfs/js-ipfs#2924
  • Loading branch information
hugomrdias committed Mar 16, 2020
1 parent 90a713b commit 24f829b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions BufferList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { Buffer } = require('buffer')
const symbol = Symbol.for('BufferList')

function BufferList (buf) {
Expand Down
4 changes: 2 additions & 2 deletions bl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const DuplexStream = require('readable-stream').Duplex
const util = require('util')
const inherits = require('inherits')
const BufferList = require('./BufferList')

function BufferListStream (callback) {
Expand Down Expand Up @@ -33,7 +33,7 @@ function BufferListStream (callback) {
DuplexStream.call(this)
}

util.inherits(BufferListStream, DuplexStream)
inherits(BufferListStream, DuplexStream)
Object.assign(BufferListStream.prototype, BufferList.prototype)

BufferListStream.prototype._new = function _new (callback) {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
],
"license": "MIT",
"dependencies": {
"buffer": "^5.5.0",
"inherits": "^2.0.4",
"readable-stream": "^3.4.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const tape = require('tape')
const { BufferList, BufferListStream } = require('../')
const { Buffer } = require('safe-buffer')
const { Buffer } = require('buffer')

tape('convert from BufferList to BufferListStream', (t) => {
const data = Buffer.from(`TEST-${Date.now()}`)
Expand Down
2 changes: 1 addition & 1 deletion test/indexOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const tape = require('tape')
const BufferList = require('../')
const Buffer = require('safe-buffer').Buffer
const { Buffer } = require('buffer')

tape('indexOf single byte needle', (t) => {
const bl = new BufferList(['abcdefg', 'abcdefg', '12345'])
Expand Down
2 changes: 1 addition & 1 deletion test/isBufferList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const tape = require('tape')
const { BufferList, BufferListStream } = require('../')
const { Buffer } = require('safe-buffer')
const { Buffer } = require('buffer')

tape('isBufferList positives', (t) => {
t.ok(BufferList.isBufferList(new BufferList()))
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const crypto = require('crypto')
const fs = require('fs')
const path = require('path')
const BufferList = require('../')
const Buffer = require('safe-buffer').Buffer
const { Buffer } = require('buffer')

const encodings =
('hex utf8 utf-8 ascii binary base64' +
Expand Down

0 comments on commit 24f829b

Please sign in to comment.