Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added safe-buffer and updated dependencies #51

Merged
merged 2 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ node_js:
- '4'
- '6'
- '7'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could remove this I reckon

- '8'
- '9'
branches:
only:
- master
Expand Down
9 changes: 5 additions & 4 deletions bl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var DuplexStream = require('readable-stream/duplex')
, util = require('util')
, Buffer = require('safe-buffer').Buffer


function BufferList (callback) {
Expand Down Expand Up @@ -66,7 +67,7 @@ BufferList.prototype.append = function append (buf) {
if (typeof buf == 'number')
buf = buf.toString()

this._appendBuffer(new Buffer(buf));
this._appendBuffer(Buffer.from(buf));
}

return this
Expand Down Expand Up @@ -127,9 +128,9 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
if (typeof srcEnd != 'number' || srcEnd > this.length)
srcEnd = this.length
if (srcStart >= this.length)
return dst || new Buffer(0)
return dst || Buffer.alloc(0)
if (srcEnd <= 0)
return dst || new Buffer(0)
return dst || Buffer.alloc(0)

var copy = !!dst
, off = this._offset(srcStart)
Expand Down Expand Up @@ -165,7 +166,7 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
}

if (!copy) // a slice, we need something to copy in to
dst = new Buffer(len)
dst = Buffer.allocUnsafe(len)

for (i = off[0]; i < this._bufs.length; i++) {
l = this._bufs[i].length - start
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
],
"license": "MIT",
"dependencies": {
"readable-stream": "^2.0.5"
"readable-stream": "^2.3.5",
"safe-buffer": "^5.1.1"
},
"devDependencies": {
"faucet": "0.0.1",
"hash_file": "~0.1.1",
"tape": "~4.6.0"
"tape": "~4.9.0"
}
}
Loading