Comparing version 1.2.1 to 1.2.2
var DuplexStream = require('readable-stream/duplex') | ||
, util = require('util') | ||
, Buffer = require('safe-buffer').Buffer | ||
@@ -69,3 +70,3 @@ | ||
this._appendBuffer(new Buffer(buf)); | ||
this._appendBuffer(Buffer.from(buf)); | ||
} | ||
@@ -131,5 +132,5 @@ | ||
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) | ||
@@ -170,3 +171,3 @@ var copy = !!dst | ||
if (!copy) // a slice, we need something to copy in to | ||
dst = new Buffer(len) | ||
dst = Buffer.allocUnsafe(len) | ||
@@ -173,0 +174,0 @@ for (i = off[0]; i < this._bufs.length; i++) { |
{ | ||
"name": "bl", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!", | ||
@@ -27,3 +27,4 @@ "main": "bl.js", | ||
"dependencies": { | ||
"readable-stream": "^2.0.5" | ||
"readable-stream": "^2.3.5", | ||
"safe-buffer": "^5.1.1" | ||
}, | ||
@@ -33,4 +34,4 @@ "devDependencies": { | ||
"hash_file": "~0.1.1", | ||
"tape": "~4.6.0" | ||
"tape": "~4.9.0" | ||
} | ||
} |
@@ -111,3 +111,3 @@ # bl *(BufferList)* | ||
// equivilant to: | ||
// equivalent to: | ||
@@ -114,0 +114,0 @@ var BufferList = require('bl') |
147
test/test.js
@@ -6,2 +6,3 @@ var tape = require('tape') | ||
, BufferList = require('../') | ||
, Buffer = require('safe-buffer').Buffer | ||
@@ -14,3 +15,3 @@ , encodings = | ||
var bl = new BufferList() | ||
bl.append(new Buffer('abcd')) | ||
bl.append(Buffer.from('abcd')) | ||
@@ -29,6 +30,6 @@ t.equal(bl.length, 4) | ||
var bl = new BufferList() | ||
bl.append(new Buffer('abcd')) | ||
bl.append(new Buffer('efg')) | ||
bl.append(new Buffer('hi')) | ||
bl.append(new Buffer('j')) | ||
bl.append(Buffer.from('abcd')) | ||
bl.append(Buffer.from('efg')) | ||
bl.append(Buffer.from('hi')) | ||
bl.append(Buffer.from('j')) | ||
@@ -52,3 +53,3 @@ t.equal(bl.length, 10) | ||
var bl = new BufferList() | ||
bl.append(new Buffer('abcd')) | ||
bl.append(Buffer.from('abcd')) | ||
@@ -67,3 +68,3 @@ t.equal(bl.length, 4) | ||
var bl = new BufferList() | ||
bl.append(new Buffer('buffer')) | ||
bl.append(Buffer.from('buffer')) | ||
@@ -82,6 +83,6 @@ t.equal(bl.length, 6) | ||
bl.append(new Buffer('abcd')) | ||
bl.append(new Buffer('efg')) | ||
bl.append(new Buffer('hi')) | ||
bl.append(new Buffer('j')) | ||
bl.append(Buffer.from('abcd')) | ||
bl.append(Buffer.from('efg')) | ||
bl.append(Buffer.from('hi')) | ||
bl.append(Buffer.from('j')) | ||
@@ -103,4 +104,4 @@ t.equal(bl.length, 10) | ||
bl.append(new BufferList([ new Buffer('abcd'), new Buffer('efg') ])) | ||
bl.append(new BufferList([ new Buffer('hi'), new Buffer('j') ])) | ||
bl.append(new BufferList([ Buffer.from('abcd'), Buffer.from('efg') ])) | ||
bl.append(new BufferList([ Buffer.from('hi'), Buffer.from('j') ])) | ||
@@ -125,8 +126,8 @@ t.equal(bl.length, 10) | ||
new BufferList([ | ||
new BufferList(new Buffer('abc')) | ||
, new Buffer('d') | ||
, new BufferList(new Buffer('efg')) | ||
new BufferList(Buffer.from('abc')) | ||
, Buffer.from('d') | ||
, new BufferList(Buffer.from('efg')) | ||
]) | ||
, new BufferList([ new Buffer('hi') ]) | ||
, new BufferList(new Buffer('j')) | ||
, new BufferList([ Buffer.from('hi') ]) | ||
, new BufferList(Buffer.from('j')) | ||
])) | ||
@@ -148,6 +149,6 @@ | ||
var bl = new BufferList() | ||
bl.append(new Buffer('abc')) | ||
bl.append([ new Buffer('def') ]) | ||
bl.append([ new Buffer('ghi'), new Buffer('jkl') ]) | ||
bl.append([ new Buffer('mnop'), new Buffer('qrstu'), new Buffer('vwxyz') ]) | ||
bl.append(Buffer.from('abc')) | ||
bl.append([ Buffer.from('def') ]) | ||
bl.append([ Buffer.from('ghi'), Buffer.from('jkl') ]) | ||
bl.append([ Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz') ]) | ||
t.equal(bl.length, 26) | ||
@@ -160,6 +161,6 @@ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz') | ||
var bl = new BufferList() | ||
bl.append(new Buffer('abc')) | ||
bl.append(Buffer.from('abc')) | ||
bl.append([ new BufferList('def') ]) | ||
bl.append(new BufferList([ new Buffer('ghi'), new BufferList('jkl') ])) | ||
bl.append([ new Buffer('mnop'), new BufferList([ new Buffer('qrstu'), new Buffer('vwxyz') ]) ]) | ||
bl.append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ])) | ||
bl.append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ]) | ||
t.equal(bl.length, 26) | ||
@@ -172,6 +173,6 @@ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz') | ||
var bl = new BufferList() | ||
t.ok(bl.append(new Buffer('abcd')) === bl) | ||
t.ok(bl.append([ new Buffer('abcd') ]) === bl) | ||
t.ok(bl.append(new BufferList(new Buffer('abcd'))) === bl) | ||
t.ok(bl.append([ new BufferList(new Buffer('abcd')) ]) === bl) | ||
t.ok(bl.append(Buffer.from('abcd')) === bl) | ||
t.ok(bl.append([ Buffer.from('abcd') ]) === bl) | ||
t.ok(bl.append(new BufferList(Buffer.from('abcd'))) === bl) | ||
t.ok(bl.append([ new BufferList(Buffer.from('abcd')) ]) === bl) | ||
t.end() | ||
@@ -183,4 +184,4 @@ }) | ||
.append([ new BufferList('def') ]) | ||
.append(new BufferList([ new Buffer('ghi'), new BufferList('jkl') ])) | ||
.append([ new Buffer('mnop'), new BufferList([ new Buffer('qrstu'), new Buffer('vwxyz') ]) ]) | ||
.append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ])) | ||
.append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ]) | ||
@@ -195,6 +196,6 @@ t.equal(bl.length, 26) | ||
bl.append(new Buffer('abcd')) | ||
bl.append(new Buffer('efg')) | ||
bl.append(new Buffer('hi')) | ||
bl.append(new Buffer('j')) | ||
bl.append(Buffer.from('abcd')) | ||
bl.append(Buffer.from('efg')) | ||
bl.append(Buffer.from('hi')) | ||
bl.append(Buffer.from('j')) | ||
@@ -231,4 +232,4 @@ t.equal(bl.length, 10) | ||
bl.append(new Buffer('a')) | ||
bl.append(new Buffer('b')) | ||
bl.append(Buffer.from('a')) | ||
bl.append(Buffer.from('b')) | ||
@@ -244,5 +245,5 @@ bl.consume(2) | ||
tape('test readUInt8 / readInt8', function (t) { | ||
var buf1 = new Buffer(1) | ||
, buf2 = new Buffer(3) | ||
, buf3 = new Buffer(3) | ||
var buf1 = Buffer.alloc(1) | ||
, buf2 = Buffer.alloc(3) | ||
, buf3 = Buffer.alloc(3) | ||
, bl = new BufferList() | ||
@@ -271,5 +272,5 @@ | ||
tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) { | ||
var buf1 = new Buffer(1) | ||
, buf2 = new Buffer(3) | ||
, buf3 = new Buffer(3) | ||
var buf1 = Buffer.alloc(1) | ||
, buf2 = Buffer.alloc(3) | ||
, buf3 = Buffer.alloc(3) | ||
, bl = new BufferList() | ||
@@ -302,5 +303,5 @@ | ||
tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) { | ||
var buf1 = new Buffer(1) | ||
, buf2 = new Buffer(3) | ||
, buf3 = new Buffer(3) | ||
var buf1 = Buffer.alloc(1) | ||
, buf2 = Buffer.alloc(3) | ||
, buf3 = Buffer.alloc(3) | ||
, bl = new BufferList() | ||
@@ -325,5 +326,5 @@ | ||
tape('test readFloatLE / readFloatBE', function (t) { | ||
var buf1 = new Buffer(1) | ||
, buf2 = new Buffer(3) | ||
, buf3 = new Buffer(3) | ||
var buf1 = Buffer.alloc(1) | ||
, buf2 = Buffer.alloc(3) | ||
, buf3 = Buffer.alloc(3) | ||
, bl = new BufferList() | ||
@@ -345,5 +346,5 @@ | ||
tape('test readDoubleLE / readDoubleBE', function (t) { | ||
var buf1 = new Buffer(1) | ||
, buf2 = new Buffer(3) | ||
, buf3 = new Buffer(10) | ||
var buf1 = Buffer.alloc(1) | ||
, buf2 = Buffer.alloc(3) | ||
, buf3 = Buffer.alloc(10) | ||
, bl = new BufferList() | ||
@@ -371,6 +372,6 @@ | ||
bl.append(new Buffer('abcd')) | ||
bl.append(new Buffer('efg')) | ||
bl.append(new Buffer('hi')) | ||
bl.append(new Buffer('j')) | ||
bl.append(Buffer.from('abcd')) | ||
bl.append(Buffer.from('efg')) | ||
bl.append(Buffer.from('hi')) | ||
bl.append(Buffer.from('j')) | ||
@@ -388,9 +389,9 @@ t.equal(bl.toString('ascii', 0, 10), 'abcdefghij') | ||
var bl = new BufferList() | ||
, b = new Buffer('abcdefghij\xff\x00') | ||
, b = Buffer.from('abcdefghij\xff\x00') | ||
bl.append(new Buffer('abcd')) | ||
bl.append(new Buffer('efg')) | ||
bl.append(new Buffer('hi')) | ||
bl.append(new Buffer('j')) | ||
bl.append(new Buffer('\xff\x00')) | ||
bl.append(Buffer.from('abcd')) | ||
bl.append(Buffer.from('efg')) | ||
bl.append(Buffer.from('hi')) | ||
bl.append(Buffer.from('j')) | ||
bl.append(Buffer.from('\xff\x00')) | ||
@@ -443,3 +444,3 @@ encodings.forEach(function (enc) { | ||
var bl = new BufferList() | ||
, b = new Buffer('abcdefghij\xff\x00') | ||
, b = Buffer.from('abcdefghij\xff\x00') | ||
@@ -461,3 +462,3 @@ bl.append('abcd') | ||
var bl = new BufferList() | ||
, b = new Buffer('1234567890') | ||
, b = Buffer.from('1234567890') | ||
@@ -496,3 +497,3 @@ bl.append(1234) | ||
t.equal(exp, bl.toString()) | ||
t.equal(new Buffer(exp).toString('hex'), bl.toString('hex')) | ||
t.equal(Buffer.from(exp).toString('hex'), bl.toString('hex')) | ||
}) | ||
@@ -515,3 +516,3 @@ | ||
var buf = crypto.randomBytes(1024) | ||
, buf2 = new Buffer(1024) | ||
, buf2 = Buffer.alloc(1024) | ||
, b = BufferList(buf) | ||
@@ -526,3 +527,3 @@ | ||
var buf = crypto.randomBytes(512) | ||
, buf2 = new Buffer(1024) | ||
, buf2 = Buffer.alloc(1024) | ||
, b = BufferList(buf) | ||
@@ -538,3 +539,3 @@ | ||
var buf = crypto.randomBytes(1004) | ||
, buf2 = new Buffer(1024) | ||
, buf2 = Buffer.alloc(1024) | ||
, b = BufferList(buf) | ||
@@ -549,3 +550,3 @@ | ||
var buf = crypto.randomBytes(10) | ||
, buf2 = new Buffer(5) | ||
, buf2 = Buffer.alloc(5) | ||
, b = BufferList(buf) | ||
@@ -561,4 +562,4 @@ | ||
, b = BufferList(rnd) // put the random bytes there | ||
, actual = new Buffer(3) | ||
, expected = new Buffer(3) | ||
, actual = Buffer.alloc(3) | ||
, expected = Buffer.alloc(3) | ||
@@ -574,3 +575,3 @@ rnd.copy(expected, 0, 5, 8) | ||
var buf = crypto.randomBytes(10) | ||
, buf2 = new Buffer(10) | ||
, buf2 = Buffer.alloc(10) | ||
, b = BufferList(buf) | ||
@@ -622,3 +623,3 @@ | ||
t.plan(1) | ||
var buffers = [new Buffer('First'), new Buffer('Second'), new Buffer('Third')] | ||
var buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')] | ||
var bl = (new BufferList(buffers)).shallowSlice(5, -3) | ||
@@ -625,0 +626,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38223
767
2
7
+ Addedsafe-buffer@^5.1.1
+ Addedsafe-buffer@5.2.1(transitive)
Updatedreadable-stream@^2.3.5