aboutsummaryrefslogtreecommitdiff
path: root/node_modules/bl
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-04-20 03:09:25 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-04-24 16:14:29 +0200
commit82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch)
tree965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/bl
parente6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff)
downloadwallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.tar.xz
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules into one file (plus commons chunks) for every entry point. This results in a much smaller extension size (almost half). Furthermore we use yarn/npm even for extension run-time dependencies. This relieves us from manually vendoring and building dependencies. It's also easier to understand for new developers familiar with node.
Diffstat (limited to 'node_modules/bl')
-rw-r--r--node_modules/bl/.travis.yml4
-rw-r--r--node_modules/bl/LICENSE.md2
-rw-r--r--node_modules/bl/README.md10
-rw-r--r--node_modules/bl/bl.js55
-rw-r--r--node_modules/bl/package.json6
-rw-r--r--node_modules/bl/test/test.js59
6 files changed, 121 insertions, 15 deletions
diff --git a/node_modules/bl/.travis.yml b/node_modules/bl/.travis.yml
index 5cb0480b4..8c6fc4810 100644
--- a/node_modules/bl/.travis.yml
+++ b/node_modules/bl/.travis.yml
@@ -4,10 +4,12 @@ node_js:
- '0.10'
- '0.12'
- '4'
- - '5'
+ - '6'
+ - '7'
branches:
only:
- master
notifications:
email:
- rod@vagg.org
+ - matteo.collina@gmail.com
diff --git a/node_modules/bl/LICENSE.md b/node_modules/bl/LICENSE.md
index ccb24797c..ff35a3472 100644
--- a/node_modules/bl/LICENSE.md
+++ b/node_modules/bl/LICENSE.md
@@ -1,7 +1,7 @@
The MIT License (MIT)
=====================
-Copyright (c) 2014 bl contributors
+Copyright (c) 2013-2016 bl contributors
----------------------------------
*bl contributors listed at <https://github.com/rvagg/bl#contributors>*
diff --git a/node_modules/bl/README.md b/node_modules/bl/README.md
index f7044db26..da0c18338 100644
--- a/node_modules/bl/README.md
+++ b/node_modules/bl/README.md
@@ -87,6 +87,7 @@ bl.pipe(fs.createWriteStream('gibberish.txt'))
* <a href="#append"><code>bl.<b>append(buffer)</b></code></a>
* <a href="#get"><code>bl.<b>get(index)</b></code></a>
* <a href="#slice"><code>bl.<b>slice([ start[, end ] ])</b></code></a>
+ * <a href="#shallowSlice"><code>bl.<b>shallowSlice([ start[, end ] ])</b></code></a>
* <a href="#copy"><code>bl.<b>copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])</b></code></a>
* <a href="#duplicate"><code>bl.<b>duplicate()</b></code></a>
* <a href="#consume"><code>bl.<b>consume(bytes)</b></code></a>
@@ -136,6 +137,13 @@ Get the length of the list in bytes. This is the sum of the lengths of all of th
If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.
--------------------------------------------------------
+<a name="shallowSlice"></a>
+### bl.shallowSlice([ start, [ end ] ])
+`shallowSlice()` returns a new `BufferList` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
+
+No copies will be performed. All buffers in the result share memory with the original list.
+
+--------------------------------------------------------
<a name="copy"></a>
### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively.
@@ -195,6 +203,6 @@ See the <b><code>[Buffer](http://nodejs.org/docs/latest/api/buffer.html)</code><
<a name="license"></a>
## License &amp; copyright
-Copyright (c) 2013-2014 bl contributors (listed above).
+Copyright (c) 2013-2016 bl contributors (listed above).
bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
diff --git a/node_modules/bl/bl.js b/node_modules/bl/bl.js
index f585df172..701c1e564 100644
--- a/node_modules/bl/bl.js
+++ b/node_modules/bl/bl.js
@@ -38,9 +38,10 @@ util.inherits(BufferList, DuplexStream)
BufferList.prototype._offset = function _offset (offset) {
var tot = 0, i = 0, _t
+ if (offset === 0) return [ 0, 0 ]
for (; i < this._bufs.length; i++) {
_t = tot + this._bufs[i].length
- if (offset < _t)
+ if (offset < _t || i == this._bufs.length - 1)
return [ i, offset - tot ]
tot = _t
}
@@ -49,9 +50,10 @@ BufferList.prototype._offset = function _offset (offset) {
BufferList.prototype.append = function append (buf) {
var i = 0
- , newBuf
- if (Array.isArray(buf)) {
+ if (Buffer.isBuffer(buf)) {
+ this._appendBuffer(buf);
+ } else if (Array.isArray(buf)) {
for (; i < buf.length; i++)
this.append(buf[i])
} else if (buf instanceof BufferList) {
@@ -64,17 +66,21 @@ BufferList.prototype.append = function append (buf) {
if (typeof buf == 'number')
buf = buf.toString()
- newBuf = Buffer.isBuffer(buf) ? buf : new Buffer(buf)
- this._bufs.push(newBuf)
- this.length += newBuf.length
+ this._appendBuffer(new Buffer(buf));
}
return this
}
+BufferList.prototype._appendBuffer = function appendBuffer (buf) {
+ this._bufs.push(buf)
+ this.length += buf.length
+}
+
+
BufferList.prototype._write = function _write (buf, encoding, callback) {
- this.append(buf)
+ this._appendBuffer(buf)
if (typeof callback == 'function')
callback()
@@ -107,6 +113,10 @@ BufferList.prototype.get = function get (index) {
BufferList.prototype.slice = function slice (start, end) {
+ if (typeof start == 'number' && start < 0)
+ start += this.length
+ if (typeof end == 'number' && end < 0)
+ end += this.length
return this.copy(null, 0, start, end)
}
@@ -132,8 +142,11 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
// copy/slice everything
if (srcStart === 0 && srcEnd == this.length) {
- if (!copy) // slice, just return a full concat
- return Buffer.concat(this._bufs)
+ if (!copy) { // slice, but full concat if multiple buffers
+ return this._bufs.length === 1
+ ? this._bufs[0]
+ : Buffer.concat(this._bufs, this.length)
+ }
// copy, need to copy individual buffers
for (i = 0; i < this._bufs.length; i++) {
@@ -174,6 +187,30 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
return dst
}
+BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
+ start = start || 0
+ end = end || this.length
+
+ if (start < 0)
+ start += this.length
+ if (end < 0)
+ end += this.length
+
+ var startOffset = this._offset(start)
+ , endOffset = this._offset(end)
+ , buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
+
+ if (startOffset[1] != 0)
+ buffers[0] = buffers[0].slice(startOffset[1])
+
+ if (endOffset[1] == 0)
+ buffers.pop()
+ else
+ buffers[buffers.length-1] = buffers[buffers.length-1].slice(0, endOffset[1])
+
+ return new BufferList(buffers)
+}
+
BufferList.prototype.toString = function toString (encoding, start, end) {
return this.slice(start, end).toString(encoding)
}
diff --git a/node_modules/bl/package.json b/node_modules/bl/package.json
index aac62e364..3cb33acf1 100644
--- a/node_modules/bl/package.json
+++ b/node_modules/bl/package.json
@@ -1,6 +1,6 @@
{
"name": "bl",
- "version": "1.1.2",
+ "version": "1.2.0",
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
"main": "bl.js",
"scripts": {
@@ -24,11 +24,11 @@
],
"license": "MIT",
"dependencies": {
- "readable-stream": "~2.0.5"
+ "readable-stream": "^2.0.5"
},
"devDependencies": {
"faucet": "0.0.1",
"hash_file": "~0.1.1",
- "tape": "~4.4.0"
+ "tape": "~4.6.0"
}
}
diff --git a/node_modules/bl/test/test.js b/node_modules/bl/test/test.js
index c95b1ba48..989534c91 100644
--- a/node_modules/bl/test/test.js
+++ b/node_modules/bl/test/test.js
@@ -53,6 +53,20 @@ tape('multi bytes from single buffer', function (t) {
t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
+ t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
+
+ t.end()
+})
+
+tape('multi bytes from single buffer (negative indexes)', function (t) {
+ var bl = new BufferList()
+ bl.append(new Buffer('buffer'))
+
+ t.equal(bl.length, 6)
+
+ t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
+ t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
+ t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
t.end()
})
@@ -72,6 +86,7 @@ tape('multiple bytes from multiple buffers', function (t) {
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
+ t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
t.end()
})
@@ -537,6 +552,50 @@ tape('copy an interval between two buffers', function (t) {
t.end()
})
+tape('shallow slice across buffer boundaries', function (t) {
+ var bl = new BufferList(['First', 'Second', 'Third'])
+
+ t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
+ t.end()
+})
+
+tape('shallow slice within single buffer', function (t) {
+ var bl = new BufferList(['First', 'Second', 'Third'])
+
+ t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
+ t.end()
+})
+
+tape('shallow slice single buffer', function (t) {
+ t.plan(3)
+ var bl = new BufferList(['First', 'Second', 'Third'])
+
+ t.equal(bl.shallowSlice(0, 5).toString(), 'First')
+ t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
+ t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
+})
+
+tape('shallow slice with negative or omitted indices', function (t) {
+ t.plan(4)
+ var bl = new BufferList(['First', 'Second', 'Third'])
+
+ t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
+ t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
+ t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
+ t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
+})
+
+tape('shallow slice does not make a copy', function (t) {
+ t.plan(1)
+ var buffers = [new Buffer('First'), new Buffer('Second'), new Buffer('Third')]
+ var bl = (new BufferList(buffers)).shallowSlice(5, -3)
+
+ buffers[1].fill('h')
+ buffers[2].fill('h')
+
+ t.equal(bl.toString(), 'hhhhhhhh')
+})
+
tape('duplicate', function (t) {
t.plan(2)