This commit is contained in:
Bret Comnes 2020-02-12 16:58:30 -07:00
parent 383cb4ca53
commit 49f58fb497
No known key found for this signature in database
GPG Key ID: 3705F4634DC3A1AC
98 changed files with 9972 additions and 1 deletions

16
CHANGELOG.md Normal file
View File

@ -0,0 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
## 0.0.1 - 2020-02-12
### Commits
- commit node_modules [`13eab06`](https://github.com/bcomnes/deploy-to-neocities/commit/13eab06cd3fbafa45500255738a1f08c3939ecbb)
- Switch back over to CJS. sa la vie [`abc9656`](https://github.com/bcomnes/deploy-to-neocities/commit/abc9656e71415695fcb9a5a34c2b08abe132d09f)
- Implement easy parts of client [`364b8fc`](https://github.com/bcomnes/deploy-to-neocities/commit/364b8fc2ed70011ad4f72d1021b602e1fb42b088)

0
node_modules/async-neocities/lib/progress.js generated vendored Normal file
View File

38
node_modules/async-neocities/lib/stream-meter.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
const { Writable, Transform } = require('streamx')
const pump = require('pump')
const pumpify = require('pumpify')
function getStreamLength (readable) {
let length = 0
const dummyLoad = new Writable({
write (data, cb) {
length += data.length
cb(null)
}
})
return new Promise((resolve, reject) => {
pump(readable, dummyLoad, (err) => {
if (err) return reject(err)
resolve(length)
})
})
}
function meterStream (readable, statsCb) {
let bytesRead = 0
const meter = new Transform({
transform (data, cb) {
bytesRead += data.length
statsCb(bytesRead)
cb(null, data)
}
})
return pumpify(readable, meter)
}
module.exports = {
getStreamLength,
meterStream
}

34
node_modules/async-neocities/lib/timer.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
/**
* Simple timer lets you record start and stop times, with an elapsed time getter.
*/
class SimpleTimer {
constructor (startTime) {
this.start = startTime || Date.now()
this.end = null
this.stopped = false
}
get elapsed () {
if (this.stopped) {
return this.end - this.start
} else {
return Date.now() - this.start
}
}
stop () {
if (this.stopped) return
this.stopped = true
this.end = Date.now()
}
toString () {
return this.elapsed
}
toJSON () {
return this.elapsed
}
}
module.exports = SimpleTimer

6
node_modules/duplexify/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,6 @@
language: node_js
node_js:
- "4"
- "6"
- "8"
- "10"

21
node_modules/duplexify/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Mathias Buus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

97
node_modules/duplexify/README.md generated vendored Normal file
View File

@ -0,0 +1,97 @@
# duplexify
Turn a writeable and readable stream into a single streams2 duplex stream.
Similar to [duplexer2](https://github.com/deoxxa/duplexer2) except it supports both streams2 and streams1 as input
and it allows you to set the readable and writable part asynchronously using `setReadable(stream)` and `setWritable(stream)`
```
npm install duplexify
```
[![build status](http://img.shields.io/travis/mafintosh/duplexify.svg?style=flat)](http://travis-ci.org/mafintosh/duplexify)
## Usage
Use `duplexify(writable, readable, streamOptions)` (or `duplexify.obj(writable, readable)` to create an object stream)
``` js
var duplexify = require('duplexify')
// turn writableStream and readableStream into a single duplex stream
var dup = duplexify(writableStream, readableStream)
dup.write('hello world') // will write to writableStream
dup.on('data', function(data) {
// will read from readableStream
})
```
You can also set the readable and writable parts asynchronously
``` js
var dup = duplexify()
dup.write('hello world') // write will buffer until the writable
// part has been set
// wait a bit ...
dup.setReadable(readableStream)
// maybe wait some more?
dup.setWritable(writableStream)
```
If you call `setReadable` or `setWritable` multiple times it will unregister the previous readable/writable stream.
To disable the readable or writable part call `setReadable` or `setWritable` with `null`.
If the readable or writable streams emits an error or close it will destroy both streams and bubble up the event.
You can also explicitly destroy the streams by calling `dup.destroy()`. The `destroy` method optionally takes an
error object as argument, in which case the error is emitted as part of the `error` event.
``` js
dup.on('error', function(err) {
console.log('readable or writable emitted an error - close will follow')
})
dup.on('close', function() {
console.log('the duplex stream is destroyed')
})
dup.destroy() // calls destroy on the readable and writable part (if present)
```
## HTTP request example
Turn a node core http request into a duplex stream is as easy as
``` js
var duplexify = require('duplexify')
var http = require('http')
var request = function(opts) {
var req = http.request(opts)
var dup = duplexify(req)
req.on('response', function(res) {
dup.setReadable(res)
})
return dup
}
var req = request({
method: 'GET',
host: 'www.google.com',
port: 80
})
req.end()
req.pipe(process.stdout)
```
## License
MIT
## Related
`duplexify` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.

21
node_modules/duplexify/example.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
var duplexify = require('duplexify')
var http = require('http')
var request = function(opts) {
var req = http.request(opts)
var dup = duplexify()
dup.setWritable(req)
req.on('response', function(res) {
dup.setReadable(res)
})
return dup
}
var req = request({
method: 'GET',
host: 'www.google.com',
port: 80
})
req.end()
req.pipe(process.stdout)

238
node_modules/duplexify/index.js generated vendored Normal file
View File

@ -0,0 +1,238 @@
var stream = require('readable-stream')
var eos = require('end-of-stream')
var inherits = require('inherits')
var shift = require('stream-shift')
var SIGNAL_FLUSH = (Buffer.from && Buffer.from !== Uint8Array.from)
? Buffer.from([0])
: new Buffer([0])
var onuncork = function(self, fn) {
if (self._corked) self.once('uncork', fn)
else fn()
}
var autoDestroy = function (self, err) {
if (self._autoDestroy) self.destroy(err)
}
var destroyer = function(self, end) {
return function(err) {
if (err) autoDestroy(self, err.message === 'premature close' ? null : err)
else if (end && !self._ended) self.end()
}
}
var end = function(ws, fn) {
if (!ws) return fn()
if (ws._writableState && ws._writableState.finished) return fn()
if (ws._writableState) return ws.end(fn)
ws.end()
fn()
}
var noop = function() {}
var toStreams2 = function(rs) {
return new (stream.Readable)({objectMode:true, highWaterMark:16}).wrap(rs)
}
var Duplexify = function(writable, readable, opts) {
if (!(this instanceof Duplexify)) return new Duplexify(writable, readable, opts)
stream.Duplex.call(this, opts)
this._writable = null
this._readable = null
this._readable2 = null
this._autoDestroy = !opts || opts.autoDestroy !== false
this._forwardDestroy = !opts || opts.destroy !== false
this._forwardEnd = !opts || opts.end !== false
this._corked = 1 // start corked
this._ondrain = null
this._drained = false
this._forwarding = false
this._unwrite = null
this._unread = null
this._ended = false
this.destroyed = false
if (writable) this.setWritable(writable)
if (readable) this.setReadable(readable)
}
inherits(Duplexify, stream.Duplex)
Duplexify.obj = function(writable, readable, opts) {
if (!opts) opts = {}
opts.objectMode = true
opts.highWaterMark = 16
return new Duplexify(writable, readable, opts)
}
Duplexify.prototype.cork = function() {
if (++this._corked === 1) this.emit('cork')
}
Duplexify.prototype.uncork = function() {
if (this._corked && --this._corked === 0) this.emit('uncork')
}
Duplexify.prototype.setWritable = function(writable) {
if (this._unwrite) this._unwrite()
if (this.destroyed) {
if (writable && writable.destroy) writable.destroy()
return
}
if (writable === null || writable === false) {
this.end()
return
}
var self = this
var unend = eos(writable, {writable:true, readable:false}, destroyer(this, this._forwardEnd))
var ondrain = function() {
var ondrain = self._ondrain
self._ondrain = null
if (ondrain) ondrain()
}
var clear = function() {
self._writable.removeListener('drain', ondrain)
unend()
}
if (this._unwrite) process.nextTick(ondrain) // force a drain on stream reset to avoid livelocks
this._writable = writable
this._writable.on('drain', ondrain)
this._unwrite = clear
this.uncork() // always uncork setWritable
}
Duplexify.prototype.setReadable = function(readable) {
if (this._unread) this._unread()
if (this.destroyed) {
if (readable && readable.destroy) readable.destroy()
return
}
if (readable === null || readable === false) {
this.push(null)
this.resume()
return
}
var self = this
var unend = eos(readable, {writable:false, readable:true}, destroyer(this))
var onreadable = function() {
self._forward()
}
var onend = function() {
self.push(null)
}
var clear = function() {
self._readable2.removeListener('readable', onreadable)
self._readable2.removeListener('end', onend)
unend()
}
this._drained = true
this._readable = readable
this._readable2 = readable._readableState ? readable : toStreams2(readable)
this._readable2.on('readable', onreadable)
this._readable2.on('end', onend)
this._unread = clear
this._forward()
}
Duplexify.prototype._read = function() {
this._drained = true
this._forward()
}
Duplexify.prototype._forward = function() {
if (this._forwarding || !this._readable2 || !this._drained) return
this._forwarding = true
var data
while (this._drained && (data = shift(this._readable2)) !== null) {
if (this.destroyed) continue
this._drained = this.push(data)
}
this._forwarding = false
}
Duplexify.prototype.destroy = function(err, cb) {
if (!cb) cb = noop
if (this.destroyed) return cb(null)
this.destroyed = true
var self = this
process.nextTick(function() {
self._destroy(err)
cb(null)
})
}
Duplexify.prototype._destroy = function(err) {
if (err) {
var ondrain = this._ondrain
this._ondrain = null
if (ondrain) ondrain(err)
else this.emit('error', err)
}
if (this._forwardDestroy) {
if (this._readable && this._readable.destroy) this._readable.destroy()
if (this._writable && this._writable.destroy) this._writable.destroy()
}
this.emit('close')
}
Duplexify.prototype._write = function(data, enc, cb) {
if (this.destroyed) return
if (this._corked) return onuncork(this, this._write.bind(this, data, enc, cb))
if (data === SIGNAL_FLUSH) return this._finish(cb)
if (!this._writable) return cb()
if (this._writable.write(data) === false) this._ondrain = cb
else if (!this.destroyed) cb()
}
Duplexify.prototype._finish = function(cb) {
var self = this
this.emit('preend')
onuncork(this, function() {
end(self._forwardEnd && self._writable, function() {
// haxx to not emit prefinish twice
if (self._writableState.prefinished === false) self._writableState.prefinished = true
self.emit('prefinish')
onuncork(self, cb)
})
})
}
Duplexify.prototype.end = function(data, enc, cb) {
if (typeof data === 'function') return this.end(null, null, data)
if (typeof enc === 'function') return this.end(data, null, enc)
this._ended = true
if (data) this.write(data)
if (!this._writableState.ending) this.write(SIGNAL_FLUSH)
return stream.Writable.prototype.end.call(this, cb)
}
module.exports = Duplexify

66
node_modules/duplexify/package.json generated vendored Normal file
View File

@ -0,0 +1,66 @@
{
"_from": "duplexify@^4.1.1",
"_id": "duplexify@4.1.1",
"_inBundle": false,
"_integrity": "sha512-DY3xVEmVHTv1wSzKNbwoU6nVjzI369Y6sPoqfYr0/xlx3IdX2n94xIszTcjPO8W8ZIv0Wb0PXNcjuZyT4wiICA==",
"_location": "/duplexify",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "duplexify@^4.1.1",
"name": "duplexify",
"escapedName": "duplexify",
"rawSpec": "^4.1.1",
"saveSpec": null,
"fetchSpec": "^4.1.1"
},
"_requiredBy": [
"/pumpify"
],
"_resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.1.tgz",
"_shasum": "7027dc374f157b122a8ae08c2d3ea4d2d953aa61",
"_spec": "duplexify@^4.1.1",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/pumpify",
"author": {
"name": "Mathias Buus"
},
"bugs": {
"url": "https://github.com/mafintosh/duplexify/issues"
},
"bundleDependencies": false,
"dependencies": {
"end-of-stream": "^1.4.1",
"inherits": "^2.0.3",
"readable-stream": "^3.1.1",
"stream-shift": "^1.0.0"
},
"deprecated": false,
"description": "Turn a writable and readable stream into a streams2 duplex stream with support for async initialization and streams1/streams2 input",
"devDependencies": {
"concat-stream": "^1.5.2",
"tape": "^4.0.0",
"through2": "^2.0.0"
},
"homepage": "https://github.com/mafintosh/duplexify",
"keywords": [
"duplex",
"streams2",
"streams",
"stream",
"writable",
"readable",
"async"
],
"license": "MIT",
"main": "index.js",
"name": "duplexify",
"repository": {
"type": "git",
"url": "git://github.com/mafintosh/duplexify.git"
},
"scripts": {
"test": "tape test.js"
},
"version": "4.1.1"
}

338
node_modules/duplexify/test.js generated vendored Normal file
View File

@ -0,0 +1,338 @@
var tape = require('tape')
var through = require('through2')
var concat = require('concat-stream')
var stream = require('readable-stream')
var net = require('net')
var duplexify = require('./')
var HELLO_WORLD = (Buffer.from && Buffer.from !== Uint8Array.from)
? Buffer.from('hello world')
: new Buffer('hello world')
tape('passthrough', function(t) {
t.plan(2)
var pt = through()
var dup = duplexify(pt, pt)
dup.end('hello world')
dup.on('finish', function() {
t.ok(true, 'should finish')
})
dup.pipe(concat(function(data) {
t.same(data.toString(), 'hello world', 'same in as out')
}))
})
tape('passthrough + double end', function(t) {
t.plan(2)
var pt = through()
var dup = duplexify(pt, pt)
dup.end('hello world')
dup.end()
dup.on('finish', function() {
t.ok(true, 'should finish')
})
dup.pipe(concat(function(data) {
t.same(data.toString(), 'hello world', 'same in as out')
}))
})
tape('async passthrough + end', function(t) {
t.plan(2)
var pt = through.obj({highWaterMark:1}, function(data, enc, cb) {
setTimeout(function() {
cb(null, data)
}, 100)
})
var dup = duplexify(pt, pt)
dup.write('hello ')
dup.write('world')
dup.end()
dup.on('finish', function() {
t.ok(true, 'should finish')
})
dup.pipe(concat(function(data) {
t.same(data.toString(), 'hello world', 'same in as out')
}))
})
tape('duplex', function(t) {
var readExpected = ['read-a', 'read-b', 'read-c']
var writeExpected = ['write-a', 'write-b', 'write-c']
t.plan(readExpected.length+writeExpected.length+2)
var readable = through.obj()
var writable = through.obj(function(data, enc, cb) {
t.same(data, writeExpected.shift(), 'onwrite should match')
cb()
})
var dup = duplexify.obj(writable, readable)
readExpected.slice().forEach(function(data) {
readable.write(data)
})
readable.end()
writeExpected.slice().forEach(function(data) {
dup.write(data)
})
dup.end()
dup.on('data', function(data) {
t.same(data, readExpected.shift(), 'ondata should match')
})
dup.on('end', function() {
t.ok(true, 'should end')
})
dup.on('finish', function() {
t.ok(true, 'should finish')
})
})
tape('async', function(t) {
var dup = duplexify()
var pt = through()
dup.pipe(concat(function(data) {
t.same(data.toString(), 'i was async', 'same in as out')
t.end()
}))
dup.write('i')
dup.write(' was ')
dup.end('async')
setTimeout(function() {
dup.setWritable(pt)
setTimeout(function() {
dup.setReadable(pt)
}, 50)
}, 50)
})
tape('destroy', function(t) {
t.plan(2)
var write = through()
var read = through()
var dup = duplexify(write, read)
write.destroy = function() {
t.ok(true, 'write destroyed')
}
dup.on('close', function() {
t.ok(true, 'close emitted')
})
dup.destroy()
dup.destroy() // should only work once
})
tape('destroy both', function(t) {
t.plan(3)
var write = through()
var read = through()
var dup = duplexify(write, read)
write.destroy = function() {
t.ok(true, 'write destroyed')
}
read.destroy = function() {
t.ok(true, 'read destroyed')
}
dup.on('close', function() {
t.ok(true, 'close emitted')
})
dup.destroy()
dup.destroy() // should only work once
})
tape('bubble read errors', function(t) {
t.plan(2)
var write = through()
var read = through()
var dup = duplexify(write, read)
dup.on('error', function(err) {
t.same(err.message, 'read-error', 'received read error')
})
dup.on('close', function() {
t.ok(true, 'close emitted')
})
read.emit('error', new Error('read-error'))
write.emit('error', new Error('write-error')) // only emit first error
})
tape('bubble write errors', function(t) {
t.plan(2)
var write = through()
var read = through()
var dup = duplexify(write, read)
dup.on('error', function(err) {
t.same(err.message, 'write-error', 'received write error')
})
dup.on('close', function() {
t.ok(true, 'close emitted')
})
write.emit('error', new Error('write-error'))
read.emit('error', new Error('read-error')) // only emit first error
})
tape('bubble errors from write()', function(t) {
t.plan(3)
var errored = false
var dup = duplexify(new stream.Writable({
write: function(chunk, enc, next) {
next(new Error('write-error'))
}
}))
dup.on('error', function(err) {
errored = true
t.same(err.message, 'write-error', 'received write error')
})
dup.on('close', function() {
t.pass('close emitted')
t.ok(errored, 'error was emitted before close')
})
dup.end('123')
})
tape('destroy while waiting for drain', function(t) {
t.plan(3)
var errored = false
var dup = duplexify(new stream.Writable({
highWaterMark: 0,
write: function() {}
}))
dup.on('error', function(err) {
errored = true
t.same(err.message, 'destroy-error', 'received destroy error')
})
dup.on('close', function() {
t.pass('close emitted')
t.ok(errored, 'error was emitted before close')
})
dup.write('123')
dup.destroy(new Error('destroy-error'))
})
tape('reset writable / readable', function(t) {
t.plan(3)
var toUpperCase = function(data, enc, cb) {
cb(null, data.toString().toUpperCase())
}
var passthrough = through()
var upper = through(toUpperCase)
var dup = duplexify(passthrough, passthrough)
dup.once('data', function(data) {
t.same(data.toString(), 'hello')
dup.setWritable(upper)
dup.setReadable(upper)
dup.once('data', function(data) {
t.same(data.toString(), 'HELLO')
dup.once('data', function(data) {
t.same(data.toString(), 'HI')
t.end()
})
})
dup.write('hello')
dup.write('hi')
})
dup.write('hello')
})
tape('cork', function(t) {
var passthrough = through()
var dup = duplexify(passthrough, passthrough)
var ok = false
dup.on('prefinish', function() {
dup.cork()
setTimeout(function() {
ok = true
dup.uncork()
}, 100)
})
dup.on('finish', function() {
t.ok(ok)
t.end()
})
dup.end()
})
tape('prefinish not twice', function(t) {
var passthrough = through()
var dup = duplexify(passthrough, passthrough)
var prefinished = false
dup.on('prefinish', function() {
t.ok(!prefinished, 'only prefinish once')
prefinished = true
})
dup.on('finish', function() {
t.end()
})
dup.end()
})
tape('close', function(t) {
var passthrough = through()
var dup = duplexify(passthrough, passthrough)
passthrough.emit('close')
dup.on('close', function() {
t.ok(true, 'should forward close')
t.end()
})
})
tape('works with node native streams (net)', function(t) {
t.plan(1)
var server = net.createServer(function(socket) {
var dup = duplexify(socket, socket)
dup.once('data', function(chunk) {
t.same(chunk, HELLO_WORLD)
server.close()
socket.end()
t.end()
})
})
server.listen(0, function () {
var socket = net.connect(server.address().port)
var dup = duplexify(socket, socket)
dup.write(HELLO_WORLD)
})
})

21
node_modules/fast-fifo/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 Mathias Buus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

66
node_modules/fast-fifo/README.md generated vendored Normal file
View File

@ -0,0 +1,66 @@
# fast-fifo
A fast fifo implementation similar to the one powering nextTick in Node.js core
```
npm install fast-fifo
```
Uses a linked list of growing fixed sized arrays to implement the FIFO to avoid
allocating a wrapper object for each item.
## Usage
``` js
const FIFO = require('fast-fifo')
const q = new FIFO()
q.push('hello')
q.push('world')
q.shift() // returns hello
q.shift() // returns world
```
## API
#### `q = new FIFO()`
Create a new FIFO.
#### `q.push(value)`
Push a value to the FIFO. `value` can be anything other than undefined.
#### `value = q.shift()`
Return the oldest value from the FIFO.
#### `bool = q.isEmpty()`
Returns `true` if the FIFO is empty and false otherwise.
## Benchmarks
Included in bench.js is a simple benchmark that benchmarks this against a simple
linked list based FIFO.
On my machine the benchmark looks like this:
```
fifo bulk push and shift: 2881.508ms
fifo individual push and shift: 3248.437ms
fast-fifo bulk push and shift: 1606.972ms
fast-fifo individual push and shift: 1328.064ms
fifo bulk push and shift: 3266.902ms
fifo individual push and shift: 3320.944ms
fast-fifo bulk push and shift: 1858.307ms
fast-fifo individual push and shift: 1516.983ms
```
YMMV
## License
MIT

34
node_modules/fast-fifo/bench.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
const FastFIFO = require('./')
const FIFO = require('fifo')
run(new FIFO(), 'fifo')
run(new FastFIFO(), 'fast-fifo')
run(new FIFO(), 'fifo')
run(new FastFIFO(), 'fast-fifo')
function run (q, prefix) {
const runs = 1024
console.time(prefix + ' bulk push and shift')
for (let j = 0; j < 1e5; j++) {
for (let i = 0; i < runs; i++) {
q.push(i)
}
for (let i = 0; i < runs; i++) {
q.shift()
}
}
console.timeEnd(prefix + ' bulk push and shift')
console.time(prefix + ' individual push and shift')
for (let j = 0; j < 1e5; j++) {
for (let i = 0; i < runs; i++) {
q.push(i)
q.shift()
}
}
console.timeEnd(prefix + ' individual push and shift')
}

29
node_modules/fast-fifo/fixed-size.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
module.exports = class FixedFIFO {
constructor (hwm) {
if (!(hwm > 0) || ((hwm - 1) & hwm) !== 0) throw new Error('Max size for a FixedFIFO should be a power of two')
this.buffer = new Array(hwm)
this.mask = hwm - 1
this.top = 0
this.btm = 0
this.next = null
}
push (data) {
if (this.buffer[this.top] !== undefined) return false
this.buffer[this.top] = data
this.top = (this.top + 1) & this.mask
return true
}
shift () {
const last = this.buffer[this.btm]
if (last === undefined) return undefined
this.buffer[this.btm] = undefined
this.btm = (this.btm + 1) & this.mask
return last
}
isEmpty () {
return this.buffer[this.btm] === undefined
}
}

32
node_modules/fast-fifo/index.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
const FixedFIFO = require('./fixed-size')
module.exports = class FastFIFO {
constructor (hwm) {
this.hwm = hwm || 16
this.head = new FixedFIFO(this.hwm)
this.tail = this.head
}
push (val) {
if (!this.head.push(val)) {
const prev = this.head
this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length)
this.head.push(val)
}
}
shift () {
const val = this.tail.shift()
if (val === undefined && this.tail.next) {
const next = this.tail.next
this.tail.next = null
this.tail = next
return this.tail.shift()
}
return val
}
isEmpty () {
return this.head.isEmpty()
}
}

52
node_modules/fast-fifo/package.json generated vendored Normal file
View File

@ -0,0 +1,52 @@
{
"_from": "fast-fifo@^1.0.0",
"_id": "fast-fifo@1.0.0",
"_inBundle": false,
"_integrity": "sha512-4VEXmjxLj7sbs8J//cn2qhRap50dGzF5n8fjay8mau+Jn4hxSeR3xPFwxMaQq/pDaq7+KQk0PAbC2+nWDkJrmQ==",
"_location": "/fast-fifo",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "fast-fifo@^1.0.0",
"name": "fast-fifo",
"escapedName": "fast-fifo",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/streamx"
],
"_resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.0.0.tgz",
"_shasum": "9bc72e6860347bb045a876d1c5c0af11e9b984e7",
"_spec": "fast-fifo@^1.0.0",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/streamx",
"author": {
"name": "Mathias Buus",
"url": "@mafintosh"
},
"bugs": {
"url": "https://github.com/mafintosh/fast-fifo/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "A fast fifo implementation similar to the one powering nextTick in Node.js core",
"devDependencies": {
"standard": "^12.0.1",
"tape": "^4.10.1"
},
"homepage": "https://github.com/mafintosh/fast-fifo",
"license": "MIT",
"main": "index.js",
"name": "fast-fifo",
"repository": {
"type": "git",
"url": "git+https://github.com/mafintosh/fast-fifo.git"
},
"scripts": {
"test": "standard && tape test.js"
},
"version": "1.0.0"
}

38
node_modules/fast-fifo/test.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
const tape = require('tape')
const FIFO = require('./')
tape('basic', function (t) {
const q = new FIFO()
const values = [
1,
4,
4,
0,
null,
{},
Math.random(),
'',
'hello',
9,
1,
4,
5,
6,
7,
null,
null,
0,
0,
15,
52.2,
null
]
t.same(q.shift(), undefined)
t.ok(q.isEmpty())
for (const value of values) q.push(value)
while (!q.isEmpty()) t.same(q.shift(), values.shift())
t.same(q.shift(), undefined)
t.ok(q.isEmpty())
t.end()
})

16
node_modules/inherits/LICENSE generated vendored Normal file
View File

@ -0,0 +1,16 @@
The ISC License
Copyright (c) Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

42
node_modules/inherits/README.md generated vendored Normal file
View File

@ -0,0 +1,42 @@
Browser-friendly inheritance fully compatible with standard node.js
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
This package exports standard `inherits` from node.js `util` module in
node environment, but also provides alternative browser-friendly
implementation through [browser
field](https://gist.github.com/shtylman/4339901). Alternative
implementation is a literal copy of standard one located in standalone
module to avoid requiring of `util`. It also has a shim for old
browsers with no `Object.create` support.
While keeping you sure you are using standard `inherits`
implementation in node.js environment, it allows bundlers such as
[browserify](https://github.com/substack/node-browserify) to not
include full `util` package to your client code if all you need is
just `inherits` function. It worth, because browser shim for `util`
package is large and `inherits` is often the single function you need
from it.
It's recommended to use this package instead of
`require('util').inherits` for any code that has chances to be used
not only in node.js but in browser too.
## usage
```js
var inherits = require('inherits');
// then use exactly as the standard one
```
## note on version ~1.0
Version ~1.0 had completely different motivation and is not compatible
neither with 2.0 nor with standard node.js `inherits`.
If you are using version ~1.0 and planning to switch to ~2.0, be
careful:
* new version uses `super_` instead of `super` for referencing
superclass
* new version overwrites current prototype while old one preserves any
existing fields on it

9
node_modules/inherits/inherits.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
try {
var util = require('util');
/* istanbul ignore next */
if (typeof util.inherits !== 'function') throw '';
module.exports = util.inherits;
} catch (e) {
/* istanbul ignore next */
module.exports = require('./inherits_browser.js');
}

27
node_modules/inherits/inherits_browser.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
})
}
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
}

68
node_modules/inherits/package.json generated vendored Normal file
View File

@ -0,0 +1,68 @@
{
"_from": "inherits@^2.0.3",
"_id": "inherits@2.0.4",
"_inBundle": false,
"_integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"_location": "/inherits",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "inherits@^2.0.3",
"name": "inherits",
"escapedName": "inherits",
"rawSpec": "^2.0.3",
"saveSpec": null,
"fetchSpec": "^2.0.3"
},
"_requiredBy": [
"/bl/readable-stream",
"/duplexer2/readable-stream",
"/duplexify",
"/glob",
"/hyperquest/readable-stream",
"/pumpify",
"/readable-stream",
"/through2/readable-stream"
],
"_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"_shasum": "0fa2c64f932917c3433a0ded55363aae37416b7c",
"_spec": "inherits@^2.0.3",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/pumpify",
"browser": "./inherits_browser.js",
"bugs": {
"url": "https://github.com/isaacs/inherits/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
"devDependencies": {
"tap": "^14.2.4"
},
"files": [
"inherits.js",
"inherits_browser.js"
],
"homepage": "https://github.com/isaacs/inherits#readme",
"keywords": [
"inheritance",
"class",
"klass",
"oop",
"object-oriented",
"inherits",
"browser",
"browserify"
],
"license": "ISC",
"main": "./inherits.js",
"name": "inherits",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/inherits.git"
},
"scripts": {
"test": "tap"
},
"version": "2.0.4"
}

66
node_modules/pretty-bytes/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,66 @@
declare namespace prettyBytes {
interface Options {
/**
Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
@default false
*/
readonly signed?: boolean;
/**
- If `false`: Output won't be localized.
- If `true`: Localize the output using the system/browser locale.
- If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
__Note:__ Localization should generally work in browsers. Node.js needs to be [built](https://github.com/nodejs/node/wiki/Intl) with `full-icu` or `system-icu`. Alternatively, the [`full-icu`](https://github.com/unicode-org/full-icu-npm) module can be used to provide support at runtime.
@default false
*/
readonly locale?: boolean | string;
/**
Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
@default false
```
import prettyBytes = require('pretty-bytes');
prettyBytes(1337, {bits: true});
//=> '1.34 kbit'
```
*/
readonly bits?: boolean;
}
}
/**
Convert bytes to a human readable string: `1337` `1.34 kB`.
@param number - The number to format.
@example
```
import prettyBytes = require('pretty-bytes');
prettyBytes(1337);
//=> '1.34 kB'
prettyBytes(100);
//=> '100 B'
// Display file size differences
prettyBytes(42, {signed: true});
//=> '+42 B'
// Localized output using German locale
prettyBytes(1337, {locale: 'de'});
//=> '1,34 kB'
```
*/
declare function prettyBytes(
number: number,
options?: prettyBytes.Options
): string;
export = prettyBytes;

76
node_modules/pretty-bytes/index.js generated vendored Normal file
View File

@ -0,0 +1,76 @@
'use strict';
const BYTE_UNITS = [
'B',
'kB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB'
];
const BIT_UNITS = [
'b',
'kbit',
'Mbit',
'Gbit',
'Tbit',
'Pbit',
'Ebit',
'Zbit',
'Ybit'
];
/*
Formats the given number using `Number#toLocaleString`.
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
- If locale is true, the system default locale is used for translation.
- If no value for locale is specified, the number is returned unmodified.
*/
const toLocaleString = (number, locale) => {
let result = number;
if (typeof locale === 'string') {
result = number.toLocaleString(locale);
} else if (locale === true) {
result = number.toLocaleString();
}
return result;
};
module.exports = (number, options) => {
if (!Number.isFinite(number)) {
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
}
options = Object.assign({bits: false}, options);
const UNITS = options.bits ? BIT_UNITS : BYTE_UNITS;
if (options.signed && number === 0) {
return ' 0 ' + UNITS[0];
}
const isNegative = number < 0;
const prefix = isNegative ? '-' : (options.signed ? '+' : '');
if (isNegative) {
number = -number;
}
if (number < 1) {
const numberString = toLocaleString(number, options.locale);
return prefix + numberString + ' ' + UNITS[0];
}
const exponent = Math.min(Math.floor(Math.log10(number) / 3), UNITS.length - 1);
// eslint-disable-next-line unicorn/prefer-exponentiation-operator
number = Number((number / Math.pow(1000, exponent)).toPrecision(3));
const numberString = toLocaleString(number, options.locale);
const unit = UNITS[exponent];
return prefix + numberString + ' ' + unit;
};

9
node_modules/pretty-bytes/license generated vendored Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

76
node_modules/pretty-bytes/package.json generated vendored Normal file
View File

@ -0,0 +1,76 @@
{
"_from": "pretty-bytes@^5.3.0",
"_id": "pretty-bytes@5.3.0",
"_inBundle": false,
"_integrity": "sha512-hjGrh+P926p4R4WbaB6OckyRtO0F0/lQBiT+0gnxjV+5kjPBrfVBFCsCLbMqVQeydvIoouYTCmmEURiH3R1Bdg==",
"_location": "/pretty-bytes",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "pretty-bytes@^5.3.0",
"name": "pretty-bytes",
"escapedName": "pretty-bytes",
"rawSpec": "^5.3.0",
"saveSpec": null,
"fetchSpec": "^5.3.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz",
"_shasum": "f2849e27db79fb4d6cfe24764fc4134f165989f2",
"_spec": "pretty-bytes@^5.3.0",
"_where": "/Users/bret/repos/deploy-to-neocities",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/pretty-bytes/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Convert bytes to a human readable string: 1337 → 1.34 kB",
"devDependencies": {
"ava": "^1.4.1",
"full-icu": "^1.2.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/sindresorhus/pretty-bytes#readme",
"keywords": [
"pretty",
"bytes",
"byte",
"filesize",
"size",
"file",
"human",
"humanized",
"readable",
"si",
"data",
"locale",
"localization",
"localized"
],
"license": "MIT",
"name": "pretty-bytes",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/pretty-bytes.git"
},
"scripts": {
"test": "xo && NODE_ICU_DATA=node_modules/full-icu ava && tsd"
},
"version": "5.3.0"
}

89
node_modules/pretty-bytes/readme.md generated vendored Normal file
View File

@ -0,0 +1,89 @@
# pretty-bytes [![Build Status](https://travis-ci.org/sindresorhus/pretty-bytes.svg?branch=master)](https://travis-ci.org/sindresorhus/pretty-bytes)
> Convert bytes to a human readable string: `1337``1.34 kB`
Useful for displaying file sizes for humans.
*Note that it uses base-10 (e.g. kilobyte).
[Read about the difference between kilobyte and kibibyte.](https://web.archive.org/web/20150324153922/https://pacoup.com/2009/05/26/kb-kb-kib-whats-up-with-that/)*
## Install
```
$ npm install pretty-bytes
```
## Usage
```js
const prettyBytes = require('pretty-bytes');
prettyBytes(1337);
//=> '1.34 kB'
prettyBytes(100);
//=> '100 B'
// Display with units of bits
prettyBytes(1337, {bits: true});
//=> '1.34 kbit'
// Display file size differences
prettyBytes(42, {signed: true});
//=> '+42 B'
// Localized output using German locale
prettyBytes(1337, {locale: 'de'});
//=> '1,34 kB'
```
## API
### prettyBytes(number, [options])
#### number
Type: `number`
The number to format.
#### options
Type: `object`
##### signed
Type: `boolean`<br>
Default: `false`
Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
##### bits
Type: `boolean`<br>
Default: `false`
Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
##### locale
Type: `boolean` `string`<br>
Default: `false` *(No localization)*
- If `true`: Localize the output using the system/browser locale.
- If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
**Note:** Localization should generally work in browsers. Node.js needs to be [built](https://github.com/nodejs/node/wiki/Intl) with `full-icu` or `system-icu`. Alternatively, the [`full-icu`](https://github.com/unicode-org/full-icu-npm) module can be used to provide support at runtime.
## Related
- [pretty-bytes-cli](https://github.com/sindresorhus/pretty-bytes-cli) - CLI for this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

21
node_modules/pretty-time/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-present, Jon Schlinkert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

169
node_modules/pretty-time/README.md generated vendored Normal file
View File

@ -0,0 +1,169 @@
# pretty-time [![NPM version](https://img.shields.io/npm/v/pretty-time.svg?style=flat)](https://www.npmjs.com/package/pretty-time) [![NPM monthly downloads](https://img.shields.io/npm/dm/pretty-time.svg?style=flat)](https://npmjs.org/package/pretty-time) [![NPM total downloads](https://img.shields.io/npm/dt/pretty-time.svg?style=flat)](https://npmjs.org/package/pretty-time) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/pretty-time.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/pretty-time)
> Easily format the time from node.js `process.hrtime`. Works with timescales ranging from weeks to nanoseconds.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save pretty-time
```
## Usage
```js
var pretty = require('pretty-time');
var start = process.hrtime();
var time = process.hrtime(start);
console.log(pretty(time));
//=> 3μs
```
## API
By default, when no time increment is given as the second argument, the closest timescale is used (e.g. _most granular without being less than zero_).
**Examples:**
```js
pretty([1200708, 795428088]);
//=> '2w'
pretty([800708, 795428088]);
//=> '1w'
pretty([400708, 795428088]);
//=> '5d'
pretty([70708, 795428088]);
//=> '20h'
pretty([12708, 795428088]);
//=> '4h'
pretty([3708, 795428088]);
//=> '1h'
pretty([208, 795428088]);
//=> '3m'
pretty([20, 795428088]);
//=> '21s'
pretty([0, 795428088]);
//=> '795ms'
pretty([0, 000428088]);
//=> '428μs'
pretty([0, 000000088]);
//=> '88ns'
pretty([0, 000000018]);
//=> '18ns'
```
### Minimum time increment
_(All of the following examples use `[6740, 795428088]` as the hrtime array.)_
This value is passed as the second argument and determines how granular to make the time.
**Examples**
```js
pretty(time, 'h');
//=> '2h'
pretty(time, 'm');
//=> '1h 52m'
pretty(time, 's');
//=> '1h 52m 21s'
```
**Valid time increments**
Any of the following may be used:
* `ns` | `nano` | `nanosecond` | `nanoseconds`
* `μs` | `micro` | `microsecond` | `microseconds`
* `ms` | `milli` | `millisecond` | `milliseconds`
* `s` | `sec` | `second` | `seconds`
* `m` | `min` | `minute` | `minutes`
* `h` | `hr` | `hour` | `hours`
* `d` | `day` | `days`
* `w` | `wk` | `week` | `weeks`
## About
<details>
<summary><strong>Contributing</strong></summary>
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
</details>
<details>
<summary><strong>Running Tests</strong></summary>
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
</details>
<details>
<summary><strong>Building docs</strong></summary>
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
</details>
### Related projects
You might also be interested in these projects:
* [o-clock](https://www.npmjs.com/package/o-clock): Simple javascript utility for displaying the time in 12-hour clock format. | [homepage](https://github.com/jonschlinkert/o-clock "Simple javascript utility for displaying the time in 12-hour clock format.")
* [seconds](https://www.npmjs.com/package/seconds): Get the number of seconds for a minute, hour, day and week. | [homepage](https://github.com/jonschlinkert/seconds "Get the number of seconds for a minute, hour, day and week.")
* [time-stamp](https://www.npmjs.com/package/time-stamp): Get a formatted timestamp. | [homepage](https://github.com/jonschlinkert/time-stamp "Get a formatted timestamp.")
* [timescale](https://www.npmjs.com/package/timescale): Convert from one time scale to another. Nanosecond is the most atomic unit, week is… [more](https://github.com/jonschlinkert/timescale) | [homepage](https://github.com/jonschlinkert/timescale "Convert from one time scale to another. Nanosecond is the most atomic unit, week is the largest unit.")
* [week](https://www.npmjs.com/package/week): Get the current week number. | [homepage](https://github.com/datetime/week "Get the current week number.")
* [weekday](https://www.npmjs.com/package/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://github.com/datetime/weekday) | [homepage](https://github.com/datetime/weekday "Get the name and number of the current weekday. Or get the name of the weekday for a given number.")
* [year](https://www.npmjs.com/package/year): Simple utility to get the current year with 2 or 4 digits. | [homepage](https://github.com/jonschlinkert/year "Simple utility to get the current year with 2 or 4 digits.")
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 14 | [jonschlinkert](https://github.com/jonschlinkert) |
| 5 | [doowb](https://github.com/doowb) |
### Author
**Jon Schlinkert**
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
### License
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 12, 2018._

56
node_modules/pretty-time/index.js generated vendored Normal file
View File

@ -0,0 +1,56 @@
/*!
* pretty-time <https://github.com/jonschlinkert/pretty-time>
*
* Copyright (c) 2015-2018, present, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
const utils = require('./utils');
module.exports = (time, smallest, digits) => {
const isNumber = /^[0-9]+$/.test(time);
if (!isNumber && !Array.isArray(time)) {
throw new TypeError('expected an array or number in nanoseconds');
}
if (Array.isArray(time) && time.length !== 2) {
throw new TypeError('expected an array from process.hrtime()');
}
if (/^[0-9]+$/.test(smallest)) {
digits = smallest;
smallest = null;
}
let num = isNumber ? time : utils.nano(time);
let res = '';
let prev;
for (const uom of Object.keys(utils.scale)) {
const step = utils.scale[uom];
let inc = num / step;
if (smallest && utils.isSmallest(uom, smallest)) {
inc = utils.round(inc, digits);
if (prev && (inc === (prev / step))) --inc;
res += inc + uom;
return res.trim();
}
if (inc < 1) continue;
if (!smallest) {
inc = utils.round(inc, digits);
res += inc + uom;
return res;
}
prev = step;
inc = Math.floor(inc);
num -= (inc * step);
res += inc + uom + ' ';
}
return res.trim();
};

99
node_modules/pretty-time/package.json generated vendored Normal file
View File

@ -0,0 +1,99 @@
{
"_from": "pretty-time@^1.1.0",
"_id": "pretty-time@1.1.0",
"_inBundle": false,
"_integrity": "sha512-28iF6xPQrP8Oa6uxE6a1biz+lWeTOAPKggvjB8HAs6nVMKZwf5bG++632Dx614hIWgUPkgivRfG+a8uAXGTIbA==",
"_location": "/pretty-time",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "pretty-time@^1.1.0",
"name": "pretty-time",
"escapedName": "pretty-time",
"rawSpec": "^1.1.0",
"saveSpec": null,
"fetchSpec": "^1.1.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/pretty-time/-/pretty-time-1.1.0.tgz",
"_shasum": "ffb7429afabb8535c346a34e41873adf3d74dd0e",
"_spec": "pretty-time@^1.1.0",
"_where": "/Users/bret/repos/deploy-to-neocities",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/pretty-time/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Easily format the time from node.js `process.hrtime`. Works with timescales ranging from weeks to nanoseconds.",
"devDependencies": {
"gulp-format-md": "^1.0.0",
"mocha": "^3.5.3"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js",
"utils.js"
],
"homepage": "https://github.com/jonschlinkert/pretty-time",
"keywords": [
"convert",
"date",
"format",
"formatting",
"hour",
"hrtime",
"micro",
"milli",
"minute",
"nano",
"nanosecond",
"pretty",
"second",
"time",
"week"
],
"license": "MIT",
"main": "index.js",
"name": "pretty-time",
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/pretty-time.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"o-clock",
"seconds",
"time-stamp",
"timescale",
"week",
"weekday",
"year"
]
},
"lint": {
"reflinks": true
}
},
"version": "1.1.0"
}

32
node_modules/pretty-time/utils.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
exports.nano = time => +time[0] * 1e9 + +time[1];
exports.scale = {
'w': 6048e11,
'd': 864e11,
'h': 36e11,
'm': 6e10,
's': 1e9,
'ms': 1e6,
'μs': 1e3,
'ns': 1,
};
exports.regex = {
'w': /^(w((ee)?k)?s?)$/,
'd': /^(d(ay)?s?)$/,
'h': /^(h((ou)?r)?s?)$/,
'm': /^(min(ute)?s?|m)$/,
's': /^((sec(ond)?)s?|s)$/,
'ms': /^(milli(second)?s?|ms)$/,
'μs': /^(micro(second)?s?|μs)$/,
'ns': /^(nano(second)?s?|ns?)$/,
};
exports.isSmallest = function(uom, unit) {
return exports.regex[uom].test(unit);
};
exports.round = function(num, digits) {
const n = Math.abs(num);
return /[0-9]/.test(digits) ? n.toFixed(digits) : Math.round(n);
};

7
node_modules/pumpify/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,7 @@
language: node_js
node_js:
- '10'
- '12'
sudo: false

21
node_modules/pumpify/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Mathias Buus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

56
node_modules/pumpify/README.md generated vendored Normal file
View File

@ -0,0 +1,56 @@
# pumpify
Combine an array of streams into a single duplex stream using [pump](https://github.com/mafintosh/pump) and [duplexify](https://github.com/mafintosh/duplexify).
If one of the streams closes/errors all streams in the pipeline will be destroyed.
```
npm install pumpify
```
[![build status](http://img.shields.io/travis/mafintosh/pumpify.svg?style=flat)](http://travis-ci.org/mafintosh/pumpify)
## Usage
Pass the streams you want to pipe together to pumpify `pipeline = pumpify(s1, s2, s3, ...)`.
`pipeline` is a duplex stream that writes to the first streams and reads from the last one.
Streams are piped together using [pump](https://github.com/mafintosh/pump) so if one of them closes
all streams will be destroyed.
``` js
var pumpify = require('pumpify')
var tar = require('tar-fs')
var zlib = require('zlib')
var fs = require('fs')
var untar = pumpify(zlib.createGunzip(), tar.extract('output-folder'))
// you can also pass an array instead
// var untar = pumpify([zlib.createGunzip(), tar.extract('output-folder')])
fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar)
```
If you are pumping object streams together use `pipeline = pumpify.obj(s1, s2, ...)`.
Call `pipeline.destroy()` to destroy the pipeline (including the streams passed to pumpify).
### Using `setPipeline(s1, s2, ...)`
Similar to [duplexify](https://github.com/mafintosh/duplexify) you can also define the pipeline asynchronously using `setPipeline(s1, s2, ...)`
``` js
var untar = pumpify()
setTimeout(function() {
// will start draining the input now
untar.setPipeline(zlib.createGunzip(), tar.extract('output-folder'))
}, 1000)
fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar)
```
## License
MIT
## Related
`pumpify` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.

60
node_modules/pumpify/index.js generated vendored Normal file
View File

@ -0,0 +1,60 @@
var pump = require('pump')
var inherits = require('inherits')
var Duplexify = require('duplexify')
var toArray = function(args) {
if (!args.length) return []
return Array.isArray(args[0]) ? args[0] : Array.prototype.slice.call(args)
}
var define = function(opts) {
var Pumpify = function() {
var streams = toArray(arguments)
if (!(this instanceof Pumpify)) return new Pumpify(streams)
Duplexify.call(this, null, null, opts)
if (streams.length) this.setPipeline(streams)
}
inherits(Pumpify, Duplexify)
Pumpify.prototype.setPipeline = function() {
var streams = toArray(arguments)
var self = this
var ended = false
var w = streams[0]
var r = streams[streams.length-1]
r = r.readable ? r : null
w = w.writable ? w : null
var onclose = function() {
streams[0].emit('error', new Error('stream was destroyed'))
}
this.on('close', onclose)
this.on('prefinish', function() {
if (!ended) self.cork()
})
pump(streams, function(err) {
self.removeListener('close', onclose)
if (err) return self.destroy(err.message === 'premature close' ? null : err)
ended = true
// pump ends after the last stream is not writable *but*
// pumpify still forwards the readable part so we need to catch errors
// still, so reenable autoDestroy in this case
if (self._autoDestroy === false) self._autoDestroy = true
self.uncork()
})
if (this.destroyed) return onclose()
this.setWritable(w)
this.setReadable(r)
}
return Pumpify
}
module.exports = define({autoDestroy:false, destroy:false})
module.exports.obj = define({autoDestroy: false, destroy:false, objectMode:true, highWaterMark:16})
module.exports.ctor = define

64
node_modules/pumpify/package.json generated vendored Normal file
View File

@ -0,0 +1,64 @@
{
"_from": "pumpify@^2.0.1",
"_id": "pumpify@2.0.1",
"_inBundle": false,
"_integrity": "sha512-m7KOje7jZxrmutanlkS1daj1dS6z6BgslzOXmcSEpIlCxM3VJH7lG5QLeck/6hgF6F4crFf01UtQmNsJfweTAw==",
"_location": "/pumpify",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "pumpify@^2.0.1",
"name": "pumpify",
"escapedName": "pumpify",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/async-neocities"
],
"_resolved": "https://registry.npmjs.org/pumpify/-/pumpify-2.0.1.tgz",
"_shasum": "abfc7b5a621307c728b551decbbefb51f0e4aa1e",
"_spec": "pumpify@^2.0.1",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/async-neocities",
"author": {
"name": "Mathias Buus"
},
"bugs": {
"url": "https://github.com/mafintosh/pumpify/issues"
},
"bundleDependencies": false,
"dependencies": {
"duplexify": "^4.1.1",
"inherits": "^2.0.3",
"pump": "^3.0.0"
},
"deprecated": false,
"description": "Combine an array of streams into a single duplex stream using pump and duplexify",
"devDependencies": {
"tape": "^4.10.2",
"through2": "^3.0.1"
},
"homepage": "https://github.com/mafintosh/pumpify",
"keywords": [
"pump",
"duplexify",
"duplex",
"streams",
"stream",
"pipeline",
"combine"
],
"license": "MIT",
"main": "index.js",
"name": "pumpify",
"repository": {
"type": "git",
"url": "git://github.com/mafintosh/pumpify.git"
},
"scripts": {
"test": "tape test.js"
},
"version": "2.0.1"
}

238
node_modules/pumpify/test.js generated vendored Normal file
View File

@ -0,0 +1,238 @@
var tape = require('tape')
var through = require('through2')
var pumpify = require('./')
var stream = require('stream')
var duplexify = require('duplexify')
tape('basic', function(t) {
t.plan(3)
var pipeline = pumpify(
through(function(data, enc, cb) {
t.same(data.toString(), 'hello')
cb(null, data.toString().toUpperCase())
}),
through(function(data, enc, cb) {
t.same(data.toString(), 'HELLO')
cb(null, data.toString().toLowerCase())
})
)
pipeline.write('hello')
pipeline.on('data', function(data) {
t.same(data.toString(), 'hello')
t.end()
})
})
tape('3 times', function(t) {
t.plan(4)
var pipeline = pumpify(
through(function(data, enc, cb) {
t.same(data.toString(), 'hello')
cb(null, data.toString().toUpperCase())
}),
through(function(data, enc, cb) {
t.same(data.toString(), 'HELLO')
cb(null, data.toString().toLowerCase())
}),
through(function(data, enc, cb) {
t.same(data.toString(), 'hello')
cb(null, data.toString().toUpperCase())
})
)
pipeline.write('hello')
pipeline.on('data', function(data) {
t.same(data.toString(), 'HELLO')
t.end()
})
})
tape('destroy', function(t) {
var test = through()
test.destroy = function() {
t.ok(true)
t.end()
}
var pipeline = pumpify(through(), test)
pipeline.destroy()
})
tape('close', function(t) {
var test = through()
var pipeline = pumpify(through(), test)
pipeline.on('error', function(err) {
t.same(err.message, 'lol')
t.end()
})
test.emit('error', new Error('lol'))
})
tape('end waits for last one', function(t) {
var ran = false
var a = through()
var b = through()
var c = through(function(data, enc, cb) {
setTimeout(function() {
ran = true
cb()
}, 100)
})
var pipeline = pumpify(a, b, c)
pipeline.write('foo')
pipeline.end(function() {
t.ok(ran)
t.end()
})
t.ok(!ran)
})
tape('always wait for finish', function(t) {
var a = new stream.Readable()
a._read = function() {}
a.push('hello')
var pipeline = pumpify(a, through(), through())
var ran = false
pipeline.on('finish', function() {
t.ok(ran)
t.end()
})
setTimeout(function() {
ran = true
a.push(null)
}, 100)
})
tape('async', function(t) {
var pipeline = pumpify()
t.plan(4)
pipeline.write('hello')
pipeline.on('data', function(data) {
t.same(data.toString(), 'HELLO')
t.end()
})
setTimeout(function() {
pipeline.setPipeline(
through(function(data, enc, cb) {
t.same(data.toString(), 'hello')
cb(null, data.toString().toUpperCase())
}),
through(function(data, enc, cb) {
t.same(data.toString(), 'HELLO')
cb(null, data.toString().toLowerCase())
}),
through(function(data, enc, cb) {
t.same(data.toString(), 'hello')
cb(null, data.toString().toUpperCase())
})
)
}, 100)
})
tape('early destroy', function(t) {
var a = through()
var b = through()
var c = through()
b.destroy = function() {
t.ok(true)
t.end()
}
var pipeline = pumpify()
pipeline.destroy()
setTimeout(function() {
pipeline.setPipeline(a, b, c)
}, 100)
})
tape('preserves error', function (t) {
var a = through()
var b = through(function (data, enc, cb) {
cb(new Error('stop'))
})
var c = through()
var s = pumpify()
s.on('error', function (err) {
t.same(err.message, 'stop')
t.end()
})
s.setPipeline(a, b, c)
s.resume()
s.write('hi')
})
tape('preserves error again', function (t) {
var ws = new stream.Writable()
var rs = new stream.Readable({highWaterMark: 16})
ws._write = function (data, enc, cb) {
cb(null)
}
var once = true
rs._read = function () {
process.nextTick(function () {
if (!once) return
once = false
rs.push('hello world')
})
}
var pumpifyErr = pumpify(
through(),
through(function(chunk, _, cb) {
cb(new Error('test'))
}),
ws
)
rs.pipe(pumpifyErr)
.on('error', function (err) {
t.ok(err)
t.ok(err.message !== 'premature close', 'does not close with premature close')
t.end()
})
})
tape('returns error from duplexify', function (t) {
var a = through()
var b = duplexify()
var s = pumpify()
s.setPipeline(a, b)
s.on('error', function (err) {
t.same(err.message, 'stop')
t.end()
})
s.write('data')
// Test passes if `.end()` is not called
s.end()
b.setWritable(through())
setImmediate(function () {
b.destroy(new Error('stop'))
})
})

38
node_modules/readable-stream/CONTRIBUTING.md generated vendored Normal file
View File

@ -0,0 +1,38 @@
# Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
* (a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
* (b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
* (c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
* (d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
## Moderation Policy
The [Node.js Moderation Policy] applies to this WG.
## Code of Conduct
The [Node.js Code of Conduct][] applies to this WG.
[Node.js Code of Conduct]:
https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
[Node.js Moderation Policy]:
https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md

136
node_modules/readable-stream/GOVERNANCE.md generated vendored Normal file
View File

@ -0,0 +1,136 @@
### Streams Working Group
The Node.js Streams is jointly governed by a Working Group
(WG)
that is responsible for high-level guidance of the project.
The WG has final authority over this project including:
* Technical direction
* Project governance and process (including this policy)
* Contribution policy
* GitHub repository hosting
* Conduct guidelines
* Maintaining the list of additional Collaborators
For the current list of WG members, see the project
[README.md](./README.md#current-project-team-members).
### Collaborators
The readable-stream GitHub repository is
maintained by the WG and additional Collaborators who are added by the
WG on an ongoing basis.
Individuals making significant and valuable contributions are made
Collaborators and given commit-access to the project. These
individuals are identified by the WG and their addition as
Collaborators is discussed during the WG meeting.
_Note:_ If you make a significant contribution and are not considered
for commit-access log an issue or contact a WG member directly and it
will be brought up in the next WG meeting.
Modifications of the contents of the readable-stream repository are
made on
a collaborative basis. Anybody with a GitHub account may propose a
modification via pull request and it will be considered by the project
Collaborators. All pull requests must be reviewed and accepted by a
Collaborator with sufficient expertise who is able to take full
responsibility for the change. In the case of pull requests proposed
by an existing Collaborator, an additional Collaborator is required
for sign-off. Consensus should be sought if additional Collaborators
participate and there is disagreement around a particular
modification. See _Consensus Seeking Process_ below for further detail
on the consensus model used for governance.
Collaborators may opt to elevate significant or controversial
modifications, or modifications that have not found consensus to the
WG for discussion by assigning the ***WG-agenda*** tag to a pull
request or issue. The WG should serve as the final arbiter where
required.
For the current list of Collaborators, see the project
[README.md](./README.md#members).
### WG Membership
WG seats are not time-limited. There is no fixed size of the WG.
However, the expected target is between 6 and 12, to ensure adequate
coverage of important areas of expertise, balanced with the ability to
make decisions efficiently.
There is no specific set of requirements or qualifications for WG
membership beyond these rules.
The WG may add additional members to the WG by unanimous consensus.
A WG member may be removed from the WG by voluntary resignation, or by
unanimous consensus of all other WG members.
Changes to WG membership should be posted in the agenda, and may be
suggested as any other agenda item (see "WG Meetings" below).
If an addition or removal is proposed during a meeting, and the full
WG is not in attendance to participate, then the addition or removal
is added to the agenda for the subsequent meeting. This is to ensure
that all members are given the opportunity to participate in all
membership decisions. If a WG member is unable to attend a meeting
where a planned membership decision is being made, then their consent
is assumed.
No more than 1/3 of the WG members may be affiliated with the same
employer. If removal or resignation of a WG member, or a change of
employment by a WG member, creates a situation where more than 1/3 of
the WG membership shares an employer, then the situation must be
immediately remedied by the resignation or removal of one or more WG
members affiliated with the over-represented employer(s).
### WG Meetings
The WG meets occasionally on a Google Hangout On Air. A designated moderator
approved by the WG runs the meeting. Each meeting should be
published to YouTube.
Items are added to the WG agenda that are considered contentious or
are modifications of governance, contribution policy, WG membership,
or release process.
The intention of the agenda is not to approve or review all patches;
that should happen continuously on GitHub and be handled by the larger
group of Collaborators.
Any community member or contributor can ask that something be added to
the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
WG member or the moderator can add the item to the agenda by adding
the ***WG-agenda*** tag to the issue.
Prior to each WG meeting the moderator will share the Agenda with
members of the WG. WG members can add any items they like to the
agenda at the beginning of each meeting. The moderator and the WG
cannot veto or remove items.
The WG may invite persons or representatives from certain projects to
participate in a non-voting capacity.
The moderator is responsible for summarizing the discussion of each
agenda item and sends it as a pull request after the meeting.
### Consensus Seeking Process
The WG follows a
[Consensus
Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
decision-making model.
When an agenda item has appeared to reach a consensus the moderator
will ask "Does anyone object?" as a final call for dissent from the
consensus.
If an agenda item cannot reach a consensus a WG member can call for
either a closing vote or a vote to table the issue to the next
meeting. The call for a vote must be seconded by a majority of the WG
or else the discussion will continue. Simple majority wins.
Note that changes to WG membership require a majority consensus. See
"WG Membership" above.

47
node_modules/readable-stream/LICENSE generated vendored Normal file
View File

@ -0,0 +1,47 @@
Node.js is licensed for use as follows:
"""
Copyright Node.js contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:
"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""

106
node_modules/readable-stream/README.md generated vendored Normal file
View File

@ -0,0 +1,106 @@
# readable-stream
***Node.js core streams for userland*** [![Build Status](https://travis-ci.com/nodejs/readable-stream.svg?branch=master)](https://travis-ci.com/nodejs/readable-stream)
[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)
[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/readabe-stream.svg)](https://saucelabs.com/u/readabe-stream)
```bash
npm install --save readable-stream
```
This package is a mirror of the streams implementations in Node.js.
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.18.1/docs/api/stream.html).
If you want to guarantee a stable streams base, regardless of what version of
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
As of version 2.0.0 **readable-stream** uses semantic versioning.
## Version 3.x.x
v3.x.x of `readable-stream` is a cut from Node 10. This version supports Node 6, 8, and 10, as well as evergreen browsers, IE 11 and latest Safari. The breaking changes introduced by v3 are composed by the combined breaking changes in [Node v9](https://nodejs.org/en/blog/release/v9.0.0/) and [Node v10](https://nodejs.org/en/blog/release/v10.0.0/), as follows:
1. Error codes: https://github.com/nodejs/node/pull/13310,
https://github.com/nodejs/node/pull/13291,
https://github.com/nodejs/node/pull/16589,
https://github.com/nodejs/node/pull/15042,
https://github.com/nodejs/node/pull/15665,
https://github.com/nodejs/readable-stream/pull/344
2. 'readable' have precedence over flowing
https://github.com/nodejs/node/pull/18994
3. make virtual methods errors consistent
https://github.com/nodejs/node/pull/18813
4. updated streams error handling
https://github.com/nodejs/node/pull/18438
5. writable.end should return this.
https://github.com/nodejs/node/pull/18780
6. readable continues to read when push('')
https://github.com/nodejs/node/pull/18211
7. add custom inspect to BufferList
https://github.com/nodejs/node/pull/17907
8. always defer 'readable' with nextTick
https://github.com/nodejs/node/pull/17979
## Version 2.x.x
v2.x.x of `readable-stream` is a cut of the stream module from Node 8 (there have been no semver-major changes from Node 4 to 8). This version supports all Node.js versions from 0.8, as well as evergreen browsers and IE 10 & 11.
### Big Thanks
Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][sauce]
# Usage
You can swap your `require('stream')` with `require('readable-stream')`
without any changes, if you are just using one of the main classes and
functions.
```js
const {
Readable,
Writable,
Transform,
Duplex,
pipeline,
finished
} = require('readable-stream')
````
Note that `require('stream')` will return `Stream`, while
`require('readable-stream')` will return `Readable`. We discourage using
whatever is exported directly, but rather use one of the properties as
shown in the example above.
# Streams Working Group
`readable-stream` is maintained by the Streams Working Group, which
oversees the development and maintenance of the Streams API within
Node.js. The responsibilities of the Streams Working Group include:
* Addressing stream issues on the Node.js issue tracker.
* Authoring and editing stream documentation within the Node.js project.
* Reviewing changes to stream subclasses within the Node.js project.
* Redirecting changes to streams from the Node.js project to this
project.
* Assisting in the implementation of stream providers within Node.js.
* Recommending versions of `readable-stream` to be included in Node.js.
* Messaging about the future of streams to give the community advance
notice of changes.
<a name="members"></a>
## Team Members
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) &lt;calvin.metcalf@gmail.com&gt;
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) &lt;mathiasbuus@gmail.com&gt;
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) &lt;matteo.collina@gmail.com&gt;
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) &lt;shestak.irina@gmail.com&gt;
* **Yoshua Wyuts** ([@yoshuawuyts](https://github.com/yoshuawuyts)) &lt;yoshuawuyts@gmail.com&gt;
[sauce]: https://saucelabs.com

127
node_modules/readable-stream/errors-browser.js generated vendored Normal file
View File

@ -0,0 +1,127 @@
'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var codes = {};
function createErrorType(code, message, Base) {
if (!Base) {
Base = Error;
}
function getMessage(arg1, arg2, arg3) {
if (typeof message === 'string') {
return message;
} else {
return message(arg1, arg2, arg3);
}
}
var NodeError =
/*#__PURE__*/
function (_Base) {
_inheritsLoose(NodeError, _Base);
function NodeError(arg1, arg2, arg3) {
return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
}
return NodeError;
}(Base);
NodeError.prototype.name = Base.name;
NodeError.prototype.code = code;
codes[code] = NodeError;
} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
function oneOf(expected, thing) {
if (Array.isArray(expected)) {
var len = expected.length;
expected = expected.map(function (i) {
return String(i);
});
if (len > 2) {
return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
} else if (len === 2) {
return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
} else {
return "of ".concat(thing, " ").concat(expected[0]);
}
} else {
return "of ".concat(thing, " ").concat(String(expected));
}
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
function startsWith(str, search, pos) {
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
function endsWith(str, search, this_len) {
if (this_len === undefined || this_len > str.length) {
this_len = str.length;
}
return str.substring(this_len - search.length, this_len) === search;
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
function includes(str, search, start) {
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > str.length) {
return false;
} else {
return str.indexOf(search, start) !== -1;
}
}
createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
return 'The value "' + value + '" is invalid for option "' + name + '"';
}, TypeError);
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
// determiner: 'must be' or 'must not be'
var determiner;
if (typeof expected === 'string' && startsWith(expected, 'not ')) {
determiner = 'must not be';
expected = expected.replace(/^not /, '');
} else {
determiner = 'must be';
}
var msg;
if (endsWith(name, ' argument')) {
// For cases like 'first argument'
msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
} else {
var type = includes(name, '.') ? 'property' : 'argument';
msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
}
msg += ". Received type ".concat(typeof actual);
return msg;
}, TypeError);
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
return 'The ' + name + ' method is not implemented';
});
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
createErrorType('ERR_STREAM_DESTROYED', function (name) {
return 'Cannot call ' + name + ' after a stream was destroyed';
});
createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
return 'Unknown encoding: ' + arg;
}, TypeError);
createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
module.exports.codes = codes;

