diff options
author | Rebecca Turner <me@re-becca.org> | 2018-03-23 03:27:22 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2018-03-23 12:08:57 +0300 |
commit | a85372e671eab46e62caa46631baa30900e32114 (patch) | |
tree | b5400435b38080699e04f2997c02a4a852805ac4 /node_modules/tar | |
parent | dc6df1bc4677164b9ba638e87c1185b857744720 (diff) |
tar@4.4.1
Switch to safe-buffer and Buffer.from
Credit: @isaacs
Credit: @ChALkeR
Diffstat (limited to 'node_modules/tar')
28 files changed, 69 insertions, 829 deletions
diff --git a/node_modules/tar/lib/buffer.js b/node_modules/tar/lib/buffer.js new file mode 100644 index 000000000..7876d5b3e --- /dev/null +++ b/node_modules/tar/lib/buffer.js @@ -0,0 +1,11 @@ +'use strict' + +// Buffer in node 4.x < 4.5.0 doesn't have working Buffer.from +// or Buffer.alloc, and Buffer in node 10 deprecated the ctor. +// .M, this is fine .\^/M.. +let B = Buffer +/* istanbul ignore next */ +if (!B.alloc) { + B = require('safe-buffer').Buffer +} +module.exports = B diff --git a/node_modules/tar/lib/header.js b/node_modules/tar/lib/header.js index 4de35fa8d..31cde8b5c 100644 --- a/node_modules/tar/lib/header.js +++ b/node_modules/tar/lib/header.js @@ -4,6 +4,7 @@ // the data could not be faithfully encoded in a simple header. // (Also, check header.needPax to see if it needs a pax header.) +const Buffer = require('./buffer.js') const types = require('./types.js') const pathModule = require('path') const large = require('./large-numbers.js') diff --git a/node_modules/tar/lib/list.js b/node_modules/tar/lib/list.js index 9da3f812c..250ebe001 100644 --- a/node_modules/tar/lib/list.js +++ b/node_modules/tar/lib/list.js @@ -1,5 +1,7 @@ 'use strict' +const Buffer = require('./buffer.js') + // XXX: This shares a lot in common with extract.js // maybe some DRY opportunity here? diff --git a/node_modules/tar/lib/pack.js b/node_modules/tar/lib/pack.js index 8df366e11..180e332e9 100644 --- a/node_modules/tar/lib/pack.js +++ b/node_modules/tar/lib/pack.js @@ -1,5 +1,7 @@ 'use strict' +const Buffer = require('./buffer.js') + // A readable tar stream creator // Technically, this is a transform stream that you write paths into, // and tar format comes out of. diff --git a/node_modules/tar/lib/parse.js b/node_modules/tar/lib/parse.js index 090b2d2c0..2a73b2bb7 100644 --- a/node_modules/tar/lib/parse.js +++ b/node_modules/tar/lib/parse.js @@ -30,7 +30,7 @@ const Entry = require('./read-entry.js') const Pax = require('./pax.js') const zlib = require('minizlib') -const gzipHeader = new Buffer([0x1f, 0x8b]) +const gzipHeader = Buffer.from([0x1f, 0x8b]) const STATE = Symbol('state') const WRITEENTRY = Symbol('writeEntry') const READENTRY = Symbol('readEntry') diff --git a/node_modules/tar/lib/pax.js b/node_modules/tar/lib/pax.js index 214a459f3..9d7e4aba5 100644 --- a/node_modules/tar/lib/pax.js +++ b/node_modules/tar/lib/pax.js @@ -1,4 +1,5 @@ 'use strict' +const Buffer = require('./buffer.js') const Header = require('./header.js') const path = require('path') diff --git a/node_modules/tar/lib/replace.js b/node_modules/tar/lib/replace.js index 44126d1f8..571cee94a 100644 --- a/node_modules/tar/lib/replace.js +++ b/node_modules/tar/lib/replace.js @@ -1,4 +1,5 @@ 'use strict' +const Buffer = require('./buffer.js') // tar -r const hlo = require('./high-level-opt.js') diff --git a/node_modules/tar/lib/write-entry.js b/node_modules/tar/lib/write-entry.js index 4eddb8b7c..7b43ebcd3 100644 --- a/node_modules/tar/lib/write-entry.js +++ b/node_modules/tar/lib/write-entry.js @@ -1,4 +1,5 @@ 'use strict' +const Buffer = require('./buffer.js') const MiniPass = require('minipass') const Pax = require('./pax.js') const Header = require('./header.js') diff --git a/node_modules/tar/node_modules/minipass/.npmignore b/node_modules/tar/node_modules/minipass/.npmignore deleted file mode 100644 index 183822a7f..000000000 --- a/node_modules/tar/node_modules/minipass/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.*.swp -node_modules -.nyc_output/ -coverage/ diff --git a/node_modules/tar/node_modules/minipass/.travis.yml b/node_modules/tar/node_modules/minipass/.travis.yml deleted file mode 100644 index 59410a36d..000000000 --- a/node_modules/tar/node_modules/minipass/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -sudo: false -node_js: - - 7 -cache: - directories: - - /Users/isaacs/.npm diff --git a/node_modules/tar/node_modules/minipass/b.js b/node_modules/tar/node_modules/minipass/b.js deleted file mode 100644 index 324c4190a..000000000 --- a/node_modules/tar/node_modules/minipass/b.js +++ /dev/null @@ -1,12 +0,0 @@ -const MiniPass = require('./') -const butterfly = '🦋' -var mp = new MiniPass({ encoding: 'utf8' }) -mp.on('data', chunk => { - console.error('data %s', chunk) -}) -var butterbuf = new Buffer([0xf0, 0x9f, 0xa6, 0x8b]) -mp.write(butterbuf.slice(0, 1)) -mp.write(butterbuf.slice(1, 2)) -mp.write(butterbuf.slice(2, 3)) -mp.write(butterbuf.slice(3, 4)) -mp.end() diff --git a/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js b/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js deleted file mode 100644 index 8e7841a87..000000000 --- a/node_modules/tar/node_modules/minipass/bench/lib/extend-minipass.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -const MiniPass = require('../..') - -module.exports = class ExtendMiniPass extends MiniPass { - constructor (opts) { - super(opts) - } - write (data, encoding) { - return super.write(data, encoding) - } -} diff --git a/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js b/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js deleted file mode 100644 index 6a021084c..000000000 --- a/node_modules/tar/node_modules/minipass/bench/lib/extend-through2.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' -const through2 = require('through2') -module.exports = function (opt) { - return opt.objectMode - ? through2.obj(func) - : through2(func) - - function func (data, enc, done) { - this.push(data, enc) - done() - } -} diff --git a/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js b/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js deleted file mode 100644 index 1d2d24026..000000000 --- a/node_modules/tar/node_modules/minipass/bench/lib/extend-transform.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -const stream = require('stream') -module.exports = class ExtendTransform extends stream.Transform { - constructor (opts) { - super(opts) - } - _transform (data, enc, done) { - this.push(data, enc) - done() - } -} diff --git a/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js b/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js deleted file mode 100644 index 13f6e916b..000000000 --- a/node_modules/tar/node_modules/minipass/bench/lib/nullsink.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' -const EE = require('events').EventEmitter - -module.exports = class NullSink extends EE { - write (data, encoding, next) { - if (next) next() - return true - } - end () { - this.emit('finish') - } -} diff --git a/node_modules/tar/node_modules/minipass/bench/lib/numbers.js b/node_modules/tar/node_modules/minipass/bench/lib/numbers.js deleted file mode 100644 index bd1593299..000000000 --- a/node_modules/tar/node_modules/minipass/bench/lib/numbers.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict' -const stream = require('stream') - -const numbers = new Array(1000).join(',').split(',').map((v, k) => k) -let acc = '' -const strings = numbers.map(n => acc += n) -const bufs = strings.map(s => new Buffer(s)) -const objs = strings.map(s => ({ str: s })) - -module.exports = class Numbers { - constructor (opt) { - this.objectMode = opt.objectMode - this.encoding = opt.encoding - this.ii = 0 - this.done = false - } - pipe (dest) { - this.dest = dest - this.go() - return dest - } - - go () { - let flowing = true - while (flowing) { - if (this.ii >= 1000) { - this.dest.end() - this.done = true - flowing = false - } else { - flowing = this.dest.write( - (this.objectMode ? objs - : this.encoding ? strings - : bufs)[this.ii++]) - } - } - - if (!this.done) - this.dest.once('drain', _ => this.go()) - } -} diff --git a/node_modules/tar/node_modules/minipass/bench/lib/timer.js b/node_modules/tar/node_modules/minipass/bench/lib/timer.js deleted file mode 100644 index 8d8fe3d80..000000000 --- a/node_modules/tar/node_modules/minipass/bench/lib/timer.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict' -module.exports = _ => { - const start = process.hrtime() - return _ => { - const end = process.hrtime(start) - const ms = Math.round(end[0]*1e6 + end[1]/1e3)/1e3 - if (!process.env.isTTY) - console.log(ms) - else { - const s = Math.round(end[0]*10 + end[1]/1e8)/10 - const ss = s <= 1 ? '' : ' (' + s + 's)' - console.log('%d%s', ms, ss) - } - } -} diff --git a/node_modules/tar/node_modules/minipass/bench/test.js b/node_modules/tar/node_modules/minipass/bench/test.js deleted file mode 100644 index 29c9fd07d..000000000 --- a/node_modules/tar/node_modules/minipass/bench/test.js +++ /dev/null @@ -1,160 +0,0 @@ -'use strict' - -const iterations = +process.env.BENCH_TEST_ITERATION || 100 -const testCount = +process.env.BENCH_TEST_COUNT || 20 - -const tests = [ - 'baseline', - 'minipass', - 'extend-minipass', - 'through2', - 'extend-through2', - 'passthrough', - 'extend-transform' -] - -const manyOpts = [ 'many', 'single' ] -const typeOpts = [ 'buffer', 'string', 'object' ] - -const main = () => { - const spawn = require('child_process').spawn - const node = process.execPath - - const results = {} - - const testSet = [] - tests.forEach(t => - manyOpts.forEach(many => - typeOpts.forEach(type => - new Array(testCount).join(',').split(',').forEach(() => - t !== 'baseline' || (many === 'single' && type === 'object') - ? testSet.push([t, many, type]) : null)))) - - let didFirst = false - const mainRunTest = t => { - if (!t) - return afterMain(results) - - const k = t.join('\t') - if (!results[k]) { - results[k] = [] - if (!didFirst) - didFirst = true - else - process.stderr.write('\n') - - process.stderr.write(k + ' #') - } else { - process.stderr.write('#') - } - - const c = spawn(node, [__filename].concat(t), { - stdio: [ 'ignore', 'pipe', 2 ] - }) - let out = '' - c.stdout.on('data', c => out += c) - c.on('close', (code, signal) => { - if (code || signal) - throw new Error('failed: ' + code + ' ' + signal) - results[k].push(+out) - mainRunTest(testSet.shift()) - }) - } - - mainRunTest(testSet.shift()) -} - -const afterMain = results => { - console.log('test\tmany\ttype\tops/s\tmean\tmedian\tmax\tmin' + - '\tstdev\trange\traw') - // get the mean, median, stddev, and range of each test - Object.keys(results).forEach(test => { - const k = results[test].sort((a, b) => a - b) - const min = k[0] - const max = k[ k.length - 1 ] - const range = max - min - const sum = k.reduce((a,b) => a + b, 0) - const mean = sum / k.length - const ops = iterations / mean * 1000 - const devs = k.map(n => n - mean).map(n => n * n) - const avgdev = devs.reduce((a,b) => a + b, 0) / k.length - const stdev = Math.pow(avgdev, 0.5) - const median = k.length % 2 ? k[Math.floor(k.length / 2)] : - (k[k.length/2] + k[k.length/2+1])/2 - console.log( - '%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%s', test, round(ops), - round(mean), round(median), - max, min, round(stdev), round(range), - k.join('\t')) - }) -} - -const round = num => Math.round(num * 1000)/1000 - -const test = (testname, many, type) => { - const timer = require('./lib/timer.js') - const Class = getClass(testname) - - const done = timer() - runTest(Class, many, type, iterations, done) -} - -// don't blow up the stack! loop unless deferred -const runTest = (Class, many, type, iterations, done) => { - const Nullsink = require('./lib/nullsink.js') - const Numbers = require('./lib/numbers.js') - const opt = {} - if (type === 'string') - opt.encoding = 'utf8' - else if (type === 'object') - opt.objectMode = true - - while (iterations--) { - let finished = false - let inloop = true - const after = iterations === 0 ? done - : () => { - if (iterations === 0) - done() - else if (inloop) - finished = true - else - runTest(Class, many, type, iterations, done) - } - - const out = new Nullsink().on('finish', after) - let sink = Class ? new Class(opt) : out - - if (many && Class) - sink = sink - .pipe(new Class(opt)) - .pipe(new Class(opt)) - .pipe(new Class(opt)) - .pipe(new Class(opt)) - - if (sink !== out) - sink.pipe(out) - - new Numbers(opt).pipe(sink) - - // keep tight-looping if the stream is done already - if (!finished) { - inloop = false - break - } - } -} - -const getClass = testname => - testname === 'through2' ? require('through2').obj - : testname === 'extend-through2' ? require('./lib/extend-through2.js') - : testname === 'minipass' ? require('../') - : testname === 'extend-minipass' ? require('./lib/extend-minipass.js') - : testname === 'passthrough' ? require('stream').PassThrough - : testname === 'extend-transform' ? require('./lib/extend-transform.js') - : null - -if (!process.argv[2]) - main() -else - test(process.argv[2], process.argv[3] === 'many', process.argv[4]) diff --git a/node_modules/tar/node_modules/minipass/d.js b/node_modules/tar/node_modules/minipass/d.js deleted file mode 100644 index ceea51396..000000000 --- a/node_modules/tar/node_modules/minipass/d.js +++ /dev/null @@ -1,7 +0,0 @@ -var MD = require('./') -var d = new MD() -console.log(d.write('hello')) -console.log(d.write('goodbye')) -d.pipe(process.stderr) -console.log(d.write('the end')) -console.log(d.end()) diff --git a/node_modules/tar/node_modules/minipass/e.js b/node_modules/tar/node_modules/minipass/e.js deleted file mode 100644 index f1da6c746..000000000 --- a/node_modules/tar/node_modules/minipass/e.js +++ /dev/null @@ -1,17 +0,0 @@ -const MP = require('stream').PassThrough // require('./') -const mp = new MP() -const wait = (n) => new Promise(resolve => setTimeout(resolve, n)) -const t = require('tap') - -t.test('end ordering', async t => { - mp.on('end', _ => console.log('end')) - mp.end() - console.log('called end') - // mp.resume() - // console.log('called resume()') - // mp.read() - // console.log('called read') - mp.on('data', _=>_) - console.log('added data handler') - await wait(1) -}) diff --git a/node_modules/tar/node_modules/minipass/eos.js b/node_modules/tar/node_modules/minipass/eos.js deleted file mode 100644 index 225072094..000000000 --- a/node_modules/tar/node_modules/minipass/eos.js +++ /dev/null @@ -1,12 +0,0 @@ -const EE = require('events').EventEmitter -const eos = require('end-of-stream') -const ee = new EE() -ee.readable = ee.writable = true -eos(ee, er => { - if (er) - throw er - console.log('stream ended') -}) -ee.emit('finish') -ee.emit('close') -ee.emit('end') diff --git a/node_modules/tar/node_modules/minipass/foo b/node_modules/tar/node_modules/minipass/foo deleted file mode 100644 index e69de29bb..000000000 --- a/node_modules/tar/node_modules/minipass/foo +++ /dev/null diff --git a/node_modules/tar/node_modules/minipass/index.js b/node_modules/tar/node_modules/minipass/index.js index 3a3ad412b..89bc787ac 100644 --- a/node_modules/tar/node_modules/minipass/index.js +++ b/node_modules/tar/node_modules/minipass/index.js @@ -18,6 +18,15 @@ const BUFFERPUSH = Symbol('bufferPush') const BUFFERSHIFT = Symbol('bufferShift') const OBJECTMODE = Symbol('objectMode') +// Buffer in node 4.x < 4.5.0 doesn't have working Buffer.from +// or Buffer.alloc, and Buffer in node 10 deprecated the ctor. +// .M, this is fine .\^/M.. +let B = Buffer +/* istanbul ignore next */ +if (!B.alloc) { + B = require('safe-buffer').Buffer +} + class MiniPass extends EE { constructor (options) { super() @@ -79,10 +88,10 @@ class MiniPass extends EE { if (typeof chunk === 'string' && !this[OBJECTMODE] && // unless it is a string already ready for us to use !(encoding === this[ENCODING] && !this[DECODER].lastNeed)) { - chunk = new Buffer(chunk, encoding) + chunk = B.from(chunk, encoding) } - if (Buffer.isBuffer(chunk) && this[ENCODING]) + if (B.isBuffer(chunk) && this[ENCODING]) chunk = this[DECODER].write(chunk) try { @@ -111,7 +120,7 @@ class MiniPass extends EE { ]) else this.buffer = new Yallist([ - Buffer.concat(Array.from(this.buffer), this[BUFFERLENGTH]) + B.concat(Array.from(this.buffer), this[BUFFERLENGTH]) ]) } @@ -217,7 +226,7 @@ class MiniPass extends EE { return dest } - addEventHandler (ev, fn) { + addListener (ev, fn) { return this.on(ev, fn) } diff --git a/node_modules/tar/node_modules/minipass/minipass-benchmarks.xlsx b/node_modules/tar/node_modules/minipass/minipass-benchmarks.xlsx Binary files differdeleted file mode 100644 index 05e19a41b..000000000 --- a/node_modules/tar/node_modules/minipass/minipass-benchmarks.xlsx +++ /dev/null diff --git a/node_modules/tar/node_modules/minipass/package.json b/node_modules/tar/node_modules/minipass/package.json index 52856521f..ad9174151 100644 --- a/node_modules/tar/node_modules/minipass/package.json +++ b/node_modules/tar/node_modules/minipass/package.json @@ -1,27 +1,28 @@ { - "_from": "minipass@^2.0.2", - "_id": "minipass@2.2.1", + "_from": "minipass@^2.2.4", + "_id": "minipass@2.2.4", "_inBundle": false, - "_integrity": "sha512-u1aUllxPJUI07cOqzR7reGmQxmCqlH88uIIsf6XZFEWgw7gXKpJdR+5R9Y3KEDmWYkdIz9wXZs3C0jOPxejk/Q==", + "_integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "_location": "/tar/minipass", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "minipass@^2.0.2", + "raw": "minipass@^2.2.4", "name": "minipass", "escapedName": "minipass", - "rawSpec": "^2.0.2", + "rawSpec": "^2.2.4", "saveSpec": null, - "fetchSpec": "^2.0.2" + "fetchSpec": "^2.2.4" }, "_requiredBy": [ "/tar", + "/tar/fs-minipass", "/tar/minizlib" ], - "_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz", - "_shasum": "5ada97538b1027b4cf7213432428578cb564011f", - "_spec": "minipass@^2.0.2", + "_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", + "_shasum": "03c824d84551ec38a8d1bb5bc350a5a30a354a40", + "_spec": "minipass@^2.2.4", "_where": "/Users/rebecca/code/npm/node_modules/tar", "author": { "name": "Isaac Z. Schlueter", @@ -33,6 +34,7 @@ }, "bundleDependencies": false, "dependencies": { + "safe-buffer": "^5.1.1", "yallist": "^3.0.0" }, "deprecated": false, @@ -42,6 +44,9 @@ "tap": "^10.7.0", "through2": "^2.0.3" }, + "files": [ + "index.js" + ], "homepage": "https://github.com/isaacs/minipass#readme", "keywords": [ "passthrough", @@ -60,5 +65,5 @@ "preversion": "npm test", "test": "tap test/*.js --100" }, - "version": "2.2.1" + "version": "2.2.4" } diff --git a/node_modules/tar/node_modules/minipass/test/basic.js b/node_modules/tar/node_modules/minipass/test/basic.js deleted file mode 100644 index e3885c808..000000000 --- a/node_modules/tar/node_modules/minipass/test/basic.js +++ /dev/null @@ -1,438 +0,0 @@ -const MiniPass = require('../') -const t = require('tap') -const EE = require('events').EventEmitter - -t.test('some basic piping and writing', async t => { - let mp = new MiniPass({ encoding: 'base64' }) - t.notOk(mp.flowing) - mp.flowing = true - t.notOk(mp.flowing) - t.equal(mp.encoding, 'base64') - mp.encoding = null - t.equal(mp.encoding, null) - t.equal(mp.readable, true) - t.equal(mp.writable, true) - t.equal(mp.write('hello'), false) - let dest = new MiniPass() - let sawDestData = false - dest.once('data', chunk => { - sawDestData = true - t.isa(chunk, Buffer) - }) - t.equal(mp.pipe(dest), dest, 'pipe returns dest') - t.ok(sawDestData, 'got data becasue pipe() flushes') - t.equal(mp.write('bye'), true, 'write() returns true when flowing') - dest.pause() - t.equal(mp.write('after pause'), false, 'false when dest is paused') - t.equal(mp.write('after false'), false, 'false when not flowing') - t.equal(dest.buffer.length, 1, '1 item is buffered in dest') - t.equal(mp.buffer.length, 1, '1 item buffered in src') - dest.resume() - t.equal(dest.buffer.length, 0, 'nothing is buffered in dest') - t.equal(mp.buffer.length, 0, 'nothing buffered in src') -}) - -t.test('unicode splitting', async t => { - const butterfly = '🦋' - const mp = new MiniPass({ encoding: 'utf8' }) - t.plan(2) - t.equal(mp.encoding, 'utf8') - mp.on('data', chunk => { - t.equal(chunk, butterfly) - }) - const butterbuf = new Buffer([0xf0, 0x9f, 0xa6, 0x8b]) - mp.write(butterbuf.slice(0, 1)) - mp.write(butterbuf.slice(1, 2)) - mp.write(butterbuf.slice(2, 3)) - mp.write(butterbuf.slice(3, 4)) - mp.end() -}) - -t.test('unicode splitting with setEncoding', async t => { - const butterfly = '🦋' - const mp = new MiniPass({ encoding: 'hex' }) - t.plan(4) - t.equal(mp.encoding, 'hex') - mp.setEncoding('hex') - t.equal(mp.encoding, 'hex') - mp.setEncoding('utf8') - t.equal(mp.encoding, 'utf8') - mp.on('data', chunk => { - t.equal(chunk, butterfly) - }) - const butterbuf = new Buffer([0xf0, 0x9f, 0xa6, 0x8b]) - mp.write(butterbuf.slice(0, 1)) - mp.write(butterbuf.slice(1, 2)) - mp.write(butterbuf.slice(2, 3)) - mp.write(butterbuf.slice(3, 4)) - mp.end() -}) - -t.test('base64 -> utf8 piping', t => { - t.plan(1) - const butterfly = '🦋' - const mp = new MiniPass({ encoding: 'base64' }) - const dest = new MiniPass({ encoding: 'utf8' }) - mp.pipe(dest) - let out = '' - dest.on('data', c => out += c) - dest.on('end', _ => - t.equal(new Buffer(out, 'base64').toString('utf8'), butterfly)) - mp.write(butterfly) - mp.end() -}) - -t.test('utf8 -> base64 piping', t => { - t.plan(1) - const butterfly = '🦋' - const mp = new MiniPass({ encoding: 'utf8' }) - const dest = new MiniPass({ encoding: 'base64' }) - mp.pipe(dest) - let out = '' - dest.on('data', c => out += c) - dest.on('end', _ => - t.equal(new Buffer(out, 'base64').toString('utf8'), butterfly)) - mp.write(butterfly) - mp.end() -}) - -t.test('read method', async t => { - const butterfly = '🦋' - const mp = new MiniPass({ encoding: 'utf8' }) - mp.on('data', c => t.equal(c, butterfly)) - mp.pause() - mp.write(new Buffer(butterfly)) - t.equal(mp.read(5), null) - t.equal(mp.read(0), null) - t.same(mp.read(2), butterfly) -}) - -t.test('read with no args', async t => { - t.test('buffer -> string', async t => { - const butterfly = '🦋' - const mp = new MiniPass({ encoding: 'utf8' }) - mp.on('data', c => t.equal(c, butterfly)) - mp.pause() - const butterbuf = new Buffer(butterfly) - mp.write(butterbuf.slice(0, 2)) - mp.write(butterbuf.slice(2)) - t.same(mp.read(), butterfly) - t.equal(mp.read(), null) - }) - - t.test('buffer -> buffer', async t => { - const butterfly = new Buffer('🦋') - const mp = new MiniPass() - mp.on('data', c => t.same(c, butterfly)) - mp.pause() - mp.write(butterfly.slice(0, 2)) - mp.write(butterfly.slice(2)) - t.same(mp.read(), butterfly) - t.equal(mp.read(), null) - }) - - t.test('string -> buffer', async t => { - const butterfly = '🦋' - const butterbuf = new Buffer(butterfly) - const mp = new MiniPass() - mp.on('data', c => t.same(c, butterbuf)) - mp.pause() - mp.write(butterfly) - t.same(mp.read(), butterbuf) - t.equal(mp.read(), null) - }) - - t.test('string -> string', async t => { - const butterfly = '🦋' - const mp = new MiniPass({ encoding: 'utf8' }) - mp.on('data', c => t.equal(c, butterfly)) - mp.pause() - mp.write(butterfly[0]) - mp.write(butterfly[1]) - t.same(mp.read(), butterfly) - t.equal(mp.read(), null) - }) -}) - -t.test('partial read', async t => { - const butterfly = '🦋' - const mp = new MiniPass() - const butterbuf = new Buffer(butterfly) - mp.write(butterbuf.slice(0, 1)) - mp.write(butterbuf.slice(1, 2)) - mp.write(butterbuf.slice(2, 3)) - mp.write(butterbuf.slice(3, 4)) - t.equal(mp.read(5), null) - t.equal(mp.read(0), null) - t.same(mp.read(2), butterbuf.slice(0, 2)) - t.same(mp.read(2), butterbuf.slice(2, 4)) -}) - -t.test('write after end', async t => { - const mp = new MiniPass() - let sawEnd = false - mp.on('end', _ => sawEnd = true) - mp.end() - t.throws(_ => mp.write('nope')) - t.notOk(sawEnd, 'should not get end event yet (not flowing)') - mp.resume() - t.ok(sawEnd, 'should get end event after resume()') -}) - -t.test('write cb', async t => { - const mp = new MiniPass() - let calledCb = false - mp.write('ok', () => calledCb = true) - t.ok(calledCb) -}) - -t.test('end with chunk', async t => { - let out = '' - const mp = new MiniPass({ encoding: 'utf8' }) - let sawEnd = false - mp.on('end', _ => sawEnd = true) - mp.addEventHandler('data', c => out += c) - let endCb = false - mp.end('ok', _ => endCb = true) - t.equal(out, 'ok') - t.ok(sawEnd, 'should see end event') - t.ok(endCb, 'end cb should get called') -}) - -t.test('no drain if could not entirely drain on resume', async t => { - const mp = new MiniPass() - const dest = new MiniPass({ encoding: 'buffer' }) - t.equal(mp.write('foo'), false) - t.equal(mp.write('bar'), false) - t.equal(mp.write('baz'), false) - t.equal(mp.write('qux'), false) - mp.on('drain', _ => t.fail('should not drain')) - mp.pipe(dest) -}) - -t.test('end with chunk pending', async t => { - const mp = new MiniPass() - t.equal(mp.write('foo'), false) - t.equal(mp.write('626172', 'hex'), false) - t.equal(mp.write('baz'), false) - t.equal(mp.write('qux'), false) - let sawEnd = false - mp.on('end', _ => sawEnd = true) - let endCb = false - mp.end(_ => endCb = true) - t.notOk(endCb, 'endcb should not happen yet') - t.notOk(sawEnd, 'should not see end yet') - let out = '' - mp.on('data', c => out += c) - t.ok(sawEnd, 'see end after flush') - t.ok(endCb, 'end cb after flush') - t.equal(out, 'foobarbazqux') -}) - -t.test('pipe to stderr does not throw', t => { - const spawn = require('child_process').spawn - const module = JSON.stringify(require.resolve('../')) - const fs = require('fs') - const file = __dirname + '/prog.js' - fs.writeFileSync(file, ` - const MP = require(${module}) - const mp = new MP() - mp.pipe(process.stderr) - mp.end("hello") - `) - let err = '' - return new Promise(res => { - const child = spawn(process.execPath, [file]) - child.stderr.on('data', c => err += c) - child.on('close', (code, signal) => { - t.equal(code, 0) - t.equal(signal, null) - t.equal(err, 'hello') - fs.unlinkSync(file) - res() - }) - }) -}) - -t.test('emit works with many args', t => { - const mp = new MiniPass() - t.plan(2) - mp.on('foo', function (a, b, c, d, e, f, g) { - t.same([a,b,c,d,e,f,g], [1,2,3,4,5,6,7]) - t.equal(arguments.length, 7) - }) - mp.emit('foo', 1, 2, 3, 4, 5, 6, 7) -}) - -t.test('emit drain on resume, even if no flush', t => { - const mp = new MiniPass() - mp.encoding = 'utf8' - - const chunks = [] - class SlowStream extends EE { - write (chunk) { - chunks.push(chunk) - setTimeout(_ => this.emit('drain')) - return false - } - end () { return this.write() } - } - - const ss = new SlowStream() - - mp.pipe(ss) - t.ok(mp.flowing, 'flowing, because piped') - t.equal(mp.write('foo'), false, 'write() returns false, backpressure') - t.equal(mp.buffer.length, 0, 'buffer len is 0') - t.equal(mp.flowing, false, 'flowing false, awaiting drain') - t.same(chunks, ['foo'], 'chunk made it through') - mp.once('drain', _ => { - t.pass('received mp drain event') - t.end() - }) -}) - -t.test('save close for end', t => { - const mp = new MiniPass() - let ended = false - mp.on('close', _ => { - t.equal(ended, true, 'end before close') - t.end() - }) - mp.on('end', _ => { - t.equal(ended, false, 'only end once') - ended = true - }) - - mp.emit('close') - mp.end('foo') - t.equal(ended, false, 'no end until flushed') - mp.resume() -}) - -t.test('eos works', t => { - const eos = require('end-of-stream') - const mp = new MiniPass() - - eos(mp, er => { - if (er) - throw er - t.end() - }) - - mp.emit('close') - mp.end('foo') - mp.resume() -}) - -t.test('bufferLength property', t => { - const eos = require('end-of-stream') - const mp = new MiniPass() - mp.write('a') - mp.write('a') - mp.write('a') - mp.write('a') - mp.write('a') - mp.write('a') - - t.equal(mp.bufferLength, 6) - t.equal(mp.read(7), null) - t.equal(mp.read(3).toString(), 'aaa') - t.equal(mp.bufferLength, 3) - t.equal(mp.read().toString(), 'aaa') - t.equal(mp.bufferLength, 0) - t.end() -}) - -t.test('emit resume event on resume', t => { - const mp = new MiniPass() - t.plan(3) - mp.on('resume', _ => t.pass('got resume event')) - mp.end('asdf') - t.equal(mp.flowing, false, 'not flowing yet') - mp.resume() - t.equal(mp.flowing, true, 'flowing after resume') -}) - -t.test('objectMode', t => { - const mp = new MiniPass({ objectMode: true }) - const a = { a: 1 } - const b = { b: 1 } - const out = [] - mp.on('data', c => out.push(c)) - mp.on('end', _ => { - t.equal(out.length, 2) - t.equal(out[0], a) - t.equal(out[1], b) - t.same(out, [ { a: 1 }, { b: 1 } ], 'objs not munged') - t.end() - }) - t.ok(mp.write(a)) - t.ok(mp.write(b)) - mp.end() -}) - -t.test('objectMode no encoding', t => { - const mp = new MiniPass({ - objectMode: true, - encoding: 'utf8' - }) - t.equal(mp.encoding, null) - const a = { a: 1 } - const b = { b: 1 } - const out = [] - mp.on('data', c => out.push(c)) - mp.on('end', _ => { - t.equal(out.length, 2) - t.equal(out[0], a) - t.equal(out[1], b) - t.same(out, [ { a: 1 }, { b: 1 } ], 'objs not munged') - t.end() - }) - t.ok(mp.write(a)) - t.ok(mp.write(b)) - mp.end() -}) - -t.test('objectMode read() and buffering', t => { - const mp = new MiniPass({ objectMode: true }) - const a = { a: 1 } - const b = { b: 1 } - t.notOk(mp.write(a)) - t.notOk(mp.write(b)) - t.equal(mp.read(2), a) - t.equal(mp.read(), b) - t.end() -}) - -t.test('set encoding in object mode throws', async t => - t.throws(_ => new MiniPass({ objectMode: true }).encoding = 'utf8', - new Error('cannot set encoding in objectMode'))) - -t.test('set encoding again throws', async t => - t.throws(_ => { - const mp = new MiniPass({ encoding: 'hex' }) - mp.write('ok') - mp.encoding = 'utf8' - }, new Error('cannot change encoding'))) - -t.test('set encoding with existing buffer', async t => { - const mp = new MiniPass() - const butterfly = '🦋' - const butterbuf = new Buffer(butterfly) - mp.write(butterbuf.slice(0, 1)) - mp.write(butterbuf.slice(1, 2)) - mp.setEncoding('utf8') - mp.write(butterbuf.slice(2)) - t.equal(mp.read(), butterfly) -}) - -t.test('end:false', async t => { - t.plan(1) - const mp = new MiniPass({ encoding: 'utf8' }) - const d = new MiniPass({ encoding: 'utf8' }) - d.end = () => t.threw(new Error('no end no exit no way out')) - d.on('data', c => t.equal(c, 'this is fine')) - mp.pipe(d, { end: false }) - mp.end('this is fine') -}) diff --git a/node_modules/tar/node_modules/minipass/test/empty-end.js b/node_modules/tar/node_modules/minipass/test/empty-end.js deleted file mode 100644 index 42387d51a..000000000 --- a/node_modules/tar/node_modules/minipass/test/empty-end.js +++ /dev/null @@ -1,38 +0,0 @@ -const t = require('tap') -const MP = require('../') - -t.test('emit end on resume', async t => { - const list = [] - const mp = new MP() - mp.on('end', _ => list.push('end')) - mp.end() - t.notOk(mp.emittedEnd) - list.push('called end') - mp.resume() - t.ok(mp.emittedEnd) - list.push('called resume') - t.same(list, ['called end', 'end', 'called resume']) -}) - -t.test('emit end on read()', async t => { - const list = [] - const mp = new MP() - mp.on('end', _ => list.push('end')) - mp.end() - list.push('called end') - - mp.read() - list.push('called read()') - t.same(list, ['called end', 'end', 'called read()']) -}) - -t.test('emit end on data handler', async t => { - const list = [] - const mp = new MP() - mp.on('end', _ => list.push('end')) - mp.end() - list.push('called end') - mp.on('data', _=>_) - list.push('added data handler') - t.same(list, ['called end', 'end', 'added data handler']) -}) diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json index 38c4ec516..b093652fc 100644 --- a/node_modules/tar/package.json +++ b/node_modules/tar/package.json @@ -1,28 +1,31 @@ { - "_from": "tar@4.4.0", - "_id": "tar@4.4.0", + "_from": "tar@4.4.1", + "_id": "tar@4.4.1", "_inBundle": false, - "_integrity": "sha512-gJlTiiErwo96K904FnoYWl+5+FBgS+FimU6GMh66XLdLa55al8+d4jeDfPoGwSNHdtWI5FJP6xurmVqhBuGJpQ==", + "_integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==", "_location": "/tar", - "_phantomChildren": {}, + "_phantomChildren": { + "safe-buffer": "5.1.1" + }, "_requested": { "type": "version", "registry": true, - "raw": "tar@4.4.0", + "raw": "tar@4.4.1", "name": "tar", "escapedName": "tar", - "rawSpec": "4.4.0", + "rawSpec": "4.4.1", "saveSpec": null, - "fetchSpec": "4.4.0" + "fetchSpec": "4.4.1" }, "_requiredBy": [ "#USER", - "/" + "/", + "/pacote" ], - "_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.0.tgz", - "_shasum": "3aaf8c29b6b800a8215f33efb4df1c95ce2ac2f5", - "_spec": "tar@4.4.0", - "_where": "/Users/zkat/Documents/code/npm", + "_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.1.tgz", + "_shasum": "b25d5a8470c976fd7a9a8a350f42c59e9fa81749", + "_spec": "tar@4.4.1", + "_where": "/Users/rebecca/code/npm", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -34,21 +37,22 @@ "bundleDependencies": false, "dependencies": { "chownr": "^1.0.1", - "fs-minipass": "^1.2.3", - "minipass": "^2.2.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.2.4", "minizlib": "^1.1.0", "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.1", "yallist": "^3.0.2" }, "deprecated": false, "description": "tar for node", "devDependencies": { "chmodr": "^1.0.2", - "end-of-stream": "^1.4.0", + "end-of-stream": "^1.4.1", "events-to-array": "^1.1.2", "mutate-fs": "^2.1.1", "rimraf": "^2.6.2", - "tap": "^11.0.0-rc.3", + "tap": "^11.1.3", "tar-fs": "^1.16.0", "tar-stream": "^1.5.2" }, @@ -74,5 +78,5 @@ "preversion": "npm test", "test": "tap test/*.js --100 -J --coverage-report=text -c" }, - "version": "4.4.0" + "version": "4.4.1" } |