Skip to content

Commit

Permalink
Added safe-buffer and updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Mar 20, 2018
1 parent 4acbe24 commit 4b8f524
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -6,6 +6,8 @@ node_js:
- '4'
- '6'
- '7'
- '8'
- '9'
branches:
only:
- master
Expand Down
9 changes: 5 additions & 4 deletions bl.js
@@ -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
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"
}
}

0 comments on commit 4b8f524

Please sign in to comment.