116
node_modules/readable-stream/errors.js generated vendored Normal file
View File

@ -0,0 +1,116 @@
'use strict';
const codes = {};
function createErrorType(code, message, Base) {
if (!Base) {
Base = Error
}
function getMessage (arg1, arg2, arg3) {
if (typeof message === 'string') {
return message
} else {
return message(arg1, arg2, arg3)
}
}
class NodeError extends Base {
constructor (arg1, arg2, arg3) {
super(getMessage(arg1, arg2, arg3));
}
}
NodeError.prototype.name = Base.name;
NodeError.prototype.code = code;
codes[code] = NodeError;
}
// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
function oneOf(expected, thing) {
if (Array.isArray(expected)) {
const len = expected.length;
expected = expected.map((i) => String(i));
if (len > 2) {
return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
expected[len - 1];
} else if (len === 2) {
return `one of ${thing} ${expected[0]} or ${expected[1]}`;
} else {
return `of ${thing} ${expected[0]}`;
}
} else {
return `of ${thing} ${String(expected)}`;
}
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
function startsWith(str, search, pos) {
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
function endsWith(str, search, this_len) {
if (this_len === undefined || this_len > str.length) {
this_len = str.length;
}
return str.substring(this_len - search.length, this_len) === search;
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
function includes(str, search, start) {
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > str.length) {
return false;
} else {
return str.indexOf(search, start) !== -1;
}
}
createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
return 'The value "' + value + '" is invalid for option "' + name + '"'
}, TypeError);
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
// determiner: 'must be' or 'must not be'
let determiner;
if (typeof expected === 'string' && startsWith(expected, 'not ')) {
determiner = 'must not be';
expected = expected.replace(/^not /, '');
} else {
determiner = 'must be';
}
let msg;
if (endsWith(name, ' argument')) {
// For cases like 'first argument'
msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
} else {
const type = includes(name, '.') ? 'property' : 'argument';
msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
}
msg += `. Received type ${typeof actual}`;
return msg;
}, TypeError);
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
return 'The ' + name + ' method is not implemented'
});
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
createErrorType('ERR_STREAM_DESTROYED', function (name) {
return 'Cannot call ' + name + ' after a stream was destroyed';
});
createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
return 'Unknown encoding: ' + arg
}, TypeError);
createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
module.exports.codes = codes;

17
node_modules/readable-stream/experimentalWarning.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
'use strict'
var experimentalWarnings = new Set();
function emitExperimentalWarning(feature) {
if (experimentalWarnings.has(feature)) return;
var msg = feature + ' is an experimental feature. This feature could ' +
'change at any time';
experimentalWarnings.add(feature);
process.emitWarning(msg, 'ExperimentalWarning');
}
function noop() {}
module.exports.emitExperimentalWarning = process.emitWarning
? emitExperimentalWarning
: noop;

139
node_modules/readable-stream/lib/_stream_duplex.js generated vendored Normal file
View File

@ -0,0 +1,139 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
// Writable.
'use strict';
/*<replacement>*/
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
keys.push(key);
}
return keys;
};
/*</replacement>*/
module.exports = Duplex;
var Readable = require('./_stream_readable');
var Writable = require('./_stream_writable');
require('inherits')(Duplex, Readable);
{
// Allow the keys array to be GC'ed.
var keys = objectKeys(Writable.prototype);
for (var v = 0; v < keys.length; v++) {
var method = keys[v];
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
}
}
function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
Readable.call(this, options);
Writable.call(this, options);
this.allowHalfOpen = true;
if (options) {
if (options.readable === false) this.readable = false;
if (options.writable === false) this.writable = false;
if (options.allowHalfOpen === false) {
this.allowHalfOpen = false;
this.once('end', onend);
}
}
}
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
return this._writableState.highWaterMark;
}
});
Object.defineProperty(Duplex.prototype, 'writableBuffer', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
return this._writableState && this._writableState.getBuffer();
}
});
Object.defineProperty(Duplex.prototype, 'writableLength', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
return this._writableState.length;
}
}); // the no-half-open enforcer
function onend() {
// If the writable side ended, then we're ok.
if (this._writableState.ended) return; // no more data can be written.
// But allow more writes to happen in this tick.
process.nextTick(onEndNT, this);
}
function onEndNT(self) {
self.end();
}
Object.defineProperty(Duplex.prototype, 'destroyed', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
if (this._readableState === undefined || this._writableState === undefined) {
return false;
}
return this._readableState.destroyed && this._writableState.destroyed;
},
set: function set(value) {
// we ignore the value if the stream
// has not been initialized yet
if (this._readableState === undefined || this._writableState === undefined) {
return;
} // backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
});

View File

@ -0,0 +1,39 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// a passthrough stream.
// basically just the most minimal sort of Transform stream.
// Every written chunk gets output as-is.
'use strict';
module.exports = PassThrough;
var Transform = require('./_stream_transform');
require('inherits')(PassThrough, Transform);
function PassThrough(options) {
if (!(this instanceof PassThrough)) return new PassThrough(options);
Transform.call(this, options);
}
PassThrough.prototype._transform = function (chunk, encoding, cb) {
cb(null, chunk);
};

1124
node_modules/readable-stream/lib/_stream_readable.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

201
node_modules/readable-stream/lib/_stream_transform.js generated vendored Normal file
View File

@ -0,0 +1,201 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// a transform stream is a readable/writable stream where you do
// something with the data. Sometimes it's called a "filter",
// but that's not a great name for it, since that implies a thing where
// some bits pass through, and others are simply ignored. (That would
// be a valid example of a transform, of course.)
//
// While the output is causally related to the input, it's not a
// necessarily symmetric or synchronous transformation. For example,
// a zlib stream might take multiple plain-text writes(), and then
// emit a single compressed chunk some time in the future.
//
// Here's how this works:
//
// The Transform stream has all the aspects of the readable and writable
// stream classes. When you write(chunk), that calls _write(chunk,cb)
// internally, and returns false if there's a lot of pending writes
// buffered up. When you call read(), that calls _read(n) until
// there's enough pending readable data buffered up.
//
// In a transform stream, the written data is placed in a buffer. When
// _read(n) is called, it transforms the queued up data, calling the
// buffered _write cb's as it consumes chunks. If consuming a single
// written chunk would result in multiple output chunks, then the first
// outputted bit calls the readcb, and subsequent chunks just go into
// the read buffer, and will cause it to emit 'readable' if necessary.
//
// This way, back-pressure is actually determined by the reading side,
// since _read has to be called to start processing a new chunk. However,
// a pathological inflate type of transform can cause excessive buffering
// here. For example, imagine a stream where every byte of input is
// interpreted as an integer from 0-255, and then results in that many
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
// 1kb of data being output. In this case, you could write a very small
// amount of input, and end up with a very large amount of output. In
// such a pathological inflating mechanism, there'd be no way to tell
// the system to stop doing the transform. A single 4MB write could
// cause the system to run out of memory.
//
// However, even in such a pathological case, only a single written chunk
// would be consumed, and then the rest would wait (un-transformed) until
// the results of the previous transformed chunk were consumed.
'use strict';
module.exports = Transform;
var _require$codes = require('../errors').codes,
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
var Duplex = require('./_stream_duplex');
require('inherits')(Transform, Duplex);
function afterTransform(er, data) {
var ts = this._transformState;
ts.transforming = false;
var cb = ts.writecb;
if (cb === null) {
return this.emit('error', new ERR_MULTIPLE_CALLBACK());
}
ts.writechunk = null;
ts.writecb = null;
if (data != null) // single equals check for both `null` and `undefined`
this.push(data);
cb(er);
var rs = this._readableState;
rs.reading = false;
if (rs.needReadable || rs.length < rs.highWaterMark) {
this._read(rs.highWaterMark);
}
}
function Transform(options) {
if (!(this instanceof Transform)) return new Transform(options);
Duplex.call(this, options);
this._transformState = {
afterTransform: afterTransform.bind(this),
needTransform: false,
transforming: false,
writecb: null,
writechunk: null,
writeencoding: null
}; // start out asking for a readable event once data is transformed.
this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
// that Readable wants before the first _read call, so unset the
// sync guard flag.
this._readableState.sync = false;
if (options) {
if (typeof options.transform === 'function') this._transform = options.transform;
if (typeof options.flush === 'function') this._flush = options.flush;
} // When the writable side finishes, then flush out anything remaining.
this.on('prefinish', prefinish);
}
function prefinish() {
var _this = this;
if (typeof this._flush === 'function' && !this._readableState.destroyed) {
this._flush(function (er, data) {
done(_this, er, data);
});
} else {
done(this, null, null);
}
}
Transform.prototype.push = function (chunk, encoding) {
this._transformState.needTransform = false;
return Duplex.prototype.push.call(this, chunk, encoding);
}; // This is the part where you do stuff!
// override this function in implementation classes.
// 'chunk' is an input chunk.
//
// Call `push(newChunk)` to pass along transformed output
// to the readable side. You may call 'push' zero or more times.
//
// Call `cb(err)` when you are done with this chunk. If you pass
// an error, then that'll put the hurt on the whole operation. If you
// never call cb(), then you'll never get another chunk.
Transform.prototype._transform = function (chunk, encoding, cb) {
cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
};
Transform.prototype._write = function (chunk, encoding, cb) {
var ts = this._transformState;
ts.writecb = cb;
ts.writechunk = chunk;
ts.writeencoding = encoding;
if (!ts.transforming) {
var rs = this._readableState;
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
}
}; // Doesn't matter what the args are here.
// _transform does all the work.
// That we got here means that the readable side wants more data.
Transform.prototype._read = function (n) {
var ts = this._transformState;
if (ts.writechunk !== null && !ts.transforming) {
ts.transforming = true;
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
} else {
// mark that we need a transform, so that any data that comes in
// will get processed, now that we've asked for it.
ts.needTransform = true;
}
};
Transform.prototype._destroy = function (err, cb) {
Duplex.prototype._destroy.call(this, err, function (err2) {
cb(err2);
});
};
function done(stream, er, data) {
if (er) return stream.emit('error', er);
if (data != null) // single equals check for both `null` and `undefined`
stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
// if there's nothing in the write buffer, then that means
// that nothing more will ever be provided
if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
return stream.push(null);
}

697
node_modules/readable-stream/lib/_stream_writable.js generated vendored Normal file
View File

@ -0,0 +1,697 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// A bit simpler than readable streams.
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
// the drain event emission and buffering.
'use strict';
module.exports = Writable;
/* <replacement> */
function WriteReq(chunk, encoding, cb) {
this.chunk = chunk;
this.encoding = encoding;
this.callback = cb;
this.next = null;
} // It seems a linked list but it is not
// there will be only 2 of these for each stream
function CorkedRequest(state) {
var _this = this;
this.next = null;
this.entry = null;
this.finish = function () {
onCorkedFinish(_this, state);
};
}
/* </replacement> */
/*<replacement>*/
var Duplex;
/*</replacement>*/
Writable.WritableState = WritableState;
/*<replacement>*/
var internalUtil = {
deprecate: require('util-deprecate')
};
/*</replacement>*/
/*<replacement>*/
var Stream = require('./internal/streams/stream');
/*</replacement>*/
var Buffer = require('buffer').Buffer;
var OurUint8Array = global.Uint8Array || function () {};
function _uint8ArrayToBuffer(chunk) {
return Buffer.from(chunk);
}
function _isUint8Array(obj) {
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}
var destroyImpl = require('./internal/streams/destroy');
var _require = require('./internal/streams/state'),
getHighWaterMark = _require.getHighWaterMark;
var _require$codes = require('../errors').codes,
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
var errorOrDestroy = destroyImpl.errorOrDestroy;
require('inherits')(Writable, Stream);
function nop() {}
function WritableState(options, stream, isDuplex) {
Duplex = Duplex || require('./_stream_duplex');
options = options || {}; // Duplex streams are both readable and writable, but share
// the same options object.
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream,
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
// contains buffers or objects.
this.objectMode = !!options.objectMode;
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
// Note: 0 is a valid value, means that we always return false if
// the entire buffer is not flushed immediately on write()
this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called
this.finalCalled = false; // drain event flag.
this.needDrain = false; // at the start of calling end()
this.ending = false; // when end() has been called, and returned
this.ended = false; // when 'finish' is emitted
this.finished = false; // has it been destroyed
this.destroyed = false; // should we decode strings into buffers before passing to _write?
// this is here so that some node-core streams can optimize string
// handling at a lower level.
var noDecode = options.decodeStrings === false;
this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
// encoding is 'binary' so we have to make this configurable.
// Everything else in the universe uses 'utf8', though.
this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
// of how much we're waiting to get pushed to some underlying
// socket or file.
this.length = 0; // a flag to see when we're in the middle of a write.
this.writing = false; // when true all writes will be buffered until .uncork() call
this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
// or on a later tick. We set this to true at first, because any
// actions that shouldn't happen until "later" should generally also
// not happen before the first write call.
this.sync = true; // a flag to know if we're processing previously buffered items, which
// may call the _write() callback in the same tick, so that we don't
// end up in an overlapped onwrite situation.
this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
this.onwrite = function (er) {
onwrite(stream, er);
}; // the callback that the user supplies to write(chunk,encoding,cb)
this.writecb = null; // the amount that is being written when _write is called.
this.writelen = 0;
this.bufferedRequest = null;
this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
// this must be 0 before 'finish' can be emitted
this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
// This is relevant for synchronous Transform streams
this.prefinished = false; // True if the error was already emitted and should not be thrown again
this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
this.autoDestroy = !!options.autoDestroy; // count buffered requests
this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
// one allocated and free to use, and we maintain at most two
this.corkedRequestsFree = new CorkedRequest(this);
}
WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest;
var out = [];
while (current) {
out.push(current);
current = current.next;
}
return out;
};
(function () {
try {
Object.defineProperty(WritableState.prototype, 'buffer', {
get: internalUtil.deprecate(function writableStateBufferGetter() {
return this.getBuffer();
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
});
} catch (_) {}
})(); // Test _writableState for inheritance to account for Duplex streams,
// whose prototype chain only points to Readable.
var realHasInstance;
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
realHasInstance = Function.prototype[Symbol.hasInstance];
Object.defineProperty(Writable, Symbol.hasInstance, {
value: function value(object) {
if (realHasInstance.call(this, object)) return true;
if (this !== Writable) return false;
return object && object._writableState instanceof WritableState;
}
});
} else {
realHasInstance = function realHasInstance(object) {
return object instanceof this;
};
}
function Writable(options) {
Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.
// `realHasInstance` is necessary because using plain `instanceof`
// would return false, as no `_writableState` property is attached.
// Trying to use the custom `instanceof` for Writable here will also break the
// Node.js LazyTransform implementation, which has a non-trivial getter for
// `_writableState` that would lead to infinite recursion.
// Checking for a Stream.Duplex instance is faster here instead of inside
// the WritableState constructor, at least with V8 6.5
var isDuplex = this instanceof Duplex;
if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
this._writableState = new WritableState(options, this, isDuplex); // legacy.
this.writable = true;
if (options) {
if (typeof options.write === 'function') this._write = options.write;
if (typeof options.writev === 'function') this._writev = options.writev;
if (typeof options.destroy === 'function') this._destroy = options.destroy;
if (typeof options.final === 'function') this._final = options.final;
}
Stream.call(this);
} // Otherwise people can pipe Writable streams, which is just wrong.
Writable.prototype.pipe = function () {
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
};
function writeAfterEnd(stream, cb) {
var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
errorOrDestroy(stream, er);
process.nextTick(cb, er);
} // Checks that a user-supplied chunk is valid, especially for the particular
// mode the stream is in. Currently this means that `null` is never accepted
// and undefined/non-string values are only allowed in object mode.
function validChunk(stream, state, chunk, cb) {
var er;
if (chunk === null) {
er = new ERR_STREAM_NULL_VALUES();
} else if (typeof chunk !== 'string' && !state.objectMode) {
er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
}
if (er) {
errorOrDestroy(stream, er);
process.nextTick(cb, er);
return false;
}
return true;
}
Writable.prototype.write = function (chunk, encoding, cb) {
var state = this._writableState;
var ret = false;
var isBuf = !state.objectMode && _isUint8Array(chunk);
if (isBuf && !Buffer.isBuffer(chunk)) {
chunk = _uint8ArrayToBuffer(chunk);
}
if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
if (typeof cb !== 'function') cb = nop;
if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
state.pendingcb++;
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
}
return ret;
};
Writable.prototype.cork = function () {
this._writableState.corked++;
};
Writable.prototype.uncork = function () {
var state = this._writableState;
if (state.corked) {
state.corked--;
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
}
};
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
// node::ParseEncoding() requires lower case.
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
this._writableState.defaultEncoding = encoding;
return this;
};
Object.defineProperty(Writable.prototype, 'writableBuffer', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
return this._writableState && this._writableState.getBuffer();
}
});
function decodeChunk(state, chunk, encoding) {
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
chunk = Buffer.from(chunk, encoding);
}
return chunk;
}
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
return this._writableState.highWaterMark;
}
}); // if we're already writing something, then just put this
// in the queue, and wait our turn. Otherwise, call _write
// If we return false, then we need a drain event, so set that flag.
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
if (!isBuf) {
var newChunk = decodeChunk(state, chunk, encoding);
if (chunk !== newChunk) {
isBuf = true;
encoding = 'buffer';
chunk = newChunk;
}
}
var len = state.objectMode ? 1 : chunk.length;
state.length += len;
var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
if (!ret) state.needDrain = true;
if (state.writing || state.corked) {
var last = state.lastBufferedRequest;
state.lastBufferedRequest = {
chunk: chunk,
encoding: encoding,
isBuf: isBuf,
callback: cb,
next: null
};
if (last) {
last.next = state.lastBufferedRequest;
} else {
state.bufferedRequest = state.lastBufferedRequest;
}
state.bufferedRequestCount += 1;
} else {
doWrite(stream, state, false, len, chunk, encoding, cb);
}
return ret;
}
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
state.writelen = len;
state.writecb = cb;
state.writing = true;
state.sync = true;
if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
state.sync = false;
}
function onwriteError(stream, state, sync, er, cb) {
--state.pendingcb;
if (sync) {
// defer the callback if we are being called synchronously
// to avoid piling up things on the stack
process.nextTick(cb, er); // this can emit finish, and it will always happen
// after error
process.nextTick(finishMaybe, stream, state);
stream._writableState.errorEmitted = true;
errorOrDestroy(stream, er);
} else {
// the caller expect this to happen before if
// it is async
cb(er);
stream._writableState.errorEmitted = true;
errorOrDestroy(stream, er); // this can emit finish, but finish must
// always follow error
finishMaybe(stream, state);
}
}
function onwriteStateUpdate(state) {
state.writing = false;
state.writecb = null;
state.length -= state.writelen;
state.writelen = 0;
}
function onwrite(stream, er) {
var state = stream._writableState;
var sync = state.sync;
var cb = state.writecb;
if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
onwriteStateUpdate(state);
if (er) onwriteError(stream, state, sync, er, cb);else {
// Check if we're actually ready to finish, but don't emit yet
var finished = needFinish(state) || stream.destroyed;
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
clearBuffer(stream, state);
}
if (sync) {
process.nextTick(afterWrite, stream, state, finished, cb);
} else {
afterWrite(stream, state, finished, cb);
}
}
}
function afterWrite(stream, state, finished, cb) {
if (!finished) onwriteDrain(stream, state);
state.pendingcb--;
cb();
finishMaybe(stream, state);
} // Must force callback to be called on nextTick, so that we don't
// emit 'drain' before the write() consumer gets the 'false' return
// value, and has a chance to attach a 'drain' listener.
function onwriteDrain(stream, state) {
if (state.length === 0 && state.needDrain) {
state.needDrain = false;
stream.emit('drain');
}
} // if there's something in the buffer waiting, then process it
function clearBuffer(stream, state) {
state.bufferProcessing = true;
var entry = state.bufferedRequest;
if (stream._writev && entry && entry.next) {
// Fast case, write everything using _writev()
var l = state.bufferedRequestCount;
var buffer = new Array(l);
var holder = state.corkedRequestsFree;
holder.entry = entry;
var count = 0;
var allBuffers = true;
while (entry) {
buffer[count] = entry;
if (!entry.isBuf) allBuffers = false;
entry = entry.next;
count += 1;
}
buffer.allBuffers = allBuffers;
doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
// as the hot path ends with doWrite
state.pendingcb++;
state.lastBufferedRequest = null;
if (holder.next) {
state.corkedRequestsFree = holder.next;
holder.next = null;
} else {
state.corkedRequestsFree = new CorkedRequest(state);
}
state.bufferedRequestCount = 0;
} else {
// Slow case, write chunks one-by-one
while (entry) {
var chunk = entry.chunk;
var encoding = entry.encoding;
var cb = entry.callback;
var len = state.objectMode ? 1 : chunk.length;
doWrite(stream, state, false, len, chunk, encoding, cb);
entry = entry.next;
state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
// it means that we need to wait until it does.
// also, that means that the chunk and cb are currently
// being processed, so move the buffer counter past them.
if (state.writing) {
break;
}
}
if (entry === null) state.lastBufferedRequest = null;
}
state.bufferedRequest = entry;
state.bufferProcessing = false;
}
Writable.prototype._write = function (chunk, encoding, cb) {
cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
};
Writable.prototype._writev = null;
Writable.prototype.end = function (chunk, encoding, cb) {
var state = this._writableState;
if (typeof chunk === 'function') {
cb = chunk;
chunk = null;
encoding = null;
} else if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
if (state.corked) {
state.corked = 1;
this.uncork();
} // ignore unnecessary end() calls.
if (!state.ending) endWritable(this, state, cb);
return this;
};
Object.defineProperty(Writable.prototype, 'writableLength', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
return this._writableState.length;
}
});
function needFinish(state) {
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
}
function callFinal(stream, state) {
stream._final(function (err) {
state.pendingcb--;
if (err) {
errorOrDestroy(stream, err);
}
state.prefinished = true;
stream.emit('prefinish');
finishMaybe(stream, state);
});
}
function prefinish(stream, state) {
if (!state.prefinished && !state.finalCalled) {
if (typeof stream._final === 'function' && !state.destroyed) {
state.pendingcb++;
state.finalCalled = true;
process.nextTick(callFinal, stream, state);
} else {
state.prefinished = true;
stream.emit('prefinish');
}
}
}
function finishMaybe(stream, state) {
var need = needFinish(state);
if (need) {
prefinish(stream, state);
if (state.pendingcb === 0) {
state.finished = true;
stream.emit('finish');
if (state.autoDestroy) {
// In case of duplex streams we need a way to detect
// if the readable side is ready for autoDestroy as well
var rState = stream._readableState;
if (!rState || rState.autoDestroy && rState.endEmitted) {
stream.destroy();
}
}
}
}
return need;
}
function endWritable(stream, state, cb) {
state.ending = true;
finishMaybe(stream, state);
if (cb) {
if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
}
state.ended = true;
stream.writable = false;
}
function onCorkedFinish(corkReq, state, err) {
var entry = corkReq.entry;
corkReq.entry = null;
while (entry) {
var cb = entry.callback;
state.pendingcb--;
cb(err);
entry = entry.next;
} // reuse the free corkReq.
state.corkedRequestsFree.next = corkReq;
}
Object.defineProperty(Writable.prototype, 'destroyed', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function get() {
if (this._writableState === undefined) {
return false;
}
return this._writableState.destroyed;
},
set: function set(value) {
// we ignore the value if the stream
// has not been initialized yet
if (!this._writableState) {
return;
} // backward compatibility, the user is explicitly
// managing destroyed
this._writableState.destroyed = value;
}
});
Writable.prototype.destroy = destroyImpl.destroy;
Writable.prototype._undestroy = destroyImpl.undestroy;
Writable.prototype._destroy = function (err, cb) {
cb(err);
};

View File

@ -0,0 +1,207 @@
'use strict';
var _Object$setPrototypeO;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var finished = require('./end-of-stream');
var kLastResolve = Symbol('lastResolve');
var kLastReject = Symbol('lastReject');
var kError = Symbol('error');
var kEnded = Symbol('ended');
var kLastPromise = Symbol('lastPromise');
var kHandlePromise = Symbol('handlePromise');
var kStream = Symbol('stream');
function createIterResult(value, done) {
return {
value: value,
done: done
};
}
function readAndResolve(iter) {
var resolve = iter[kLastResolve];
if (resolve !== null) {
var data = iter[kStream].read(); // we defer if data is null
// we can be expecting either 'end' or
// 'error'
if (data !== null) {
iter[kLastPromise] = null;
iter[kLastResolve] = null;
iter[kLastReject] = null;
resolve(createIterResult(data, false));
}
}
}
function onReadable(iter) {
// we wait for the next tick, because it might
// emit an error with process.nextTick
process.nextTick(readAndResolve, iter);
}
function wrapForNext(lastPromise, iter) {
return function (resolve, reject) {
lastPromise.then(function () {
if (iter[kEnded]) {
resolve(createIterResult(undefined, true));
return;
}
iter[kHandlePromise](resolve, reject);
}, reject);
};
}
var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
get stream() {
return this[kStream];
},
next: function next() {
var _this = this;
// if we have detected an error in the meanwhile
// reject straight away
var error = this[kError];
if (error !== null) {
return Promise.reject(error);
}
if (this[kEnded]) {
return Promise.resolve(createIterResult(undefined, true));
}
if (this[kStream].destroyed) {
// We need to defer via nextTick because if .destroy(err) is
// called, the error will be emitted via nextTick, and
// we cannot guarantee that there is no error lingering around
// waiting to be emitted.
return new Promise(function (resolve, reject) {
process.nextTick(function () {
if (_this[kError]) {
reject(_this[kError]);
} else {
resolve(createIterResult(undefined, true));
}
});
});
} // if we have multiple next() calls
// we will wait for the previous Promise to finish
// this logic is optimized to support for await loops,
// where next() is only called once at a time
var lastPromise = this[kLastPromise];
var promise;
if (lastPromise) {
promise = new Promise(wrapForNext(lastPromise, this));
} else {
// fast path needed to support multiple this.push()
// without triggering the next() queue
var data = this[kStream].read();
if (data !== null) {
return Promise.resolve(createIterResult(data, false));
}
promise = new Promise(this[kHandlePromise]);
}
this[kLastPromise] = promise;
return promise;
}
}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
return this;
}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
var _this2 = this;
// destroy(err, cb) is a private API
// we can guarantee we have that here, because we control the
// Readable class this is attached to
return new Promise(function (resolve, reject) {
_this2[kStream].destroy(null, function (err) {
if (err) {
reject(err);
return;
}
resolve(createIterResult(undefined, true));
});
});
}), _Object$setPrototypeO), AsyncIteratorPrototype);
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
var _Object$create;
var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
value: stream,
writable: true
}), _defineProperty(_Object$create, kLastResolve, {
value: null,
writable: true
}), _defineProperty(_Object$create, kLastReject, {
value: null,
writable: true
}), _defineProperty(_Object$create, kError, {
value: null,
writable: true
}), _defineProperty(_Object$create, kEnded, {
value: stream._readableState.endEmitted,
writable: true
}), _defineProperty(_Object$create, kHandlePromise, {
value: function value(resolve, reject) {
var data = iterator[kStream].read();
if (data) {
iterator[kLastPromise] = null;
iterator[kLastResolve] = null;
iterator[kLastReject] = null;
resolve(createIterResult(data, false));
} else {
iterator[kLastResolve] = resolve;
iterator[kLastReject] = reject;
}
},
writable: true
}), _Object$create));
iterator[kLastPromise] = null;
finished(stream, function (err) {
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
// returned by next() and store the error
if (reject !== null) {
iterator[kLastPromise] = null;
iterator[kLastResolve] = null;
iterator[kLastReject] = null;
reject(err);
}
iterator[kError] = err;
return;
}
var resolve = iterator[kLastResolve];
if (resolve !== null) {
iterator[kLastPromise] = null;
iterator[kLastResolve] = null;
iterator[kLastReject] = null;
resolve(createIterResult(undefined, true));
}
iterator[kEnded] = true;
});
stream.on('readable', onReadable.bind(null, iterator));
return iterator;
};
module.exports = createReadableStreamAsyncIterator;

View File

@ -0,0 +1,191 @@
'use strict';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _require = require('buffer'),
Buffer = _require.Buffer;
var _require2 = require('util'),
inspect = _require2.inspect;
var custom = inspect && inspect.custom || 'inspect';
function copyBuffer(src, target, offset) {
Buffer.prototype.copy.call(src, target, offset);
}
module.exports =
/*#__PURE__*/
function () {
function BufferList() {
this.head = null;
this.tail = null;
this.length = 0;
}
var _proto = BufferList.prototype;
_proto.push = function push(v) {
var entry = {
data: v,
next: null
};
if (this.length > 0) this.tail.next = entry;else this.head = entry;
this.tail = entry;
++this.length;
};
_proto.unshift = function unshift(v) {
var entry = {
data: v,
next: this.head
};
if (this.length === 0) this.tail = entry;
this.head = entry;
++this.length;
};
_proto.shift = function shift() {
if (this.length === 0) return;
var ret = this.head.data;
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
--this.length;
return ret;
};
_proto.clear = function clear() {
this.head = this.tail = null;
this.length = 0;
};
_proto.join = function join(s) {
if (this.length === 0) return '';
var p = this.head;
var ret = '' + p.data;
while (p = p.next) {
ret += s + p.data;
}
return ret;
};
_proto.concat = function concat(n) {
if (this.length === 0) return Buffer.alloc(0);
var ret = Buffer.allocUnsafe(n >>> 0);
var p = this.head;
var i = 0;
while (p) {
copyBuffer(p.data, ret, i);
i += p.data.length;
p = p.next;
}
return ret;
} // Consumes a specified amount of bytes or characters from the buffered data.
;
_proto.consume = function consume(n, hasStrings) {
var ret;
if (n < this.head.data.length) {
// `slice` is the same for buffers and strings.
ret = this.head.data.slice(0, n);
this.head.data = this.head.data.slice(n);
} else if (n === this.head.data.length) {
// First chunk is a perfect match.
ret = this.shift();
} else {
// Result spans more than one buffer.
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
}
return ret;
};
_proto.first = function first() {
return this.head.data;
} // Consumes a specified amount of characters from the buffered data.
;
_proto._getString = function _getString(n) {
var p = this.head;
var c = 1;
var ret = p.data;
n -= ret.length;
while (p = p.next) {
var str = p.data;
var nb = n > str.length ? str.length : n;
if (nb === str.length) ret += str;else ret += str.slice(0, n);
n -= nb;
if (n === 0) {
if (nb === str.length) {
++c;
if (p.next) this.head = p.next;else this.head = this.tail = null;
} else {
this.head = p;
p.data = str.slice(nb);
}
break;
}
++c;
}
this.length -= c;
return ret;
} // Consumes a specified amount of bytes from the buffered data.
;
_proto._getBuffer = function _getBuffer(n) {
var ret = Buffer.allocUnsafe(n);
var p = this.head;
var c = 1;
p.data.copy(ret);
n -= p.data.length;
while (p = p.next) {
var buf = p.data;
var nb = n > buf.length ? buf.length : n;
buf.copy(ret, ret.length - n, 0, nb);
n -= nb;
if (n === 0) {
if (nb === buf.length) {
++c;
if (p.next) this.head = p.next;else this.head = this.tail = null;
} else {
this.head = p;
p.data = buf.slice(nb);
}
break;
}
++c;
}
this.length -= c;
return ret;
} // Make sure the linked list only shows the minimal necessary information.
;
_proto[custom] = function (_, options) {
return inspect(this, _objectSpread({}, options, {
// Only inspect one level.
depth: 0,
// It should not recurse.
customInspect: false
}));
};
return BufferList;
}();

View File

@ -0,0 +1,105 @@
'use strict'; // undocumented cb() API, needed for core, not for public API
function destroy(err, cb) {
var _this = this;
var readableDestroyed = this._readableState && this._readableState.destroyed;
var writableDestroyed = this._writableState && this._writableState.destroyed;
if (readableDestroyed || writableDestroyed) {
if (cb) {
cb(err);
} else if (err) {
if (!this._writableState) {
process.nextTick(emitErrorNT, this, err);
} else if (!this._writableState.errorEmitted) {
this._writableState.errorEmitted = true;
process.nextTick(emitErrorNT, this, err);
}
}
return this;
} // we set destroyed to true before firing error callbacks in order
// to make it re-entrance safe in case destroy() is called within callbacks
if (this._readableState) {
this._readableState.destroyed = true;
} // if this is a duplex stream mark the writable part as destroyed as well
if (this._writableState) {
this._writableState.destroyed = true;
}
this._destroy(err || null, function (err) {
if (!cb && err) {
if (!_this._writableState) {
process.nextTick(emitErrorAndCloseNT, _this, err);
} else if (!_this._writableState.errorEmitted) {
_this._writableState.errorEmitted = true;
process.nextTick(emitErrorAndCloseNT, _this, err);
} else {
process.nextTick(emitCloseNT, _this);
}
} else if (cb) {
process.nextTick(emitCloseNT, _this);
cb(err);
} else {
process.nextTick(emitCloseNT, _this);
}
});
return this;
}
function emitErrorAndCloseNT(self, err) {
emitErrorNT(self, err);
emitCloseNT(self);
}
function emitCloseNT(self) {
if (self._writableState && !self._writableState.emitClose) return;
if (self._readableState && !self._readableState.emitClose) return;
self.emit('close');
}
function undestroy() {
if (this._readableState) {
this._readableState.destroyed = false;
this._readableState.reading = false;
this._readableState.ended = false;
this._readableState.endEmitted = false;
}
if (this._writableState) {
this._writableState.destroyed = false;
this._writableState.ended = false;
this._writableState.ending = false;
this._writableState.finalCalled = false;
this._writableState.prefinished = false;
this._writableState.finished = false;
this._writableState.errorEmitted = false;
}
}
function emitErrorNT(self, err) {
self.emit('error', err);
}
function errorOrDestroy(stream, err) {
// We have tests that rely on errors being emitted
// in the same tick, so changing this is semver major.
// For now when you opt-in to autoDestroy we allow
// the error to be emitted nextTick. In a future
// semver major update we should change the default to this.
var rState = stream._readableState;
var wState = stream._writableState;
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
}
module.exports = {
destroy: destroy,
undestroy: undestroy,
errorOrDestroy: errorOrDestroy
};

View File

@ -0,0 +1,104 @@
// Ported from https://github.com/mafintosh/end-of-stream with
// permission from the author, Mathias Buus (@mafintosh).
'use strict';
var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;
function once(callback) {
var called = false;
return function () {
if (called) return;
called = true;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
callback.apply(this, args);
};
}
function noop() {}
function isRequest(stream) {
return stream.setHeader && typeof stream.abort === 'function';
}
function eos(stream, opts, callback) {
if (typeof opts === 'function') return eos(stream, null, opts);
if (!opts) opts = {};
callback = once(callback || noop);
var readable = opts.readable || opts.readable !== false && stream.readable;
var writable = opts.writable || opts.writable !== false && stream.writable;
var onlegacyfinish = function onlegacyfinish() {
if (!stream.writable) onfinish();
};
var writableEnded = stream._writableState && stream._writableState.finished;
var onfinish = function onfinish() {
writable = false;
writableEnded = true;
if (!readable) callback.call(stream);
};
var readableEnded = stream._readableState && stream._readableState.endEmitted;
var onend = function onend() {
readable = false;
readableEnded = true;
if (!writable) callback.call(stream);
};
var onerror = function onerror(err) {
callback.call(stream, err);
};
var onclose = function onclose() {
var err;
if (readable && !readableEnded) {
if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
return callback.call(stream, err);
}
if (writable && !writableEnded) {
if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
return callback.call(stream, err);
}
};
var onrequest = function onrequest() {
stream.req.on('finish', onfinish);
};
if (isRequest(stream)) {
stream.on('complete', onfinish);
stream.on('abort', onclose);
if (stream.req) onrequest();else stream.on('request', onrequest);
} else if (writable && !stream._writableState) {
// legacy streams
stream.on('end', onlegacyfinish);
stream.on('close', onlegacyfinish);
}
stream.on('end', onend);
stream.on('finish', onfinish);
if (opts.error !== false) stream.on('error', onerror);
stream.on('close', onclose);
return function () {
stream.removeListener('complete', onfinish);
stream.removeListener('abort', onclose);
stream.removeListener('request', onrequest);
if (stream.req) stream.req.removeListener('finish', onfinish);
stream.removeListener('end', onlegacyfinish);
stream.removeListener('close', onlegacyfinish);
stream.removeListener('finish', onfinish);
stream.removeListener('end', onend);
stream.removeListener('error', onerror);
stream.removeListener('close', onclose);
};
}
module.exports = eos;

View File

@ -0,0 +1,3 @@
module.exports = function () {
throw new Error('Readable.from is not available in the browser')
};

View File

@ -0,0 +1,64 @@
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE;
function from(Readable, iterable, opts) {
var iterator;
if (iterable && typeof iterable.next === 'function') {
iterator = iterable;
} else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);
var readable = new Readable(_objectSpread({
objectMode: true
}, opts)); // Reading boolean to protect against _read
// being called before last iteration completion.
var reading = false;
readable._read = function () {
if (!reading) {
reading = true;
next();
}
};
function next() {
return _next2.apply(this, arguments);
}
function _next2() {
_next2 = _asyncToGenerator(function* () {
try {
var _ref = yield iterator.next(),
value = _ref.value,
done = _ref.done;
if (done) {
readable.push(null);
} else if (readable.push((yield value))) {
next();
} else {
reading = false;
}
} catch (err) {
readable.destroy(err);
}
});
return _next2.apply(this, arguments);
}
return readable;
}
module.exports = from;

View File

@ -0,0 +1,97 @@
// Ported from https://github.com/mafintosh/pump with
// permission from the author, Mathias Buus (@mafintosh).
'use strict';
var eos;
function once(callback) {
var called = false;
return function () {
if (called) return;
called = true;
callback.apply(void 0, arguments);
};
}
var _require$codes = require('../../../errors').codes,
ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
function noop(err) {
// Rethrow the error if it exists to avoid swallowing it
if (err) throw err;
}
function isRequest(stream) {
return stream.setHeader && typeof stream.abort === 'function';
}
function destroyer(stream, reading, writing, callback) {
callback = once(callback);
var closed = false;
stream.on('close', function () {
closed = true;
});
if (eos === undefined) eos = require('./end-of-stream');
eos(stream, {
readable: reading,
writable: writing
}, function (err) {
if (err) return callback(err);
closed = true;
callback();
});
var destroyed = false;
return function (err) {
if (closed) return;
if (destroyed) return;
destroyed = true; // request.destroy just do .end - .abort is what we want
if (isRequest(stream)) return stream.abort();
if (typeof stream.destroy === 'function') return stream.destroy();
callback(err || new ERR_STREAM_DESTROYED('pipe'));
};
}
function call(fn) {
fn();
}
function pipe(from, to) {
return from.pipe(to);
}
function popCallback(streams) {
if (!streams.length) return noop;
if (typeof streams[streams.length - 1] !== 'function') return noop;
return streams.pop();
}
function pipeline() {
for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
streams[_key] = arguments[_key];
}
var callback = popCallback(streams);
if (Array.isArray(streams[0])) streams = streams[0];
if (streams.length < 2) {
throw new ERR_MISSING_ARGS('streams');
}
var error;
var destroys = streams.map(function (stream, i) {
var reading = i < streams.length - 1;
var writing = i > 0;
return destroyer(stream, reading, writing, function (err) {
if (!error) error = err;
if (err) destroys.forEach(call);
if (reading) return;
destroys.forEach(call);
callback(error);
});
});
return streams.reduce(pipe);
}
module.exports = pipeline;

View File

@ -0,0 +1,27 @@
'use strict';
var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
function highWaterMarkFrom(options, isDuplex, duplexKey) {
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
}
function getHighWaterMark(state, options, duplexKey, isDuplex) {
var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
if (hwm != null) {
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
var name = isDuplex ? duplexKey : 'highWaterMark';
throw new ERR_INVALID_OPT_VALUE(name, hwm);
}
return Math.floor(hwm);
} // Default value
return state.objectMode ? 16 : 16 * 1024;
}
module.exports = {
getHighWaterMark: getHighWaterMark
};

View File

@ -0,0 +1 @@
module.exports = require('events').EventEmitter;

View File

@ -0,0 +1 @@
module.exports = require('stream');

97
node_modules/readable-stream/package.json generated vendored Normal file
View File

@ -0,0 +1,97 @@
{
"_from": "readable-stream@^3.1.1",
"_id": "readable-stream@3.5.0",
"_inBundle": false,
"_integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==",
"_location": "/readable-stream",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "readable-stream@^3.1.1",
"name": "readable-stream",
"escapedName": "readable-stream",
"rawSpec": "^3.1.1",
"saveSpec": null,
"fetchSpec": "^3.1.1"
},
"_requiredBy": [
"/duplexify"
],
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz",
"_shasum": "465d70e6d1087f6162d079cd0b5db7fbebfd1606",
"_spec": "readable-stream@^3.1.1",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/duplexify",
"browser": {
"util": false,
"worker_threads": false,
"./errors": "./errors-browser.js",
"./readable.js": "./readable-browser.js",
"./lib/internal/streams/from.js": "./lib/internal/streams/from-browser.js",
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
},
"bugs": {
"url": "https://github.com/nodejs/readable-stream/issues"
},
"bundleDependencies": false,
"dependencies": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"deprecated": false,
"description": "Streams3, a user-land copy of the stream library from Node.js",
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.2.0",
"airtap": "0.0.9",
"assert": "^1.4.0",
"bl": "^2.0.0",
"deep-strict-equal": "^0.2.0",
"events.once": "^2.0.2",
"glob": "^7.1.2",
"gunzip-maybe": "^1.4.1",
"hyperquest": "^2.1.3",
"lolex": "^2.6.0",
"nyc": "^11.0.0",
"pump": "^3.0.0",
"rimraf": "^2.6.2",
"tap": "^12.0.0",
"tape": "^4.9.0",
"tar-fs": "^1.16.2",
"util-promisify": "^2.1.0"
},
"engines": {
"node": ">= 6"
},
"homepage": "https://github.com/nodejs/readable-stream#readme",
"keywords": [
"readable",
"stream",
"pipe"
],
"license": "MIT",
"main": "readable.js",
"name": "readable-stream",
"nyc": {
"include": [
"lib/**.js"
]
},
"repository": {
"type": "git",
"url": "git://github.com/nodejs/readable-stream.git"
},
"scripts": {
"ci": "TAP=1 tap --no-esm test/parallel/*.js test/ours/*.js | tee test.tap",
"cover": "nyc npm test",
"report": "nyc report --reporter=lcov",
"test": "tap -J --no-esm test/parallel/*.js test/ours/*.js",
"test-browser-local": "airtap --open --local -- test/browser.js",
"test-browsers": "airtap --sauce-connect --loopback airtap.local -- test/browser.js",
"update-browser-errors": "babel -o errors-browser.js errors.js"
},
"version": "3.5.0"
}

9
node_modules/readable-stream/readable-browser.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
exports = module.exports = require('./lib/_stream_readable.js');
exports.Stream = exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');
exports.finished = require('./lib/internal/streams/end-of-stream.js');
exports.pipeline = require('./lib/internal/streams/pipeline.js');

16
node_modules/readable-stream/readable.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
var Stream = require('stream');
if (process.env.READABLE_STREAM === 'disable' && Stream) {
module.exports = Stream.Readable;
Object.assign(module.exports, Stream);
module.exports.Stream = Stream;
} else {
exports = module.exports = require('./lib/_stream_readable.js');
exports.Stream = Stream || exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');
exports.finished = require('./lib/internal/streams/end-of-stream.js');
exports.pipeline = require('./lib/internal/streams/pipeline.js');
}

21
node_modules/safe-buffer/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Feross Aboukhadijeh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

586
node_modules/safe-buffer/README.md generated vendored Normal file
View File

@ -0,0 +1,586 @@
# safe-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[travis-image]: https://img.shields.io/travis/feross/safe-buffer/master.svg
[travis-url]: https://travis-ci.org/feross/safe-buffer
[npm-image]: https://img.shields.io/npm/v/safe-buffer.svg
[npm-url]: https://npmjs.org/package/safe-buffer
[downloads-image]: https://img.shields.io/npm/dm/safe-buffer.svg
[downloads-url]: https://npmjs.org/package/safe-buffer
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com
#### Safer Node.js Buffer API
**Use the new Node.js Buffer APIs (`Buffer.from`, `Buffer.alloc`,
`Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`) in all versions of Node.js.**
**Uses the built-in implementation when available.**
## install
```
npm install safe-buffer
```
[Get supported safe-buffer with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-safe-buffer?utm_source=npm-safe-buffer&utm_medium=referral&utm_campaign=readme)
## usage
The goal of this package is to provide a safe replacement for the node.js `Buffer`.
It's a drop-in replacement for `Buffer`. You can use it by adding one `require` line to
the top of your node.js modules:
```js
var Buffer = require('safe-buffer').Buffer
// Existing buffer code will continue to work without issues:
new Buffer('hey', 'utf8')
new Buffer([1, 2, 3], 'utf8')
new Buffer(obj)
new Buffer(16) // create an uninitialized buffer (potentially unsafe)
// But you can use these new explicit APIs to make clear what you want:
Buffer.from('hey', 'utf8') // convert from many types to a Buffer
Buffer.alloc(16) // create a zero-filled buffer (safe)
Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe)
```
## api
### Class Method: Buffer.from(array)
<!-- YAML
added: v3.0.0
-->
* `array` {Array}
Allocates a new `Buffer` using an `array` of octets.
```js
const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
// creates a new Buffer containing ASCII bytes
// ['b','u','f','f','e','r']
```
A `TypeError` will be thrown if `array` is not an `Array`.
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
<!-- YAML
added: v5.10.0
-->
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
a `new ArrayBuffer()`
* `byteOffset` {Number} Default: `0`
* `length` {Number} Default: `arrayBuffer.length - byteOffset`
When passed a reference to the `.buffer` property of a `TypedArray` instance,
the newly created `Buffer` will share the same allocated memory as the
TypedArray.
```js
const arr = new Uint16Array(2);
arr[0] = 5000;
arr[1] = 4000;
const buf = Buffer.from(arr.buffer); // shares the memory with arr;
console.log(buf);
// Prints: <Buffer 88 13 a0 0f>
// changing the TypedArray changes the Buffer also
arr[1] = 6000;
console.log(buf);
// Prints: <Buffer 88 13 70 17>
```
The optional `byteOffset` and `length` arguments specify a memory range within
the `arrayBuffer` that will be shared by the `Buffer`.
```js
const ab = new ArrayBuffer(10);
const buf = Buffer.from(ab, 0, 2);
console.log(buf.length);
// Prints: 2
```
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
### Class Method: Buffer.from(buffer)
<!-- YAML
added: v3.0.0
-->
* `buffer` {Buffer}
Copies the passed `buffer` data onto a new `Buffer` instance.
```js
const buf1 = Buffer.from('buffer');
const buf2 = Buffer.from(buf1);
buf1[0] = 0x61;
console.log(buf1.toString());
// 'auffer'
console.log(buf2.toString());
// 'buffer' (copy is not changed)
```
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
### Class Method: Buffer.from(str[, encoding])
<!-- YAML
added: v5.10.0
-->
* `str` {String} String to encode.
* `encoding` {String} Encoding to use, Default: `'utf8'`
Creates a new `Buffer` containing the given JavaScript string `str`. If
provided, the `encoding` parameter identifies the character encoding.
If not provided, `encoding` defaults to `'utf8'`.
```js
const buf1 = Buffer.from('this is a tést');
console.log(buf1.toString());
// prints: this is a tést
console.log(buf1.toString('ascii'));
// prints: this is a tC)st
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
console.log(buf2.toString());
// prints: this is a tést
```
A `TypeError` will be thrown if `str` is not a string.
### Class Method: Buffer.alloc(size[, fill[, encoding]])
<!-- YAML
added: v5.10.0
-->
* `size` {Number}
* `fill` {Value} Default: `undefined`
* `encoding` {String} Default: `utf8`
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
`Buffer` will be *zero-filled*.
```js
const buf = Buffer.alloc(5);
console.log(buf);
// <Buffer 00 00 00 00 00>
```
The `size` must be less than or equal to the value of
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
be created if a `size` less than or equal to 0 is specified.
If `fill` is specified, the allocated `Buffer` will be initialized by calling
`buf.fill(fill)`. See [`buf.fill()`][] for more information.
```js
const buf = Buffer.alloc(5, 'a');
console.log(buf);
// <Buffer 61 61 61 61 61>
```
If both `fill` and `encoding` are specified, the allocated `Buffer` will be
initialized by calling `buf.fill(fill, encoding)`. For example:
```js
const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
console.log(buf);
// <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
```
Calling `Buffer.alloc(size)` can be significantly slower than the alternative
`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance
contents will *never contain sensitive data*.
A `TypeError` will be thrown if `size` is not a number.
### Class Method: Buffer.allocUnsafe(size)
<!-- YAML
added: v5.10.0
-->
* `size` {Number}
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
thrown. A zero-length Buffer will be created if a `size` less than or equal to
0 is specified.
The underlying memory for `Buffer` instances created in this way is *not
initialized*. The contents of the newly created `Buffer` are unknown and
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
`Buffer` instances to zeroes.
```js
const buf = Buffer.allocUnsafe(5);
console.log(buf);
// <Buffer 78 e0 82 02 01>
// (octets will be different, every time)
buf.fill(0);
console.log(buf);
// <Buffer 00 00 00 00 00>
```
A `TypeError` will be thrown if `size` is not a number.
Note that the `Buffer` module pre-allocates an internal `Buffer` instance of
size `Buffer.poolSize` that is used as a pool for the fast allocation of new
`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the deprecated
`new Buffer(size)` constructor) only when `size` is less than or equal to
`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default
value of `Buffer.poolSize` is `8192` but can be modified.
Use of this pre-allocated internal memory pool is a key difference between
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer
pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The
difference is subtle but can be important when an application requires the
additional performance that `Buffer.allocUnsafe(size)` provides.
### Class Method: Buffer.allocUnsafeSlow(size)
<!-- YAML
added: v5.10.0
-->
* `size` {Number}
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
`size` must be less than or equal to the value of
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
be created if a `size` less than or equal to 0 is specified.
The underlying memory for `Buffer` instances created in this way is *not
initialized*. The contents of the newly created `Buffer` are unknown and
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
`Buffer` instances to zeroes.
When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
allocations under 4KB are, by default, sliced from a single pre-allocated
`Buffer`. This allows applications to avoid the garbage collection overhead of
creating many individually allocated Buffers. This approach improves both
performance and memory usage by eliminating the need to track and cleanup as
many `Persistent` objects.
However, in the case where a developer may need to retain a small chunk of
memory from a pool for an indeterminate amount of time, it may be appropriate
to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then
copy out the relevant bits.
```js
// need to keep around a few small chunks of memory
const store = [];
socket.on('readable', () => {
const data = socket.read();
// allocate for retained data
const sb = Buffer.allocUnsafeSlow(10);
// copy the data into the new allocation
data.copy(sb, 0, 0, 10);
store.push(sb);
});
```
Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after*
a developer has observed undue memory retention in their applications.
A `TypeError` will be thrown if `size` is not a number.
### All the Rest
The rest of the `Buffer` API is exactly the same as in node.js.
[See the docs](https://nodejs.org/api/buffer.html).
## Related links
- [Node.js issue: Buffer(number) is unsafe](https://github.com/nodejs/node/issues/4660)
- [Node.js Enhancement Proposal: Buffer.from/Buffer.alloc/Buffer.zalloc/Buffer() soft-deprecate](https://github.com/nodejs/node-eps/pull/4)
## Why is `Buffer` unsafe?
Today, the node.js `Buffer` constructor is overloaded to handle many different argument
types like `String`, `Array`, `Object`, `TypedArrayView` (`Uint8Array`, etc.),
`ArrayBuffer`, and also `Number`.
The API is optimized for convenience: you can throw any type at it, and it will try to do
what you want.
Because the Buffer constructor is so powerful, you often see code like this:
```js
// Convert UTF-8 strings to hex
function toHex (str) {
return new Buffer(str).toString('hex')
}
```
***But what happens if `toHex` is called with a `Number` argument?***
### Remote Memory Disclosure
If an attacker can make your program call the `Buffer` constructor with a `Number`
argument, then they can make it allocate uninitialized memory from the node.js process.
This could potentially disclose TLS private keys, user data, or database passwords.
When the `Buffer` constructor is passed a `Number` argument, it returns an
**UNINITIALIZED** block of memory of the specified `size`. When you create a `Buffer` like
this, you **MUST** overwrite the contents before returning it to the user.
From the [node.js docs](https://nodejs.org/api/buffer.html#buffer_new_buffer_size):
> `new Buffer(size)`
>
> - `size` Number
>
> The underlying memory for `Buffer` instances created in this way is not initialized.
> **The contents of a newly created `Buffer` are unknown and could contain sensitive
> data.** Use `buf.fill(0)` to initialize a Buffer to zeroes.
(Emphasis our own.)
Whenever the programmer intended to create an uninitialized `Buffer` you often see code
like this:
```js
var buf = new Buffer(16)
// Immediately overwrite the uninitialized buffer with data from another buffer
for (var i = 0; i < buf.length; i++) {
buf[i] = otherBuf[i]
}
```
### Would this ever be a problem in real code?
Yes. It's surprisingly common to forget to check the type of your variables in a
dynamically-typed language like JavaScript.
Usually the consequences of assuming the wrong type is that your program crashes with an
uncaught exception. But the failure mode for forgetting to check the type of arguments to
the `Buffer` constructor is more catastrophic.
Here's an example of a vulnerable service that takes a JSON payload and converts it to
hex:
```js
// Take a JSON payload {str: "some string"} and convert it to hex
var server = http.createServer(function (req, res) {
var data = ''
req.setEncoding('utf8')
req.on('data', function (chunk) {
data += chunk
})
req.on('end', function () {
var body = JSON.parse(data)
res.end(new Buffer(body.str).toString('hex'))
})
})
server.listen(8080)
```
In this example, an http client just has to send:
```json
{
"str": 1000
}
```
and it will get back 1,000 bytes of uninitialized memory from the server.
This is a very serious bug. It's similar in severity to the
[the Heartbleed bug](http://heartbleed.com/) that allowed disclosure of OpenSSL process
memory by remote attackers.
### Which real-world packages were vulnerable?
#### [`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht)
[Mathias Buus](https://github.com/mafintosh) and I
([Feross Aboukhadijeh](http://feross.org/)) found this issue in one of our own packages,
[`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht). The bug would allow
anyone on the internet to send a series of messages to a user of `bittorrent-dht` and get
them to reveal 20 bytes at a time of uninitialized memory from the node.js process.
Here's
[the commit](https://github.com/feross/bittorrent-dht/commit/6c7da04025d5633699800a99ec3fbadf70ad35b8)
that fixed it. We released a new fixed version, created a
[Node Security Project disclosure](https://nodesecurity.io/advisories/68), and deprecated all
vulnerable versions on npm so users will get a warning to upgrade to a newer version.
#### [`ws`](https://www.npmjs.com/package/ws)
That got us wondering if there were other vulnerable packages. Sure enough, within a short
period of time, we found the same issue in [`ws`](https://www.npmjs.com/package/ws), the
most popular WebSocket implementation in node.js.
If certain APIs were called with `Number` parameters instead of `String` or `Buffer` as
expected, then uninitialized server memory would be disclosed to the remote peer.
These were the vulnerable methods:
```js
socket.send(number)
socket.ping(number)
socket.pong(number)
```
Here's a vulnerable socket server with some echo functionality:
```js
server.on('connection', function (socket) {
socket.on('message', function (message) {
message = JSON.parse(message)
if (message.type === 'echo') {
socket.send(message.data) // send back the user's message
}
})
})
```
`socket.send(number)` called on the server, will disclose server memory.
Here's [the release](https://github.com/websockets/ws/releases/tag/1.0.1) where the issue
was fixed, with a more detailed explanation. Props to
[Arnout Kazemier](https://github.com/3rd-Eden) for the quick fix. Here's the
[Node Security Project disclosure](https://nodesecurity.io/advisories/67).
### What's the solution?
It's important that node.js offers a fast way to get memory otherwise performance-critical
applications would needlessly get a lot slower.
But we need a better way to *signal our intent* as programmers. **When we want
uninitialized memory, we should request it explicitly.**
Sensitive functionality should not be packed into a developer-friendly API that loosely
accepts many different types. This type of API encourages the lazy practice of passing
variables in without checking the type very carefully.
#### A new API: `Buffer.allocUnsafe(number)`
The functionality of creating buffers with uninitialized memory should be part of another
API. We propose `Buffer.allocUnsafe(number)`. This way, it's not part of an API that
frequently gets user input of all sorts of different types passed into it.
```js
var buf = Buffer.allocUnsafe(16) // careful, uninitialized memory!
// Immediately overwrite the uninitialized buffer with data from another buffer
for (var i = 0; i < buf.length; i++) {
buf[i] = otherBuf[i]
}
```
### How do we fix node.js core?
We sent [a PR to node.js core](https://github.com/nodejs/node/pull/4514) (merged as
`semver-major`) which defends against one case:
```js
var str = 16
new Buffer(str, 'utf8')
```
In this situation, it's implied that the programmer intended the first argument to be a
string, since they passed an encoding as a second argument. Today, node.js will allocate
uninitialized memory in the case of `new Buffer(number, encoding)`, which is probably not
what the programmer intended.
But this is only a partial solution, since if the programmer does `new Buffer(variable)`
(without an `encoding` parameter) there's no way to know what they intended. If `variable`
is sometimes a number, then uninitialized memory will sometimes be returned.
### What's the real long-term fix?
We could deprecate and remove `new Buffer(number)` and use `Buffer.allocUnsafe(number)` when
we need uninitialized memory. But that would break 1000s of packages.
~~We believe the best solution is to:~~
~~1. Change `new Buffer(number)` to return safe, zeroed-out memory~~
~~2. Create a new API for creating uninitialized Buffers. We propose: `Buffer.allocUnsafe(number)`~~
#### Update
We now support adding three new APIs:
- `Buffer.from(value)` - convert from any type to a buffer
- `Buffer.alloc(size)` - create a zero-filled buffer
- `Buffer.allocUnsafe(size)` - create an uninitialized buffer with given size
This solves the core problem that affected `ws` and `bittorrent-dht` which is
`Buffer(variable)` getting tricked into taking a number argument.
This way, existing code continues working and the impact on the npm ecosystem will be
minimal. Over time, npm maintainers can migrate performance-critical code to use
`Buffer.allocUnsafe(number)` instead of `new Buffer(number)`.
### Conclusion
We think there's a serious design issue with the `Buffer` API as it exists today. It
promotes insecure software by putting high-risk functionality into a convenient API
with friendly "developer ergonomics".
This wasn't merely a theoretical exercise because we found the issue in some of the
most popular npm packages.
Fortunately, there's an easy fix that can be applied today. Use `safe-buffer` in place of
`buffer`.
```js
var Buffer = require('safe-buffer').Buffer
```
Eventually, we hope that node.js core can switch to this new, safer behavior. We believe
the impact on the ecosystem would be minimal since it's not a breaking change.
Well-maintained, popular packages would be updated to use `Buffer.alloc` quickly, while
older, insecure packages would magically become safe from this attack vector.
## links
- [Node.js PR: buffer: throw if both length and enc are passed](https://github.com/nodejs/node/pull/4514)
- [Node Security Project disclosure for `ws`](https://nodesecurity.io/advisories/67)
- [Node Security Project disclosure for`bittorrent-dht`](https://nodesecurity.io/advisories/68)
## credit
The original issues in `bittorrent-dht`
([disclosure](https://nodesecurity.io/advisories/68)) and
`ws` ([disclosure](https://nodesecurity.io/advisories/67)) were discovered by
[Mathias Buus](https://github.com/mafintosh) and
[Feross Aboukhadijeh](http://feross.org/).
Thanks to [Adam Baldwin](https://github.com/evilpacket) for helping disclose these issues
and for his work running the [Node Security Project](https://nodesecurity.io/).
Thanks to [John Hiesey](https://github.com/jhiesey) for proofreading this README and
auditing the code.
## license
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org)

187
node_modules/safe-buffer/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,187 @@
declare module "safe-buffer" {
export class Buffer {
length: number
write(string: string, offset?: number, length?: number, encoding?: string): number;
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): { type: 'Buffer', data: any[] };
equals(otherBuffer: Buffer): boolean;
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt8(offset: number, noAssert?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readInt8(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readFloatLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
swap16(): Buffer;
swap32(): Buffer;
swap64(): Buffer;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): this;
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
/**
* Allocates a new buffer containing the given {str}.
*
* @param str String to store in buffer.
* @param encoding encoding to use, optional. Default is 'utf8'
*/
constructor (str: string, encoding?: string);
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
*/
constructor (size: number);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: Uint8Array);
/**
* Produces a Buffer backed by the same allocated memory as
* the given {ArrayBuffer}.
*
*
* @param arrayBuffer The ArrayBuffer with which to share memory.
*/
constructor (arrayBuffer: ArrayBuffer);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: any[]);
/**
* Copies the passed {buffer} data onto a new {Buffer} instance.
*
* @param buffer The buffer to copy.
*/
constructor (buffer: Buffer);
prototype: Buffer;
/**
* Allocates a new Buffer using an {array} of octets.
*
* @param array
*/
static from(array: any[]): Buffer;
/**
* When passed a reference to the .buffer property of a TypedArray instance,
* the newly created Buffer will share the same allocated memory as the TypedArray.
* The optional {byteOffset} and {length} arguments specify a memory range
* within the {arrayBuffer} that will be shared by the Buffer.
*
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
* @param byteOffset
* @param length
*/
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
/**
* Copies the passed {buffer} data onto a new Buffer instance.
*
* @param buffer
*/
static from(buffer: Buffer): Buffer;
/**
* Creates a new Buffer containing the given JavaScript string {str}.
* If provided, the {encoding} parameter identifies the character encoding.
* If not provided, {encoding} defaults to 'utf8'.
*
* @param str
*/
static from(str: string, encoding?: string): Buffer;
/**
* Returns true if {obj} is a Buffer
*
* @param obj object to test.
*/
static isBuffer(obj: any): obj is Buffer;
/**
* Returns true if {encoding} is a valid encoding argument.
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
*
* @param encoding string to test.
*/
static isEncoding(encoding: string): boolean;
/**
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
* This is not the same as String.prototype.length since that returns the number of characters in a string.
*
* @param string string to test.
* @param encoding encoding used to evaluate (defaults to 'utf8')
*/
static byteLength(string: string, encoding?: string): number;
/**
* Returns a buffer which is the result of concatenating all the buffers in the list together.
*
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
* If the list has exactly one item, then the first item of the list is returned.
* If the list has more than one item, then a new Buffer is created.
*
* @param list An array of Buffer objects to concatenate
* @param totalLength Total length of the buffers when concatenated.
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
*/
static concat(list: Buffer[], totalLength?: number): Buffer;
/**
* The same as buf1.compare(buf2).
*/
static compare(buf1: Buffer, buf2: Buffer): number;
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
* If parameter is omitted, buffer will be filled with zeros.
* @param encoding encoding used for call to buf.fill while initalizing
*/
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
/**
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafe(size: number): Buffer;
/**
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafeSlow(size: number): Buffer;
}
}

64
node_modules/safe-buffer/index.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
/* eslint-disable node/no-deprecated-api */
var buffer = require('buffer')
var Buffer = buffer.Buffer
// alternative to using Object.keys for old browsers
function copyProps (src, dst) {
for (var key in src) {
dst[key] = src[key]
}
}
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer
} else {
// Copy properties from require('buffer')
copyProps(buffer, exports)
exports.Buffer = SafeBuffer
}
function SafeBuffer (arg, encodingOrOffset, length) {
return Buffer(arg, encodingOrOffset, length)
}
SafeBuffer.prototype = Object.create(Buffer.prototype)
// Copy static methods from Buffer
copyProps(Buffer, SafeBuffer)
SafeBuffer.from = function (arg, encodingOrOffset, length) {
if (typeof arg === 'number') {
throw new TypeError('Argument must not be a number')
}
return Buffer(arg, encodingOrOffset, length)
}
SafeBuffer.alloc = function (size, fill, encoding) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
var buf = Buffer(size)
if (fill !== undefined) {
if (typeof encoding === 'string') {
buf.fill(fill, encoding)
} else {
buf.fill(fill)
}
} else {
buf.fill(0)
}
return buf
}
SafeBuffer.allocUnsafe = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return Buffer(size)
}
SafeBuffer.allocUnsafeSlow = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return buffer.SlowBuffer(size)
}

67
node_modules/safe-buffer/package.json generated vendored Normal file
View File

@ -0,0 +1,67 @@
{
"_from": "safe-buffer@~5.2.0",
"_id": "safe-buffer@5.2.0",
"_inBundle": false,
"_integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==",
"_location": "/safe-buffer",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "safe-buffer@~5.2.0",
"name": "safe-buffer",
"escapedName": "safe-buffer",
"rawSpec": "~5.2.0",
"saveSpec": null,
"fetchSpec": "~5.2.0"
},
"_requiredBy": [
"/cp-file",
"/got",
"/registry-auth-token",
"/request",
"/string_decoder",
"/tunnel-agent"
],
"_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"_shasum": "b74daec49b1148f88c64b68d49b1e815c1f2f519",
"_spec": "safe-buffer@~5.2.0",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/string_decoder",
"author": {
"name": "Feross Aboukhadijeh",
"email": "feross@feross.org",
"url": "http://feross.org"
},
"bugs": {
"url": "https://github.com/feross/safe-buffer/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Safer Node.js Buffer API",
"devDependencies": {
"standard": "*",
"tape": "^4.0.0"
},
"homepage": "https://github.com/feross/safe-buffer",
"keywords": [
"buffer",
"buffer allocate",
"node security",
"safe",
"safe-buffer",
"security",
"uninitialized"
],
"license": "MIT",
"main": "index.js",
"name": "safe-buffer",
"repository": {
"type": "git",
"url": "git://github.com/feross/safe-buffer.git"
},
"scripts": {
"test": "standard && tape test/*.js"
},
"types": "index.d.ts",
"version": "5.2.0"
}

6
node_modules/stream-shift/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,6 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "4"
- "6"

21
node_modules/stream-shift/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Mathias Buus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

25
node_modules/stream-shift/README.md generated vendored Normal file
View File

@ -0,0 +1,25 @@
# stream-shift
Returns the next buffer/object in a stream's readable queue
```
npm install stream-shift
```
[![build status](http://img.shields.io/travis/mafintosh/stream-shift.svg?style=flat)](http://travis-ci.org/mafintosh/stream-shift)
## Usage
``` js
var shift = require('stream-shift')
console.log(shift(someStream)) // first item in its buffer
```
## Credit
Thanks [@dignifiedquire](https://github.com/dignifiedquire) for making this work on node 6
## License
MIT

20
node_modules/stream-shift/index.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
module.exports = shift
function shift (stream) {
var rs = stream._readableState
if (!rs) return null
return (rs.objectMode || typeof stream._duplexState === 'number') ? stream.read() : stream.read(getStateLength(rs))
}
function getStateLength (state) {
if (state.buffer.length) {
// Since node 6.3.0 state.buffer is a BufferList not an array
if (state.buffer.head) {
return state.buffer.head.data.length
}
return state.buffer[0].length
}
return state.length
}

53
node_modules/stream-shift/package.json generated vendored Normal file
View File

@ -0,0 +1,53 @@
{
"_from": "stream-shift@^1.0.0",
"_id": "stream-shift@1.0.1",
"_inBundle": false,
"_integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==",
"_location": "/stream-shift",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "stream-shift@^1.0.0",
"name": "stream-shift",
"escapedName": "stream-shift",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/duplexify"
],
"_resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz",
"_shasum": "d7088281559ab2778424279b0877da3c392d5a3d",
"_spec": "stream-shift@^1.0.0",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/duplexify",
"author": {
"name": "Mathias Buus",
"url": "@mafintosh"
},
"bugs": {
"url": "https://github.com/mafintosh/stream-shift/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Returns the next buffer/object in a stream's readable queue",
"devDependencies": {
"standard": "^7.1.2",
"tape": "^4.6.0",
"through2": "^2.0.1"
},
"homepage": "https://github.com/mafintosh/stream-shift",
"license": "MIT",
"main": "index.js",
"name": "stream-shift",
"repository": {
"type": "git",
"url": "git+https://github.com/mafintosh/stream-shift.git"
},
"scripts": {
"test": "standard && tape test.js"
},
"version": "1.0.1"
}

48
node_modules/stream-shift/test.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
var tape = require('tape')
var through = require('through2')
var stream = require('stream')
var shift = require('./')
tape('shifts next', function (t) {
var passthrough = through()
passthrough.write('hello')
passthrough.write('world')
t.same(shift(passthrough), Buffer('hello'))
t.same(shift(passthrough), Buffer('world'))
t.end()
})
tape('shifts next with core', function (t) {
var passthrough = stream.PassThrough()
passthrough.write('hello')
passthrough.write('world')
t.same(shift(passthrough), Buffer('hello'))
t.same(shift(passthrough), Buffer('world'))
t.end()
})
tape('shifts next with object mode', function (t) {
var passthrough = through({objectMode: true})
passthrough.write({hello: 1})
passthrough.write({world: 1})
t.same(shift(passthrough), {hello: 1})
t.same(shift(passthrough), {world: 1})
t.end()
})
tape('shifts next with object mode with core', function (t) {
var passthrough = stream.PassThrough({objectMode: true})
passthrough.write({hello: 1})
passthrough.write({world: 1})
t.same(shift(passthrough), {hello: 1})
t.same(shift(passthrough), {world: 1})
t.end()
})

8
node_modules/streamx/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,8 @@
language: node_js
node_js:
- '10'
- '12'
os:
- windows
- osx
- linux

21
node_modules/streamx/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 Mathias Buus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

366
node_modules/streamx/README.md generated vendored Normal file
View File

@ -0,0 +1,366 @@
# streamx
An iteration of the Node.js core streams with a series of improvements.
```
npm install streamx
```
[![Build Status](https://travis-ci.org/mafintosh/streamx.svg?branch=master)](https://travis-ci.org/mafintosh/streamx)
## Main improvements from Node.js core stream
#### Proper lifecycle support.
Streams have an `_open` function that is called before any read/write operation and a `_destroy`
function that is always run as the last part of the stream.
This makes it easy to maintain state.
#### Easy error handling
Fully integrates a `.destroy()` function. When called the stream will wait for any
pending operation to finish and call the stream destroy logic.
Close is *always* the last event emitted and `destroy` is always ran.
#### `pipe()` error handles
`pipe` accepts a callback that is called when the pipeline is fully drained.
It also error handles the streams provided and destroys both streams if either
of them fail.
#### All streams are both binary and object mode streams
A `map` function can be provided to map your input data into buffers
or other formats. To indicate how much buffer space each data item takes
an `byteLength` function can be provided as well.
This removes the need for two modes of streams.
#### Simplicity
This is a full rewrite, all contained in one file.
Lots of stream methods are simplified based on how I and devs I work with actually use streams in the wild.
#### Backwards compat
streamx aims to be compatible with Node.js streams whenever it is reasonable to do so.
This means that streamx streams behave a lot like Node.js streams from the outside but still provides the
improvements above.
## Usage
``` js
const { Readable } = require('streamx')
const rs = new Readable({
read (cb) {
this.push('Cool data')
cb(null)
}
})
rs.on('data', data => console.log('data:', data))
```
## API
This streamx package contains 4 streams similar to Node.js core.
## Readable Stream
#### `rs = new stream.Readable([options])`
Create a new readable stream.
Options include:
```
{
highWaterMark: 16384, // max buffer size in bytes
map: (data) => data, // optional function to map input data
byteLength: (data) => size // optional function that calculates the byte size of input data
}
```
In addition you can pass the `open`, `read`, and `destroy` functions as shorthands in
the constructor instead of overwrite the methods below.
The default byteLength function returns the byte length of buffers and `1024`
for any other object. This means the buffer will contain around 16 non buffers
or buffers worth 16kb when full if the defaults are used.
#### `rs._read(cb)`
This function is called when the stream wants you to push new data.
Overwrite this and add your own read logic.
You should call the callback when you are fully done with the read.
Can also be set using `options.read` in the constructor.
Note that this function differs from Node.js streams in that it takes
the "read finished" callback.
#### `drained = rs.push(data)`
Push new data to the stream. Returns true if the buffer is not full
and you should push more data if you can.
If you call `rs.push(null)` you signal to the stream that no more
data will be pushed and that you want to end the stream.
#### `data = rs.read()`
Read a piece of data from the stream buffer. If the buffer is currently empty
`null` will be returned and you should wait for `readable` to be emitted before
trying again. If the stream has been ended it will also return `null`.
Note that this method differs from Node.js streams in that it does not accept
an optional amounts of bytes to consume.
#### `rs.unshift(data)`
Add a piece of data to the front of the buffer. Use this if you read too much
data using the `rs.read()` function.
#### `rs._open(cb)`
This function is called once before the first read is issued. Use this function
to implement your own open logic.
Can also be set using `options.open` in the constructor.
#### `rs._destroy(cb)`
This function is called just before the stream is fully destroyed. You should
use this to implement whatever teardown logic you need. The final part of the
stream life cycle is always to call destroy itself so this function will always
be called wheather or not the stream ends gracefully or forcefully.
Can also be set using `options.destroy` in the constructor.
Note that the `_destroy` might be called without the open function being called
in case no read was ever performed on the stream.
#### `rs._predestroy()`
A simple hook that is called as soon as the first `stream.destroy()` call is invoked.
Use this in case you need to cancel pending reads (if possible) instead of waiting for them to finish.
Can also be set using `options.predestroy` in the constructor.
#### `rs.destroy([error])`
Forcefully destroy the stream. Will call `_destroy` as soon as all pending reads have finished.
Once the stream is fully destroyed `close` will be emitted.
If you pass an error this error will be emitted just before `close` is, signifying a reason
as to why this stream was destroyed.
#### `rs.pause()`
Pauses the stream. You will only need to call this if you want to pause a resumed stream.
#### `rs.resume()`
Will start reading data from the stream as fast as possible.
If you do not call this, you need to use the `read()` method to read data or the `pipe()` method to
pipe the stream somewhere else or the `data` handler.
If none of these option are used the stream will stay paused.
#### `writableStream = rs.pipe(writableStream, [callback])`
Efficently pipe the readable stream to a writable stream (can be Node.js core stream or a stream from this package).
If you provide a callback the callback is called when the pipeline has fully finished with an optional error in case
it failed.
To cancel the pipeline destroy either of the streams.
#### `rs.on('readable')`
Emitted when data is pushed to the stream if the buffer was previously empty.
#### `rs.on('data', data)`
Emitted when data is being read from the stream. If you attach a data handler you are implicitly resuming the stream.
#### `rs.on('end')`
Emitted when the readable stream has ended and no data is left in it's buffer.
#### `rs.on('close')`
Emitted when the readable stream has fully closed (i.e. it's destroy function has completed)
#### `rs.on('error', err)`
Emitted if any of the stream operations fail with an error. `close` is always emitted right after this.
#### `rs.destroyed`
Boolean property indicating wheather or not this stream has been destroyed.
#### `bool = Readable.isBackpressured(rs)`
Static method to check if a readable stream is currently under backpressure.
### `stream = Readable.from(arrayOrBufferOrStringOrAsyncIterator)
Static method to turn an array or buffer or string or AsyncIterator into a readable stream.
## Writable Stream
#### `ws = new stream.Writable([options])`
Create a new writable stream.
Options include:
```
{
highWaterMark: 16384, // max buffer size in bytes
map: (data) => data, // optional function to map input data
byteLength: (data) => size // optional function that calculates the byte size of input data
}
```
In addition you can pass the `open`, `write`, `flush`, and `destroy` functions as shorthands in
the constructor instead of overwrite the methods below.
The default byteLength function returns the byte length of buffers and `1024`
for any other object. This means the buffer will contain around 16 non buffers
or buffers worth 16kb when full if the defaults are used.
#### `ws._open(cb)`
This function is called once before the first write is issued. Use this function
to implement your own open logic.
Can also be set using `options.open` in the constructor.
#### `ws._destroy(cb)`
This function is called just before the stream is fully destroyed. You should
use this to implement whatever teardown logic you need. The final part of the
stream life cycle is always to call destroy itself so this function will always
be called wheather or not the stream ends gracefully or forcefully.
Can also be set using `options.destroy` in the constructor.
Note that the `_destroy` might be called without the open function being called
in case no write was ever performed on the stream.
#### `ws._predestroy()`
A simple hook that is called as soon as the first `stream.destroy()` call is invoked.
Use this in case you need to cancel pending writes (if possible) instead of waiting for them to finish.
Can also be set using `options.predestroy` in the constructor.
#### `ws.destroy([error])`
Forcefully destroy the stream. Will call `_destroy` as soon as all pending reads have finished.
Once the stream is fully destroyed `close` will be emitted.
If you pass an error this error will be emitted just before `close` is, signifying a reason
as to why this stream was destroyed.
#### `drained = ws.write(data)`
Write a piece of data to the stream. Returns `true` if the stream buffer is not full and you
should keep writing to it if you can. If `false` is returned the stream will emit `drain`
once it's buffer is fully drained.
#### `ws._write(data, callback)`
This function is called when the stream want to write some data. Use this to implement your own
write logic. When done call the callback and the stream will call it again if more data exists in the buffer.
Can also be set using `options.write` in the constructor.
#### `ws._writev(batch, callback)`
Similar to `_write` but passes an array of all data in the current write buffer instead of the oldest one.
Useful if the destination you are writing the data to supports batching.
Can also be set using `options.writev` in the constructor.
#### `ws.end()`
Gracefully end the writable stream. Call this when you no longer want to write to the stream.
Once all writes have been fully drained `finish` will be emitted.
#### `ws._final(callback)`
This function is called just before `finish` is emitted, i.e. when all writes have flushed but `ws.end()`
have been called. Use this to implement any logic that should happen after all writes but before finish.
Can also be set using `options.final` in the constructor.
#### `ws.on('finish')`
Emitted when the stream has been ended and all writes have been drained.
#### `ws.on('close')`
Emitted when the readable stream has fully closed (i.e. it's destroy function has completed)
#### `ws.on('error', err)`
Emitted if any of the stream operations fail with an error. `close` is always emitted right after this.
#### `ws.destroyed`
Boolean property indicating wheather or not this stream has been destroyed.
#### `bool = Writable.isBackpressured(ws)`
Static method to check if a writable stream is currently under backpressure.
## Duplex Stream
#### `s = new stream.Duplex([options])`
A duplex stream is a stream that is both readable and writable.
Since JS does not support multiple inheritance it inherits directly from Readable
but implements the Writable API as well.
If you want to provide only a map function for the readable side use `mapReadable` instead.
If you want to provide only a byteLength function for the readable side use `byteLengthReadable` instead.
Same goes for the writable side but using `mapWritable` and `byteLengthWritable` instead.
## Transform Stream
#### `ts = new stream.Transform([options])`
A transform stream is a duplex stream that maps the data written to it and emits that as readable data.
Has the same options as a duplex stream except you can provide a `transform` function also.
#### `ts._transform(data, callback)`
Transform the incoming data. Call `callback(null, mappedData)` or use `ts.push(mappedData)` to
return data to the readable side of the stream.
Per default the transform function just remits the incoming data making it act as a pass-through stream.
## Contributing
If you want to help contribute to streamx a good way to start is to help writing more test
cases, compatibility tests, documentation, or performance benchmarks.
If in doubt open an issue :)
## License
MIT

73
node_modules/streamx/examples/fs.js generated vendored Normal file
View File

@ -0,0 +1,73 @@
const fs = require('fs')
const { Writable, Readable } = require('../')
class FileWriteStream extends Writable {
constructor (filename, mode) {
super()
this.filename = filename
this.mode = mode
this.fd = 0
}
_open (cb) {
fs.open(this.filename, this.mode, (err, fd) => {
if (err) return cb(err)
this.fd = fd
cb(null)
})
}
_write (data, cb) {
fs.write(this.fd, data, 0, data.length, null, (err, written) => {
if (err) return cb(err)
if (written !== data.length) return this._write(data.slice(written), cb)
cb(null)
})
}
_destroy (cb) {
if (!this.fd) return cb()
fs.close(this.fd, cb)
}
}
class FileReadStream extends Readable {
constructor (filename) {
super()
this.filename = filename
this.fd = 0
}
_open (cb) {
fs.open(this.filename, 'r', (err, fd) => {
if (err) return cb(err)
this.fd = fd
cb(null)
})
}
_read (cb) {
let data = Buffer.alloc(16 * 1024)
fs.read(this.fd, data, 0, data.length, null, (err, read) => {
if (err) return cb(err)
if (read !== data.length) data = data.slice(0, read)
this.push(data.length ? data : null)
cb(null)
})
}
_destroy (cb) {
if (!this.fd) return cb()
fs.close(this.fd, cb)
}
}
// copy this file as an example
const rs = new FileReadStream(__filename)
const ws = new FileWriteStream(`${__filename}.cpy`, 'w')
rs.pipe(ws, function (err) {
console.log('file copied', err)
})

855
node_modules/streamx/index.js generated vendored Normal file
View File

@ -0,0 +1,855 @@
const { EventEmitter } = require('events')
const STREAM_DESTROYED = new Error('Stream was destroyed')
const FIFO = require('fast-fifo')
/* eslint-disable no-multi-spaces */
const MAX = ((1 << 25) - 1)
// Shared state
const OPENING = 0b001
const DESTROYING = 0b010
const DESTROYED = 0b100
const NOT_OPENING = MAX ^ OPENING
// Read state
const READ_ACTIVE = 0b0000000000001 << 3
const READ_PRIMARY = 0b0000000000010 << 3
const READ_SYNC = 0b0000000000100 << 3
const READ_QUEUED = 0b0000000001000 << 3
const READ_RESUMED = 0b0000000010000 << 3
const READ_PIPE_DRAINED = 0b0000000100000 << 3
const READ_ENDING = 0b0000001000000 << 3
const READ_EMIT_DATA = 0b0000010000000 << 3
const READ_EMIT_READABLE = 0b0000100000000 << 3
const READ_EMITTED_READABLE = 0b0001000000000 << 3
const READ_DONE = 0b0010000000000 << 3
const READ_NEXT_TICK = 0b0100000000001 << 3 // also active
const READ_NEEDS_PUSH = 0b1000000000000 << 3
const READ_NOT_ACTIVE = MAX ^ READ_ACTIVE
const READ_NON_PRIMARY = MAX ^ READ_PRIMARY
const READ_NON_PRIMARY_AND_PUSHED = MAX ^ (READ_PRIMARY | READ_NEEDS_PUSH)
const READ_NOT_SYNC = MAX ^ READ_SYNC
const READ_PUSHED = MAX ^ READ_NEEDS_PUSH
const READ_PAUSED = MAX ^ READ_RESUMED
const READ_NOT_QUEUED = MAX ^ (READ_QUEUED | READ_EMITTED_READABLE)
const READ_NOT_ENDING = MAX ^ READ_ENDING
const READ_PIPE_NOT_DRAINED = MAX ^ (READ_RESUMED | READ_PIPE_DRAINED)
const READ_NOT_NEXT_TICK = MAX ^ READ_NEXT_TICK
// Write state
const WRITE_ACTIVE = 0b000000001 << 16
const WRITE_PRIMARY = 0b000000010 << 16
const WRITE_SYNC = 0b000000100 << 16
const WRITE_QUEUED = 0b000001000 << 16
const WRITE_UNDRAINED = 0b000010000 << 16
const WRITE_DONE = 0b000100000 << 16
const WRITE_EMIT_DRAIN = 0b001000000 << 16
const WRITE_NEXT_TICK = 0b010000001 << 16 // also active
const WRITE_FINISHING = 0b100000000 << 16
const WRITE_NOT_ACTIVE = MAX ^ WRITE_ACTIVE
const WRITE_NOT_SYNC = MAX ^ WRITE_SYNC
const WRITE_NON_PRIMARY = MAX ^ WRITE_PRIMARY
const WRITE_NOT_FINISHING = MAX ^ WRITE_FINISHING
const WRITE_DRAINED = MAX ^ WRITE_UNDRAINED
const WRITE_NOT_QUEUED = MAX ^ WRITE_QUEUED
const WRITE_NOT_NEXT_TICK = MAX ^ WRITE_NEXT_TICK
// Combined shared state
const ACTIVE = READ_ACTIVE | WRITE_ACTIVE
const NOT_ACTIVE = MAX ^ ACTIVE
const DONE = READ_DONE | WRITE_DONE
const DESTROY_STATUS = DESTROYING | DESTROYED
const OPEN_STATUS = DESTROY_STATUS | OPENING
const AUTO_DESTROY = DESTROY_STATUS | DONE
const NON_PRIMARY = WRITE_NON_PRIMARY & READ_NON_PRIMARY
// Combined read state
const READ_PRIMARY_STATUS = OPEN_STATUS | READ_ENDING | READ_DONE
const READ_STATUS = OPEN_STATUS | READ_DONE | READ_QUEUED
const READ_FLOWING = READ_RESUMED | READ_PIPE_DRAINED
const READ_ACTIVE_AND_SYNC = READ_ACTIVE | READ_SYNC
const READ_ACTIVE_AND_SYNC_AND_NEEDS_PUSH = READ_ACTIVE | READ_SYNC | READ_NEEDS_PUSH
const READ_PRIMARY_AND_ACTIVE = READ_PRIMARY | READ_ACTIVE
const READ_ENDING_STATUS = OPEN_STATUS | READ_ENDING | READ_QUEUED
const READ_EMIT_READABLE_AND_QUEUED = READ_EMIT_READABLE | READ_QUEUED
const READ_READABLE_STATUS = OPEN_STATUS | READ_EMIT_READABLE | READ_QUEUED | READ_EMITTED_READABLE
const SHOULD_NOT_READ = OPEN_STATUS | READ_ACTIVE | READ_ENDING | READ_DONE | READ_NEEDS_PUSH
const READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE
// Combined write state
const WRITE_PRIMARY_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_DONE
const WRITE_QUEUED_AND_UNDRAINED = WRITE_QUEUED | WRITE_UNDRAINED
const WRITE_QUEUED_AND_ACTIVE = WRITE_QUEUED | WRITE_ACTIVE
const WRITE_DRAIN_STATUS = WRITE_QUEUED | WRITE_UNDRAINED | OPEN_STATUS | WRITE_ACTIVE
const WRITE_STATUS = OPEN_STATUS | WRITE_ACTIVE | WRITE_QUEUED
const WRITE_PRIMARY_AND_ACTIVE = WRITE_PRIMARY | WRITE_ACTIVE
const WRITE_ACTIVE_AND_SYNC = WRITE_ACTIVE | WRITE_SYNC
const WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED
const WRITE_BACKPRESSURE_STATUS = WRITE_UNDRAINED | DESTROY_STATUS | WRITE_FINISHING | WRITE_DONE
const asyncIterator = Symbol.asyncIterator || Symbol('asyncIterator')
class WritableState {
constructor (stream, { highWaterMark = 16384, map = null, mapWritable, byteLength, byteLengthWritable } = {}) {
this.stream = stream
this.queue = new FIFO()
this.highWaterMark = highWaterMark
this.buffered = 0
this.error = null
this.pipeline = null
this.byteLength = byteLengthWritable || byteLength || defaultByteLength
this.map = mapWritable || map
this.afterWrite = afterWrite.bind(this)
}
push (data) {
if (this.map !== null) data = this.map(data)
this.buffered += this.byteLength(data)
this.queue.push(data)
if (this.buffered < this.highWaterMark) {
this.stream._duplexState |= WRITE_QUEUED
return true
}
this.stream._duplexState |= WRITE_QUEUED_AND_UNDRAINED
return false
}
shift () {
const data = this.queue.shift()
const stream = this.stream
this.buffered -= this.byteLength(data)
if (this.buffered === 0) stream._duplexState &= WRITE_NOT_QUEUED
return data
}
end (data) {
if (data !== undefined && data !== null) this.push(data)
this.stream._duplexState = (this.stream._duplexState | WRITE_FINISHING) & WRITE_NON_PRIMARY
}
autoBatch (data, cb) {
const buffer = []
const stream = this.stream
buffer.push(data)
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED_AND_ACTIVE) {
buffer.push(stream._writableState.shift())
}
if ((stream._duplexState & OPEN_STATUS) !== 0) return cb(null)
stream._writev(buffer, cb)
}
update () {
const stream = this.stream
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
const data = this.shift()
stream._duplexState |= WRITE_ACTIVE_AND_SYNC
stream._write(data, this.afterWrite)
stream._duplexState &= WRITE_NOT_SYNC
}
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
}
updateNonPrimary () {
const stream = this.stream
if ((stream._duplexState & WRITE_FINISHING_STATUS) === WRITE_FINISHING) {
stream._duplexState = (stream._duplexState | WRITE_ACTIVE) & WRITE_NOT_FINISHING
stream._final(afterFinal.bind(this))
return
}
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
if ((stream._duplexState & ACTIVE) === 0) {
stream._duplexState |= ACTIVE
stream._destroy(afterDestroy.bind(this))
}
return
}
if ((stream._duplexState & OPEN_STATUS) === OPENING) {
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING
stream._open(afterOpen.bind(this))
}
}
updateNextTick () {
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return
this.stream._duplexState |= WRITE_NEXT_TICK
process.nextTick(updateWriteNT, this)
}
}
class ReadableState {
constructor (stream, { highWaterMark = 16384, map = null, mapReadable, byteLength, byteLengthReadable } = {}) {
this.stream = stream
this.queue = new FIFO()
this.highWaterMark = highWaterMark
this.buffered = 0
this.error = null
this.pipeline = null
this.byteLength = byteLengthReadable || byteLength || defaultByteLength
this.map = mapReadable || map
this.pipeTo = null
this.afterRead = afterRead.bind(this)
}
pipe (pipeTo, cb) {
if (this.pipeTo !== null) throw new Error('Can only pipe to one destination')
this.stream._duplexState |= READ_PIPE_DRAINED
this.pipeTo = pipeTo
this.pipeline = new Pipeline(this.stream, pipeTo, cb || null)
if (cb) this.stream.on('error', noop) // We already error handle this so supress crashes
if (isStreamx(pipeTo)) {
pipeTo._writableState.pipeline = this.pipeline
if (cb) pipeTo.on('error', noop) // We already error handle this so supress crashes
pipeTo.on('finish', this.pipeline.finished.bind(this.pipeline)) // TODO: just call finished from pipeTo itself
} else {
const onerror = this.pipeline.done.bind(this.pipeline, pipeTo)
const onclose = this.pipeline.done.bind(this.pipeline, pipeTo, null) // onclose has a weird bool arg
pipeTo.on('error', onerror)
pipeTo.on('close', onclose)
pipeTo.on('finish', this.pipeline.finished.bind(this.pipeline))
}
pipeTo.on('drain', afterDrain.bind(this))
this.stream.emit('pipe', pipeTo)
}
push (data) {
const stream = this.stream
if (data === null) {
this.highWaterMark = 0
stream._duplexState = (stream._duplexState | READ_ENDING) & READ_NON_PRIMARY_AND_PUSHED
return false
}
if (this.map !== null) data = this.map(data)
this.buffered += this.byteLength(data)
this.queue.push(data)
stream._duplexState = (stream._duplexState | READ_QUEUED) & READ_PUSHED
return this.buffered < this.highWaterMark
}
shift () {
const data = this.queue.shift()
this.buffered -= this.byteLength(data)
if (this.buffered === 0) this.stream._duplexState &= READ_NOT_QUEUED
return data
}
unshift (data) {
let tail
const pending = []
while ((tail === this.queue.shift()) !== undefined) {
pending.push(tail)
}
this.push(data)
for (let i = 0; i < pending.length; i++) {
this.queue.push(pending[i])
}
}
read () {
const stream = this.stream
if ((stream._duplexState & READ_STATUS) === READ_QUEUED) {
const data = this.shift()
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit('data', data)
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED
return data
}
return null
}
drain () {
const stream = this.stream
while ((stream._duplexState & READ_STATUS) === READ_QUEUED && (stream._duplexState & READ_FLOWING) !== 0) {
const data = this.shift()
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit('data', data)
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED
}
}
update () {
const stream = this.stream
this.drain()
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === 0) {
stream._duplexState |= READ_ACTIVE_AND_SYNC_AND_NEEDS_PUSH
stream._read(this.afterRead)
stream._duplexState &= READ_NOT_SYNC
if ((stream._duplexState & READ_ACTIVE) === 0) this.drain()
}
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
stream._duplexState |= READ_EMITTED_READABLE
stream.emit('readable')
}
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
}
updateNonPrimary () {
const stream = this.stream
if ((stream._duplexState & READ_ENDING_STATUS) === READ_ENDING) {
stream._duplexState = (stream._duplexState | READ_DONE) & READ_NOT_ENDING
stream.emit('end')
if ((stream._duplexState & AUTO_DESTROY) === DONE) stream._duplexState |= DESTROYING
if (this.pipeTo !== null) this.pipeTo.end()
}
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
if ((stream._duplexState & ACTIVE) === 0) {
stream._duplexState |= ACTIVE
stream._destroy(afterDestroy.bind(this))
}
return
}
if ((stream._duplexState & OPEN_STATUS) === OPENING) {
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING
stream._open(afterOpen.bind(this))
}
}
updateNextTick () {
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return
this.stream._duplexState |= READ_NEXT_TICK
process.nextTick(updateReadNT, this)
}
}
class TransformState {
constructor (stream) {
this.data = null
this.afterTransform = afterTransform.bind(stream)
this.afterFinal = null
}
}
class Pipeline {
constructor (src, dst, cb) {
this.from = src
this.to = dst
this.afterPipe = cb
this.error = null
this.pipeToFinished = false
}
finished () {
this.pipeToFinished = true
}
done (stream, err) {
if (err) this.error = err
if (stream === this.to) {
this.to = null
if (this.from !== null) {
if ((this.from._duplexState & READ_DONE) === 0 || !this.pipeToFinished) {
this.from.destroy(new Error('Writable stream closed prematurely'))
}
return
}
}
if (stream === this.from) {
this.from = null
if (this.to !== null) {
if ((stream._duplexState & READ_DONE) === 0) {
this.to.destroy(new Error('Readable stream closed before ending'))
}
return
}
}
if (this.afterPipe !== null) this.afterPipe(this.error)
this.to = this.from = this.afterPipe = null
}
}
function afterDrain () {
this.stream._duplexState |= READ_PIPE_DRAINED
if ((this.stream._duplexState & READ_ACTIVE_AND_SYNC) === 0) this.updateNextTick()
}
function afterFinal (err) {
const stream = this.stream
if (err) stream.destroy(err)
if ((stream._duplexState & DESTROY_STATUS) === 0) {
stream._duplexState |= WRITE_DONE
stream.emit('finish')
}
if ((stream._duplexState & AUTO_DESTROY) === DONE) {
stream._duplexState |= DESTROYING
}
stream._duplexState &= WRITE_NOT_ACTIVE
this.update()
}
function afterDestroy (err) {
const stream = this.stream
if (!err && this.error !== STREAM_DESTROYED) err = this.error
if (err) stream.emit('error', err)
stream._duplexState |= DESTROYED
stream.emit('close')
const rs = stream._readableState
const ws = stream._writableState
if (rs !== null && rs.pipeline !== null) rs.pipeline.done(stream, err)
if (ws !== null && ws.pipeline !== null) ws.pipeline.done(stream, err)
}
function afterWrite (err) {
const stream = this.stream
if (err) stream.destroy(err)
stream._duplexState &= WRITE_NOT_ACTIVE
if ((stream._duplexState & WRITE_DRAIN_STATUS) === WRITE_UNDRAINED) {
stream._duplexState &= WRITE_DRAINED
if ((stream._duplexState & WRITE_EMIT_DRAIN) === WRITE_EMIT_DRAIN) {
stream.emit('drain')
}
}
if ((stream._duplexState & WRITE_SYNC) === 0) this.update()
}
function afterRead (err) {
if (err) this.stream.destroy(err)
this.stream._duplexState &= READ_NOT_ACTIVE
if ((this.stream._duplexState & READ_SYNC) === 0) this.update()
}
function updateReadNT (rs) {
rs.stream._duplexState &= READ_NOT_NEXT_TICK
rs.update()
}
function updateWriteNT (ws) {
ws.stream._duplexState &= WRITE_NOT_NEXT_TICK
ws.update()
}
function afterOpen (err) {
const stream = this.stream
if (err) stream.destroy(err)
if ((stream._duplexState & DESTROYING) === 0) {
if ((stream._duplexState & READ_PRIMARY_STATUS) === 0) stream._duplexState |= READ_PRIMARY
if ((stream._duplexState & WRITE_PRIMARY_STATUS) === 0) stream._duplexState |= WRITE_PRIMARY
stream.emit('open')
}
stream._duplexState &= NOT_ACTIVE
if (stream._writableState !== null) {
stream._writableState.update()
}
if (stream._readableState !== null) {
stream._readableState.update()
}
}
function afterTransform (err, data) {
if (data !== undefined && data !== null) this.push(data)
this._writableState.afterWrite(err)
}
class Stream extends EventEmitter {
constructor (opts) {
super()
this._duplexState = 0
this._readableState = null
this._writableState = null
if (opts) {
if (opts.open) this._open = opts.open
if (opts.destroy) this._destroy = opts.destroy
if (opts.predestroy) this._predestroy = opts.predestroy
}
}
_open (cb) {
cb(null)
}
_destroy (cb) {
cb(null)
}
_predestroy () {
// does nothing
}
get readable () {
return this._readableState !== null
}
get writable () {
return this._writableState !== null
}
get destroyed () {
return (this._duplexState & DESTROYED) !== 0
}
get destroying () {
return (this._duplexState & DESTROY_STATUS) !== 0
}
destroy (err) {
if ((this._duplexState & DESTROY_STATUS) === 0) {
if (!err) err = STREAM_DESTROYED
this._duplexState = (this._duplexState | DESTROYING) & NON_PRIMARY
this._predestroy()
if (this._readableState !== null) {
this._readableState.error = err
this._readableState.updateNextTick()
}
if (this._writableState !== null) {
this._writableState.error = err
this._writableState.updateNextTick()
}
}
}
on (name, fn) {
if (this._readableState !== null) {
if (name === 'data') {
this._duplexState |= (READ_EMIT_DATA | READ_RESUMED)
this._readableState.updateNextTick()
}
if (name === 'readable') {
this._duplexState |= READ_EMIT_READABLE
this._readableState.updateNextTick()
}
}
if (this._writableState !== null) {
if (name === 'drain') {
this._duplexState |= WRITE_EMIT_DRAIN
this._writableState.updateNextTick()
}
}
return super.on(name, fn)
}
}
class Readable extends Stream {
constructor (opts) {
super(opts)
this._duplexState |= OPENING | WRITE_DONE
this._readableState = new ReadableState(this, opts)
if (opts) {
if (opts.read) this._read = opts.read
}
}
_read (cb) {
cb(null)
}
pipe (dest, cb) {
this._readableState.pipe(dest, cb)
this._readableState.updateNextTick()
return dest
}
read () {
this._readableState.updateNextTick()
return this._readableState.read()
}
push (data) {
this._readableState.updateNextTick()
return this._readableState.push(data)
}
unshift (data) {
this._readableState.updateNextTick()
return this._readableState.unshift(data)
}
resume () {
this._duplexState |= READ_RESUMED
this._readableState.updateNextTick()
}
pause () {
this._duplexState &= READ_PAUSED
}
static _fromAsyncIterator (ite) {
let destroy
const rs = new Readable({
read (cb) {
ite.next().then(push).then(cb.bind(null, null)).catch(cb)
},
predestroy () {
destroy = ite.return()
},
destroy (cb) {
destroy.then(cb.bind(null, null)).catch(cb)
}
})
return rs
function push (data) {
if (data.done) rs.push(null)
else rs.push(data.value)
}
}
static from (data) {
if (data[asyncIterator]) return this._fromAsyncIterator(data[asyncIterator]())
if (!Array.isArray(data)) data = data === undefined ? [] : [data]
let i = 0
return new Readable({
read (cb) {
this.push(i === data.length ? null : data[i++])
cb(null)
}
})
}
static isBackpressured (rs) {
return (rs._duplexState & READ_BACKPRESSURE_STATUS) !== 0 || rs._readableState.buffered >= rs._readableState.highWaterMark
}
[asyncIterator] () {
const stream = this
let error = null
let ended = false
let promiseResolve
let promiseReject
this.on('error', (err) => { error = err })
this.on('end', () => { ended = true })
this.on('close', () => call(error, null))
this.on('readable', () => call(null, stream.read()))
return {
[asyncIterator] () {
return this
},
next () {
return new Promise(function (resolve, reject) {
promiseResolve = resolve
promiseReject = reject
const data = stream.read()
if (data !== null) call(null, data)
})
},
return () {
stream.destroy()
}
}
function call (err, data) {
if (promiseReject === null) return
if (err) promiseReject(err)
else if (data === null && !ended) promiseReject(STREAM_DESTROYED)
else promiseResolve({ value: data, done: data === null })
promiseReject = promiseResolve = null
}
}
}
class Writable extends Stream {
constructor (opts) {
super(opts)
this._duplexState |= OPENING | READ_DONE
this._writableState = new WritableState(this, opts)
if (opts) {
if (opts.writev) this._writev = opts.writev
if (opts.write) this._write = opts.write
if (opts.final) this._final = opts.final
}
}
_writev (batch, cb) {
cb(null)
}
_write (data, cb) {
this._writableState.autoBatch(data, cb)
}
_final (cb) {
cb(null)
}
static isBackpressured (ws) {
return (ws._duplexState & WRITE_BACKPRESSURE_STATUS) !== 0
}
write (data) {
this._writableState.updateNextTick()
return this._writableState.push(data)
}
end (data) {
this._writableState.updateNextTick()
this._writableState.end(data)
}
}
class Duplex extends Readable { // and Writable
constructor (opts) {
super(opts)
this._duplexState = OPENING
this._writableState = new WritableState(this, opts)
if (opts) {
if (opts.writev) this._writev = opts.writev
if (opts.write) this._write = opts.write
if (opts.final) this._final = opts.final
}
}
_writev (batch, cb) {
cb(null)
}
_write (data, cb) {
this._writableState.autoBatch(data, cb)
}
_final (cb) {
cb(null)
}
write (data) {
this._writableState.updateNextTick()
return this._writableState.push(data)
}
end (data) {
this._writableState.updateNextTick()
this._writableState.end(data)
}
}
class Transform extends Duplex {
constructor (opts) {
super(opts)
this._transformState = new TransformState(this)
if (opts) {
if (opts.transform) this._transform = opts.transform
if (opts.flush) this._flush = opts.flush
}
}
_write (data, cb) {
if (this._readableState.buffered >= this._readableState.highWaterMark) {
this._transformState.data = data
} else {
this._transform(data, this._transformState.afterTransform)
}
}
_read (cb) {
if (this._transformState.data !== null) {
const data = this._transformState.data
this._transformState.data = null
cb(null)
this._transform(data, this._transformState.afterTransform)
} else {
cb(null)
}
}
_transform (data, cb) {
cb(null, data)
}
_flush (cb) {
cb(null)
}
_final (cb) {
this._transformState.afterFinal = cb
this._flush(transformAfterFlush.bind(this))
}
}
function transformAfterFlush (err, data) {
const cb = this._transformState.afterFinal
if (err) return cb(err)
if (data !== null && data !== undefined) this.push(data)
this.push(null)
cb(null)
}
function isStream (stream) {
return !!stream._readableState || !!stream._writableState
}
function isStreamx (stream) {
return typeof stream._duplexState === 'number' && isStream(stream)
}
function defaultByteLength (data) {
return Buffer.isBuffer(data) ? data.length : 1024
}
function noop () {}
module.exports = {
isStream,
isStreamx,
Stream,
Writable,
Readable,
Duplex,
Transform
}

56
node_modules/streamx/package.json generated vendored Normal file
View File

@ -0,0 +1,56 @@
{
"_from": "streamx@^2.6.0",
"_id": "streamx@2.6.0",
"_inBundle": false,
"_integrity": "sha512-fDIdCkmCjhNt9/IIFL6UdJeqyOpDoX9rHXdRt5hpYQQ1owCSyVieQtTkbXcZAsASS9F5JrlxwKLHkv5w2GHVvA==",
"_location": "/streamx",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "streamx@^2.6.0",
"name": "streamx",
"escapedName": "streamx",
"rawSpec": "^2.6.0",
"saveSpec": null,
"fetchSpec": "^2.6.0"
},
"_requiredBy": [
"/async-neocities"
],
"_resolved": "https://registry.npmjs.org/streamx/-/streamx-2.6.0.tgz",
"_shasum": "f7aa741edc8142666c12d09479e708fdc2a09c33",
"_spec": "streamx@^2.6.0",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/async-neocities",
"author": {
"name": "Mathias Buus",
"url": "@mafintosh"
},
"bugs": {
"url": "https://github.com/mafintosh/streamx/issues"
},
"bundleDependencies": false,
"dependencies": {
"fast-fifo": "^1.0.0",
"nanoassert": "^2.0.0"
},
"deprecated": false,
"description": "An iteration of the Node.js core streams with a series of improvements",
"devDependencies": {
"end-of-stream": "^1.4.1",
"standard": "^14.3.1",
"tape": "^4.11.0"
},
"homepage": "https://github.com/mafintosh/streamx",
"license": "MIT",
"main": "index.js",
"name": "streamx",
"repository": {
"type": "git",
"url": "git+https://github.com/mafintosh/streamx.git"
},
"scripts": {
"test": "standard && tape test/*.js"
},
"version": "2.6.0"
}

21
node_modules/streamx/test/async-iterator.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
const tape = require('tape')
const { Readable } = require('../')
tape('streams are async iterators', async function (t) {
const data = ['a', 'b', 'c', null]
const expected = data.slice(0)
const r = new Readable({
read (cb) {
this.push(data.shift())
cb(null)
}
})
for await (const chunk of r) {
t.same(chunk, expected.shift())
}
t.same(expected, [null])
t.end()
})

105
node_modules/streamx/test/backpressure.js generated vendored Normal file
View File

@ -0,0 +1,105 @@
const tape = require('tape')
const { Writable, Readable } = require('../')
tape('write backpressure', function (t) {
const ws = new Writable()
for (let i = 0; i < 15; i++) {
t.ok(ws.write('a'), 'not backpressured')
t.notOk(Writable.isBackpressured(ws), 'static check')
}
t.notOk(ws.write('a'), 'backpressured')
t.ok(Writable.isBackpressured(ws), 'static check')
t.end()
})
tape('write backpressure with drain', function (t) {
const ws = new Writable()
for (let i = 0; i < 15; i++) {
t.ok(ws.write('a'), 'not backpressured')
t.notOk(Writable.isBackpressured(ws), 'static check')
}
t.notOk(ws.write('a'), 'backpressured')
t.ok(Writable.isBackpressured(ws), 'static check')
ws.on('drain', function () {
t.notOk(Writable.isBackpressured(ws))
t.end()
})
})
tape('write backpressure with destroy', function (t) {
const ws = new Writable()
ws.write('a')
ws.destroy()
t.ok(Writable.isBackpressured(ws))
t.end()
})
tape('write backpressure with end', function (t) {
const ws = new Writable()
ws.write('a')
ws.end()
t.ok(Writable.isBackpressured(ws))
t.end()
})
tape('read backpressure', function (t) {
const rs = new Readable()
for (let i = 0; i < 15; i++) {
t.ok(rs.push('a'), 'not backpressured')
t.notOk(Readable.isBackpressured(rs), 'static check')
}
t.notOk(rs.push('a'), 'backpressured')
t.ok(Readable.isBackpressured(rs), 'static check')
t.end()
})
tape('read backpressure with later read', function (t) {
const rs = new Readable()
for (let i = 0; i < 15; i++) {
t.ok(rs.push('a'), 'not backpressured')
t.notOk(Readable.isBackpressured(rs), 'static check')
}
t.notOk(rs.push('a'), 'backpressured')
t.ok(Readable.isBackpressured(rs), 'static check')
rs.once('readable', function () {
rs.read()
t.notOk(Readable.isBackpressured(rs))
t.end()
})
})
tape('read backpressure with destroy', function (t) {
const rs = new Readable()
rs.push('a')
rs.destroy()
t.ok(Readable.isBackpressured(rs))
t.end()
})
tape('read backpressure with push(null)', function (t) {
const rs = new Readable()
rs.push('a')
rs.push(null)
t.ok(Readable.isBackpressured(rs))
t.end()
})

178
node_modules/streamx/test/compat.js generated vendored Normal file
View File

@ -0,0 +1,178 @@
const eos = require('end-of-stream')
const tape = require('tape')
const stream = require('../')
const finished = require('stream').finished
run(eos)
run(finished)
function run (eos) {
if (!eos) return
const name = eos === finished ? 'nodeStream.finished' : 'eos'
tape(name + ' readable', function (t) {
const r = new stream.Readable()
let ended = false
r.on('end', function () {
ended = true
})
eos(r, function (err) {
t.error(err, 'no error')
t.ok(ended)
t.end()
})
r.push('hello')
r.push(null)
r.resume()
})
tape(name + ' readable destroy', function (t) {
const r = new stream.Readable()
let ended = false
r.on('end', function () {
ended = true
})
eos(r, function (err) {
t.ok(err, 'had error')
t.notOk(ended)
t.end()
})
r.push('hello')
r.push(null)
r.resume()
r.destroy()
})
tape(name + ' writable', function (t) {
const w = new stream.Writable()
let finished = false
w.on('finish', function () {
finished = true
})
eos(w, function (err) {
t.error(err, 'no error')
t.ok(finished)
t.end()
})
w.write('hello')
w.end()
})
tape(name + ' writable destroy', function (t) {
const w = new stream.Writable()
let finished = false
w.on('finish', function () {
finished = true
})
eos(w, function (err) {
t.ok(err, 'had error')
t.notOk(finished)
t.end()
})
w.write('hello')
w.end()
w.destroy()
})
tape(name + ' duplex', function (t) {
const s = new stream.Duplex()
let ended = false
let finished = false
s.on('end', () => { ended = true })
s.on('finish', () => { finished = true })
eos(s, function (err) {
t.error(err, 'no error')
t.ok(ended)
t.ok(finished)
t.end()
})
s.push('hello')
s.push(null)
s.resume()
s.end()
})
tape(name + ' duplex + deferred s.end()', function (t) {
const s = new stream.Duplex()
let ended = false
let finished = false
s.on('end', function () {
ended = true
setImmediate(() => s.end())
})
s.on('finish', () => { finished = true })
eos(s, function (err) {
t.error(err, 'no error')
t.ok(ended)
t.ok(finished)
t.end()
})
s.push('hello')
s.push(null)
s.resume()
})
tape(name + ' duplex + deferred s.push(null)', function (t) {
const s = new stream.Duplex()
let ended = false
let finished = false
s.on('finish', function () {
finished = true
setImmediate(() => s.push(null))
})
s.on('end', () => { ended = true })
eos(s, function (err) {
t.error(err, 'no error')
t.ok(ended)
t.ok(finished)
t.end()
})
s.push('hello')
s.end()
s.resume()
})
tape(name + ' duplex destroy', function (t) {
const s = new stream.Duplex()
let ended = false
let finished = false
s.on('end', () => { ended = true })
s.on('finish', () => { finished = true })
eos(s, function (err) {
t.ok(err, 'had error')
t.notOk(ended)
t.notOk(finished)
t.end()
})
s.push('hello')
s.push(null)
s.resume()
s.end()
s.destroy()
})
}

134
node_modules/streamx/test/pipe.js generated vendored Normal file
View File

@ -0,0 +1,134 @@
const tape = require('tape')
const compat = require('stream')
const { Readable, Writable } = require('../')
tape('pipe to node stream', function (t) {
const expected = [
'hi',
'ho'
]
const r = new Readable()
const w = new compat.Writable({
objectMode: true,
write (data, enc, cb) {
t.same(data, expected.shift())
cb(null)
}
})
r.push('hi')
r.push('ho')
r.push(null)
r.pipe(w)
w.on('finish', function () {
t.same(expected.length, 0)
t.end()
})
})
tape('pipe with callback - error case', function (t) {
const r = new Readable()
const w = new Writable({
write (data, cb) {
cb(new Error('blerg'))
}
})
r.pipe(w, function (err) {
t.pass('callback called')
t.same(err, new Error('blerg'))
t.end()
})
r.push('hello')
r.push('world')
r.push(null)
})
tape('pipe with callback - error case with destroy', function (t) {
const r = new Readable()
const w = new Writable({
write (data, cb) {
w.destroy(new Error('blerg'))
cb(null)
}
})
r.pipe(w, function (err) {
t.pass('callback called')
t.same(err, new Error('blerg'))
t.end()
})
r.push('hello')
r.push('world')
})
tape('pipe with callback - error case node stream', function (t) {
const r = new Readable()
const w = new compat.Writable({
write (data, enc, cb) {
cb(new Error('blerg'))
}
})
r.pipe(w, function (err) {
t.pass('callback called')
t.same(err, new Error('blerg'))
t.end()
})
r.push('hello')
r.push('world')
r.push(null)
})
tape('simple pipe', function (t) {
const buffered = []
const r = new Readable()
const w = new Writable({
write (data, cb) {
buffered.push(data)
cb(null)
},
final () {
t.pass('final called')
t.same(buffered, ['hello', 'world'])
t.end()
}
})
r.pipe(w)
r.push('hello')
r.push('world')
r.push(null)
})
tape('pipe with callback', function (t) {
const buffered = []
const r = new Readable()
const w = new Writable({
write (data, cb) {
buffered.push(data)
cb(null)
}
})
r.pipe(w, function (err) {
t.pass('callback called')
t.same(err, null)
t.same(buffered, ['hello', 'world'])
t.end()
})
r.push('hello')
r.push('world')
r.push(null)
})

119
node_modules/streamx/test/readable.js generated vendored Normal file
View File

@ -0,0 +1,119 @@
const tape = require('tape')
const { Readable } = require('../')
tape('ondata', function (t) {
const r = new Readable()
const buffered = []
let ended = 0
r.push('hello')
r.push('world')
r.push(null)
r.on('data', data => buffered.push(data))
r.on('end', () => ended++)
r.on('close', function () {
t.pass('closed')
t.same(buffered, ['hello', 'world'])
t.same(ended, 1)
t.ok(r.destroyed)
t.end()
})
})
tape('resume', function (t) {
const r = new Readable()
let ended = 0
r.push('hello')
r.push('world')
r.push(null)
r.resume()
r.on('end', () => ended++)
r.on('close', function () {
t.pass('closed')
t.same(ended, 1)
t.ok(r.destroyed)
t.end()
})
})
tape('shorthands', function (t) {
t.plan(3 + 1)
const r = new Readable({
read (cb) {
this.push('hello')
cb(null)
},
destroy (cb) {
t.pass('destroyed')
cb(null)
}
})
r.once('readable', function () {
t.same(r.read(), 'hello')
t.same(r.read(), 'hello')
r.destroy()
t.same(r.read(), null)
})
})
tape('both push and the cb needs to be called for re-reads', function (t) {
t.plan(2)
let once = true
const r = new Readable({
read (cb) {
t.ok(once, 'read called once')
once = false
cb(null)
}
})
r.resume()
setTimeout(function () {
once = true
r.push('hi')
}, 100)
})
tape('from array', function (t) {
const inc = []
const r = Readable.from([1, 2, 3])
r.on('data', data => inc.push(data))
r.on('end', function () {
t.same(inc, [1, 2, 3])
t.end()
})
})
tape('from buffer', function (t) {
const inc = []
const r = Readable.from(Buffer.from('hello'))
r.on('data', data => inc.push(data))
r.on('end', function () {
t.same(inc, [Buffer.from('hello')])
t.end()
})
})
tape('from async iterator', function (t) {
async function * test () {
yield 1
yield 2
yield 3
}
const inc = []
const r = Readable.from(test())
r.on('data', data => inc.push(data))
r.on('end', function () {
t.same(inc, [1, 2, 3])
t.end()
})
})

103
node_modules/streamx/test/writable.js generated vendored Normal file
View File

@ -0,0 +1,103 @@
const tape = require('tape')
const { Writable } = require('../')
tape('opens before writes', function (t) {
t.plan(2)
const trace = []
const stream = new Writable({
open (cb) {
trace.push('open')
return cb(null)
},
write (data, cb) {
trace.push('write')
return cb(null)
}
})
stream.on('close', () => {
t.equals(trace.length, 2)
t.equals(trace[0], 'open')
})
stream.write('data')
stream.end()
})
tape('drain', function (t) {
const stream = new Writable({
highWaterMark: 1,
write (data, cb) {
cb(null)
}
})
t.notOk(stream.write('a'))
stream.on('drain', function () {
t.pass('drained')
t.end()
})
})
tape('drain multi write', function (t) {
t.plan(4)
const stream = new Writable({
highWaterMark: 1,
write (data, cb) {
cb(null)
}
})
t.notOk(stream.write('a'))
t.notOk(stream.write('a'))
t.notOk(stream.write('a'))
stream.on('drain', function () {
t.pass('drained')
t.end()
})
})
tape('drain async write', function (t) {
let flushed = false
const stream = new Writable({
highWaterMark: 1,
write (data, cb) {
setImmediate(function () {
flushed = true
cb(null)
})
}
})
t.notOk(stream.write('a'))
t.notOk(flushed)
stream.on('drain', function () {
t.ok(flushed)
t.end()
})
})
tape('writev', function (t) {
const expected = [[], ['ho']]
const s = new Writable({
writev (batch, cb) {
t.same(batch, expected.shift())
cb(null)
}
})
for (let i = 0; i < 100; i++) {
expected[0].push('hi-' + i)
s.write('hi-' + i)
}
s.on('drain', function () {
s.write('ho')
s.end()
})
s.on('finish', function () {
t.end()
})
})

48
node_modules/string_decoder/LICENSE generated vendored Normal file
View File

@ -0,0 +1,48 @@
Node.js is licensed for use as follows:
"""
Copyright Node.js contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:
"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""

47
node_modules/string_decoder/README.md generated vendored Normal file
View File

@ -0,0 +1,47 @@
# string_decoder
***Node-core v8.9.4 string_decoder for userland***
[![NPM](https://nodei.co/npm/string_decoder.png?downloads=true&downloadRank=true)](https://nodei.co/npm/string_decoder/)
[![NPM](https://nodei.co/npm-dl/string_decoder.png?&months=6&height=3)](https://nodei.co/npm/string_decoder/)
```bash
npm install --save string_decoder
```
***Node-core string_decoder for userland***
This package is a mirror of the string_decoder implementation in Node-core.
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.9.4/docs/api/).
As of version 1.0.0 **string_decoder** uses semantic versioning.
## Previous versions
Previous version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10.
## Update
The *build/* directory contains a build script that will scrape the source from the [nodejs/node](https://github.com/nodejs/node) repo given a specific Node version.
## Streams Working Group
`string_decoder` is maintained by the Streams Working Group, which
oversees the development and maintenance of the Streams API within
Node.js. The responsibilities of the Streams Working Group include:
* Addressing stream issues on the Node.js issue tracker.
* Authoring and editing stream documentation within the Node.js project.
* Reviewing changes to stream subclasses within the Node.js project.
* Redirecting changes to streams from the Node.js project to this
project.
* Assisting in the implementation of stream providers within Node.js.
* Recommending versions of `readable-stream` to be included in Node.js.
* Messaging about the future of streams to give the community advance
notice of changes.
See [readable-stream](https://github.com/nodejs/readable-stream) for
more details.

296
node_modules/string_decoder/lib/string_decoder.js generated vendored Normal file
View File

@ -0,0 +1,296 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
var isEncoding = Buffer.isEncoding || function (encoding) {
encoding = '' + encoding;
switch (encoding && encoding.toLowerCase()) {
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
return true;
default:
return false;
}
};
function _normalizeEncoding(enc) {
if (!enc) return 'utf8';
var retried;
while (true) {
switch (enc) {
case 'utf8':
case 'utf-8':
return 'utf8';
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return 'utf16le';
case 'latin1':
case 'binary':
return 'latin1';
case 'base64':
case 'ascii':
case 'hex':
return enc;
default:
if (retried) return; // undefined
enc = ('' + enc).toLowerCase();
retried = true;
}
}
};
// Do not cache `Buffer.isEncoding` when checking encoding names as some
// modules monkey-patch it to support additional encodings
function normalizeEncoding(enc) {
var nenc = _normalizeEncoding(enc);
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
return nenc || enc;
}
// StringDecoder provides an interface for efficiently splitting a series of
// buffers into a series of JS strings without breaking apart multi-byte
// characters.
exports.StringDecoder = StringDecoder;
function StringDecoder(encoding) {
this.encoding = normalizeEncoding(encoding);
var nb;
switch (this.encoding) {
case 'utf16le':
this.text = utf16Text;
this.end = utf16End;
nb = 4;
break;
case 'utf8':
this.fillLast = utf8FillLast;
nb = 4;
break;
case 'base64':
this.text = base64Text;
this.end = base64End;
nb = 3;
break;
default:
this.write = simpleWrite;
this.end = simpleEnd;
return;
}
this.lastNeed = 0;
this.lastTotal = 0;
this.lastChar = Buffer.allocUnsafe(nb);
}
StringDecoder.prototype.write = function (buf) {
if (buf.length === 0) return '';
var r;
var i;
if (this.lastNeed) {
r = this.fillLast(buf);
if (r === undefined) return '';
i = this.lastNeed;
this.lastNeed = 0;
} else {
i = 0;
}
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
return r || '';
};
StringDecoder.prototype.end = utf8End;
// Returns only complete characters in a Buffer
StringDecoder.prototype.text = utf8Text;
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
StringDecoder.prototype.fillLast = function (buf) {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
this.lastNeed -= buf.length;
};
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
// continuation byte. If an invalid byte is detected, -2 is returned.
function utf8CheckByte(byte) {
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
return byte >> 6 === 0x02 ? -1 : -2;
}
// Checks at most 3 bytes at the end of a Buffer in order to detect an
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
// needed to complete the UTF-8 character (if applicable) are returned.
function utf8CheckIncomplete(self, buf, i) {
var j = buf.length - 1;
if (j < i) return 0;
var nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 1;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 2;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) {
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
}
return nb;
}
return 0;
}
// Validates as many continuation bytes for a multi-byte UTF-8 character as
// needed or are available. If we see a non-continuation byte where we expect
// one, we "replace" the validated continuation bytes we've seen so far with
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
// behavior. The continuation byte check is included three times in the case
// where all of the continuation bytes for a character exist in the same buffer.
// It is also done this way as a slight performance increase instead of using a
// loop.
function utf8CheckExtraBytes(self, buf, p) {
if ((buf[0] & 0xC0) !== 0x80) {
self.lastNeed = 0;
return '\ufffd';
}
if (self.lastNeed > 1 && buf.length > 1) {
if ((buf[1] & 0xC0) !== 0x80) {
self.lastNeed = 1;
return '\ufffd';
}
if (self.lastNeed > 2 && buf.length > 2) {
if ((buf[2] & 0xC0) !== 0x80) {
self.lastNeed = 2;
return '\ufffd';
}
}
}
}
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
function utf8FillLast(buf) {
var p = this.lastTotal - this.lastNeed;
var r = utf8CheckExtraBytes(this, buf, p);
if (r !== undefined) return r;
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, p, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, p, 0, buf.length);
this.lastNeed -= buf.length;
}
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
// partial character, the character's bytes are buffered until the required
// number of bytes are available.
function utf8Text(buf, i) {
var total = utf8CheckIncomplete(this, buf, i);
if (!this.lastNeed) return buf.toString('utf8', i);
this.lastTotal = total;
var end = buf.length - (total - this.lastNeed);
buf.copy(this.lastChar, 0, end);
return buf.toString('utf8', i, end);
}
// For UTF-8, a replacement character is added when ending on a partial
// character.
function utf8End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + '\ufffd';
return r;
}
// UTF-16LE typically needs two bytes per character, but even if we have an even
// number of bytes available, we need to check if we end on a leading/high
// surrogate. In that case, we need to wait for the next two bytes in order to
// decode the last character properly.
function utf16Text(buf, i) {
if ((buf.length - i) % 2 === 0) {
var r = buf.toString('utf16le', i);
if (r) {
var c = r.charCodeAt(r.length - 1);
if (c >= 0xD800 && c <= 0xDBFF) {
this.lastNeed = 2;
this.lastTotal = 4;
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
return r.slice(0, -1);
}
}
return r;
}
this.lastNeed = 1;
this.lastTotal = 2;
this.lastChar[0] = buf[buf.length - 1];
return buf.toString('utf16le', i, buf.length - 1);
}
// For UTF-16LE we do not explicitly append special replacement characters if we
// end on a partial character, we simply let v8 handle that.
function utf16End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) {
var end = this.lastTotal - this.lastNeed;
return r + this.lastChar.toString('utf16le', 0, end);
}
return r;
}
function base64Text(buf, i) {
var n = (buf.length - i) % 3;
if (n === 0) return buf.toString('base64', i);
this.lastNeed = 3 - n;
this.lastTotal = 3;
if (n === 1) {
this.lastChar[0] = buf[buf.length - 1];
} else {
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
}
return buf.toString('base64', i, buf.length - n);
}
function base64End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
return r;
}
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
function simpleWrite(buf) {
return buf.toString(this.encoding);
}
function simpleEnd(buf) {
return buf && buf.length ? this.write(buf) : '';
}

62
node_modules/string_decoder/package.json generated vendored Normal file
View File

@ -0,0 +1,62 @@
{
"_from": "string_decoder@^1.1.1",
"_id": "string_decoder@1.3.0",
"_inBundle": false,
"_integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"_location": "/string_decoder",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "string_decoder@^1.1.1",
"name": "string_decoder",
"escapedName": "string_decoder",
"rawSpec": "^1.1.1",
"saveSpec": null,
"fetchSpec": "^1.1.1"
},
"_requiredBy": [
"/readable-stream"
],
"_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"_shasum": "42f114594a46cf1a8e30b0a84f56c78c3edac21e",
"_spec": "string_decoder@^1.1.1",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/readable-stream",
"bugs": {
"url": "https://github.com/nodejs/string_decoder/issues"
},
"bundleDependencies": false,
"dependencies": {
"safe-buffer": "~5.2.0"
},
"deprecated": false,
"description": "The string_decoder module from Node core",
"devDependencies": {
"babel-polyfill": "^6.23.0",
"core-util-is": "^1.0.2",
"inherits": "^2.0.3",
"tap": "~0.4.8"
},
"files": [
"lib"
],
"homepage": "https://github.com/nodejs/string_decoder",
"keywords": [
"string",
"decoder",
"browser",
"browserify"
],
"license": "MIT",
"main": "lib/string_decoder.js",
"name": "string_decoder",
"repository": {
"type": "git",
"url": "git://github.com/nodejs/string_decoder.git"
},
"scripts": {
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
"test": "tap test/parallel/*.js && node test/verify-dependencies"
},
"version": "1.3.0"
}

16
node_modules/util-deprecate/History.md generated vendored Normal file
View File

@ -0,0 +1,16 @@
1.0.2 / 2015-10-07
==================
* use try/catch when checking `localStorage` (#3, @kumavis)
1.0.1 / 2014-11-25
==================
* browser: use `console.warn()` for deprecation calls
* browser: more jsdocs
1.0.0 / 2014-04-30
==================
* initial commit

24
node_modules/util-deprecate/LICENSE generated vendored Normal file
View File

@ -0,0 +1,24 @@
(The MIT License)
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

53
node_modules/util-deprecate/README.md generated vendored Normal file
View File

@ -0,0 +1,53 @@
util-deprecate
==============
### The Node.js `util.deprecate()` function with browser support
In Node.js, this module simply re-exports the `util.deprecate()` function.
In the web browser (i.e. via browserify), a browser-specific implementation
of the `util.deprecate()` function is used.
## API
A `deprecate()` function is the only thing exposed by this module.
``` javascript
// setup:
exports.foo = deprecate(foo, 'foo() is deprecated, use bar() instead');
// users see:
foo();
// foo() is deprecated, use bar() instead
foo();
foo();
```
## License
(The MIT License)
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

67
node_modules/util-deprecate/browser.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
/**
* Module exports.
*/
module.exports = deprecate;
/**
* Mark that a method should not be used.
* Returns a modified function which warns once by default.
*
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
*
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
* will throw an Error when invoked.
*
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
* will invoke `console.trace()` instead of `console.error()`.
*
* @param {Function} fn - the function to deprecate
* @param {String} msg - the string to print to the console when `fn` is invoked
* @returns {Function} a new "deprecated" version of `fn`
* @api public
*/
function deprecate (fn, msg) {
if (config('noDeprecation')) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (config('throwDeprecation')) {
throw new Error(msg);
} else if (config('traceDeprecation')) {
console.trace(msg);
} else {
console.warn(msg);
}
warned = true;
}
return fn.apply(this, arguments);
}
return deprecated;
}
/**
* Checks `localStorage` for boolean values for the given `name`.
*
* @param {String} name
* @returns {Boolean}
* @api private
*/
function config (name) {
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
try {
if (!global.localStorage) return false;
} catch (_) {
return false;
}
var val = global.localStorage[name];
if (null == val) return false;
return String(val).toLowerCase() === 'true';
}

6
node_modules/util-deprecate/node.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
/**
* For Node.js, simply re-export the core `util.deprecate` function.
*/
module.exports = require('util').deprecate;

58
node_modules/util-deprecate/package.json generated vendored Normal file
View File

@ -0,0 +1,58 @@
{
"_from": "util-deprecate@^1.0.1",
"_id": "util-deprecate@1.0.2",
"_inBundle": false,
"_integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"_location": "/util-deprecate",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "util-deprecate@^1.0.1",
"name": "util-deprecate",
"escapedName": "util-deprecate",
"rawSpec": "^1.0.1",
"saveSpec": null,
"fetchSpec": "^1.0.1"
},
"_requiredBy": [
"/bl/readable-stream",
"/readable-stream",
"/through2/readable-stream"
],
"_resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf",
"_spec": "util-deprecate@^1.0.1",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/readable-stream",
"author": {
"name": "Nathan Rajlich",
"email": "nathan@tootallnate.net",
"url": "http://n8.io/"
},
"browser": "browser.js",
"bugs": {
"url": "https://github.com/TooTallNate/util-deprecate/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "The Node.js `util.deprecate()` function with browser support",
"homepage": "https://github.com/TooTallNate/util-deprecate",
"keywords": [
"util",
"deprecate",
"browserify",
"browser",
"node"
],
"license": "MIT",
"main": "node.js",
"name": "util-deprecate",
"repository": {
"type": "git",
"url": "git://github.com/TooTallNate/util-deprecate.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.2"
}

View File

@ -1,6 +1,6 @@
{
"name": "deploy-to-neocities",
"version": "0.0.0",
"version": "0.0.1",
"description": "Github Action to deplpoy a folder to Neocities.org",
"main": "index.js",
"private": true,