first commit
This commit is contained in:
5
build/node_modules/insert-module-globals/.travis.yml
generated
vendored
Normal file
5
build/node_modules/insert-module-globals/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- node
|
||||
18
build/node_modules/insert-module-globals/LICENSE
generated
vendored
Normal file
18
build/node_modules/insert-module-globals/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
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.
|
||||
18
build/node_modules/insert-module-globals/bench/results.txt
generated
vendored
Normal file
18
build/node_modules/insert-module-globals/bench/results.txt
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
$ git log|head -n1
|
||||
commit 8b66aec6f43c5099c72ab365a93da2a9e406824e
|
||||
|
||||
with lexical-scope@0.0.4:
|
||||
|
||||
$ time module-deps bench/jquery.js | bin/cmd.js >/dev/null
|
||||
|
||||
real 0m7.380s
|
||||
user 0m7.504s
|
||||
sys 0m0.320s
|
||||
|
||||
with lexical-scope@0.0.5:
|
||||
|
||||
$ time module-deps bench/jquery.js | bin/cmd.js >/dev/null
|
||||
|
||||
real 0m2.441s
|
||||
user 0m2.584s
|
||||
sys 0m0.176s
|
||||
2
build/node_modules/insert-module-globals/bench/run.sh
generated
vendored
Executable file
2
build/node_modules/insert-module-globals/bench/run.sh
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
time module-deps bench/jquery.js | bin/cmd.js >/dev/null
|
||||
26
build/node_modules/insert-module-globals/bin/cmd.js
generated
vendored
Executable file
26
build/node_modules/insert-module-globals/bin/cmd.js
generated
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var insert = require('../');
|
||||
var through = require('through2');
|
||||
var concat = require('concat-stream');
|
||||
var JSONStream = require('JSONStream');
|
||||
|
||||
var basedir = process.argv[2] || process.cwd();
|
||||
|
||||
process.stdin
|
||||
.pipe(JSONStream.parse([ true ]))
|
||||
.pipe(through.obj(write))
|
||||
.pipe(JSONStream.stringify())
|
||||
.pipe(process.stdout)
|
||||
;
|
||||
|
||||
function write (row, enc, next) {
|
||||
var self = this;
|
||||
var s = insert(row.id, { basedir: basedir });
|
||||
s.pipe(concat(function (src) {
|
||||
row.source = src.toString('utf8');
|
||||
self.push(row);
|
||||
next();
|
||||
}));
|
||||
s.end(row.source);
|
||||
}
|
||||
6
build/node_modules/insert-module-globals/example/files/foo/index.js
generated
vendored
Normal file
6
build/node_modules/insert-module-globals/example/files/foo/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
process.nextTick(function () {
|
||||
console.log('in foo/index.js: ' + JSON.stringify({
|
||||
__filename: __filename,
|
||||
__dirname: __dirname
|
||||
}));
|
||||
});
|
||||
6
build/node_modules/insert-module-globals/example/files/main.js
generated
vendored
Normal file
6
build/node_modules/insert-module-globals/example/files/main.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
console.log('in main.js: ' + JSON.stringify({
|
||||
__filename: __filename,
|
||||
__dirname: __dirname
|
||||
}));
|
||||
|
||||
require('./foo');
|
||||
12
build/node_modules/insert-module-globals/example/insert.js
generated
vendored
Normal file
12
build/node_modules/insert-module-globals/example/insert.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var mdeps = require('module-deps');
|
||||
var bpack = require('browser-pack');
|
||||
var insert = require('../');
|
||||
function inserter (file) {
|
||||
return insert(file, { basedir: __dirname + '/files' });
|
||||
}
|
||||
|
||||
var files = [ __dirname + '/files/main.js' ];
|
||||
mdeps(files, { transform: inserter })
|
||||
.pipe(bpack({ raw: true }))
|
||||
.pipe(process.stdout)
|
||||
;
|
||||
170
build/node_modules/insert-module-globals/index.js
generated
vendored
Normal file
170
build/node_modules/insert-module-globals/index.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
var parseScope = require('lexical-scope');
|
||||
var through = require('through2');
|
||||
var merge = require('xtend');
|
||||
|
||||
var path = require('path');
|
||||
var processPath = require.resolve('process/browser.js');
|
||||
var isbufferPath = require.resolve('is-buffer')
|
||||
var combineSourceMap = require('combine-source-map');
|
||||
|
||||
function getRelativeRequirePath(fullPath, fromPath) {
|
||||
var relpath = path.relative(path.dirname(fromPath), fullPath);
|
||||
// If fullPath is in the same directory as fromPath, relpath will
|
||||
// result in something like "index.js". require() needs "./" prepended
|
||||
// to these paths.
|
||||
if (path.dirname(relpath) === '.') {
|
||||
relpath = "./" + relpath;
|
||||
}
|
||||
// On Windows: Convert path separators to what require() expects
|
||||
if (path.sep === '\\') {
|
||||
relpath = relpath.replace(/\\/g, '/');
|
||||
}
|
||||
return relpath;
|
||||
}
|
||||
|
||||
var defaultVars = {
|
||||
process: function (file) {
|
||||
var relpath = getRelativeRequirePath(processPath, file);
|
||||
return 'require(' + JSON.stringify(relpath) + ')';
|
||||
},
|
||||
global: function () {
|
||||
return 'typeof global !== "undefined" ? global : '
|
||||
+ 'typeof self !== "undefined" ? self : '
|
||||
+ 'typeof window !== "undefined" ? window : {}'
|
||||
;
|
||||
},
|
||||
'Buffer.isBuffer': function (file) {
|
||||
var relpath = getRelativeRequirePath(isbufferPath, file);
|
||||
return 'require(' + JSON.stringify(relpath) + ')';
|
||||
},
|
||||
Buffer: function () {
|
||||
return 'require("buffer").Buffer';
|
||||
},
|
||||
__filename: function (file, basedir) {
|
||||
var filename = '/' + path.relative(basedir, file);
|
||||
return JSON.stringify(filename);
|
||||
},
|
||||
__dirname: function (file, basedir) {
|
||||
var dir = path.dirname('/' + path.relative(basedir, file));
|
||||
return JSON.stringify(dir);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function (file, opts) {
|
||||
if (/\.json$/i.test(file)) return through();
|
||||
if (!opts) opts = {};
|
||||
|
||||
var basedir = opts.basedir || '/';
|
||||
var vars = merge(defaultVars, opts.vars);
|
||||
var varNames = Object.keys(vars).filter(function(name) {
|
||||
return typeof vars[name] === 'function';
|
||||
});
|
||||
|
||||
var quick = RegExp(varNames.map(function (name) {
|
||||
return '\\b' + name + '\\b';
|
||||
}).join('|'));
|
||||
|
||||
var chunks = [];
|
||||
|
||||
return through(write, end);
|
||||
|
||||
function write (chunk, enc, next) { chunks.push(chunk); next() }
|
||||
|
||||
function end () {
|
||||
var self = this;
|
||||
var source = Buffer.isBuffer(chunks[0])
|
||||
? Buffer.concat(chunks).toString('utf8')
|
||||
: chunks.join('')
|
||||
;
|
||||
source = source
|
||||
.replace(/^\ufeff/, '')
|
||||
.replace(/^#![^\n]*\n/, '\n');
|
||||
|
||||
if (opts.always !== true && !quick.test(source)) {
|
||||
this.push(source);
|
||||
this.push(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var scope = opts.always
|
||||
? { globals: { implicit: varNames } }
|
||||
: parseScope('(function(){\n' + source + '\n})()')
|
||||
;
|
||||
}
|
||||
catch (err) {
|
||||
var e = new SyntaxError(
|
||||
(err.message || err) + ' while parsing ' + file
|
||||
);
|
||||
e.type = 'syntax';
|
||||
e.filename = file;
|
||||
return this.emit('error', e);
|
||||
}
|
||||
|
||||
var globals = {};
|
||||
|
||||
varNames.forEach(function (name) {
|
||||
if (!/\./.test(name)) return;
|
||||
var parts = name.split('.')
|
||||
var prop = (scope.globals.implicitProperties || {})[parts[0]]
|
||||
if (!prop || prop.length !== 1 || prop[0] !== parts[1]) return;
|
||||
var value = vars[name](file, basedir);
|
||||
if (!value) return;
|
||||
globals[parts[0]] = '{'
|
||||
+ JSON.stringify(parts[1]) + ':' + value + '}';
|
||||
self.emit('global', name);
|
||||
});
|
||||
varNames.forEach(function (name) {
|
||||
if (/\./.test(name)) return;
|
||||
if (globals[name]) return;
|
||||
if (scope.globals.implicit.indexOf(name) < 0) return;
|
||||
var value = vars[name](file, basedir);
|
||||
if (!value) return;
|
||||
globals[name] = value;
|
||||
self.emit('global', name);
|
||||
});
|
||||
|
||||
this.push(closeOver(globals, source, file, opts));
|
||||
this.push(null);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.vars = defaultVars;
|
||||
|
||||
function closeOver (globals, src, file, opts) {
|
||||
var keys = Object.keys(globals);
|
||||
if (keys.length === 0) return src;
|
||||
var values = keys.map(function (key) { return globals[key] });
|
||||
|
||||
var wrappedSource;
|
||||
if (keys.length <= 3) {
|
||||
wrappedSource = '(function (' + keys.join(',') + '){\n'
|
||||
+ src + '\n}).call(this,' + values.join(',') + ')'
|
||||
;
|
||||
}
|
||||
else {
|
||||
// necessary to make arguments[3..6] still work for workerify etc
|
||||
// a,b,c,arguments[3..6],d,e,f...
|
||||
var extra = [ '__argument0', '__argument1', '__argument2', '__argument3' ];
|
||||
var names = keys.slice(0,3).concat(extra).concat(keys.slice(3));
|
||||
values.splice(3, 0,
|
||||
'arguments[3]','arguments[4]',
|
||||
'arguments[5]','arguments[6]'
|
||||
);
|
||||
wrappedSource = '(function (' + names.join(',') + '){\n'
|
||||
+ src + '\n}).call(this,' + values.join(',') + ')';
|
||||
}
|
||||
|
||||
// Generate source maps if wanted. Including the right offset for
|
||||
// the wrapped source.
|
||||
if (!opts.debug) {
|
||||
return wrappedSource;
|
||||
}
|
||||
var sourceFile = path.relative(opts.basedir, file)
|
||||
.replace(/\\/g, '/');
|
||||
var sourceMap = combineSourceMap.create().addFile(
|
||||
{ sourceFile: sourceFile, source: src},
|
||||
{ line: 1 });
|
||||
return combineSourceMap.removeComments(wrappedSource) + "\n"
|
||||
+ sourceMap.comment();
|
||||
}
|
||||
24
build/node_modules/insert-module-globals/node_modules/concat-stream/LICENSE
generated
vendored
Normal file
24
build/node_modules/insert-module-globals/node_modules/concat-stream/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2013 Max Ogden
|
||||
|
||||
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.
|
||||
143
build/node_modules/insert-module-globals/node_modules/concat-stream/index.js
generated
vendored
Normal file
143
build/node_modules/insert-module-globals/node_modules/concat-stream/index.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
var Writable = require('readable-stream').Writable
|
||||
var inherits = require('inherits')
|
||||
|
||||
if (typeof Uint8Array === 'undefined') {
|
||||
var U8 = require('typedarray').Uint8Array
|
||||
} else {
|
||||
var U8 = Uint8Array
|
||||
}
|
||||
|
||||
function ConcatStream(opts, cb) {
|
||||
if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb)
|
||||
|
||||
if (typeof opts === 'function') {
|
||||
cb = opts
|
||||
opts = {}
|
||||
}
|
||||
if (!opts) opts = {}
|
||||
|
||||
var encoding = opts.encoding
|
||||
var shouldInferEncoding = false
|
||||
|
||||
if (!encoding) {
|
||||
shouldInferEncoding = true
|
||||
} else {
|
||||
encoding = String(encoding).toLowerCase()
|
||||
if (encoding === 'u8' || encoding === 'uint8') {
|
||||
encoding = 'uint8array'
|
||||
}
|
||||
}
|
||||
|
||||
Writable.call(this, { objectMode: true })
|
||||
|
||||
this.encoding = encoding
|
||||
this.shouldInferEncoding = shouldInferEncoding
|
||||
|
||||
if (cb) this.on('finish', function () { cb(this.getBody()) })
|
||||
this.body = []
|
||||
}
|
||||
|
||||
module.exports = ConcatStream
|
||||
inherits(ConcatStream, Writable)
|
||||
|
||||
ConcatStream.prototype._write = function(chunk, enc, next) {
|
||||
this.body.push(chunk)
|
||||
next()
|
||||
}
|
||||
|
||||
ConcatStream.prototype.inferEncoding = function (buff) {
|
||||
var firstBuffer = buff === undefined ? this.body[0] : buff;
|
||||
if (Buffer.isBuffer(firstBuffer)) return 'buffer'
|
||||
if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array'
|
||||
if (Array.isArray(firstBuffer)) return 'array'
|
||||
if (typeof firstBuffer === 'string') return 'string'
|
||||
if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object'
|
||||
return 'buffer'
|
||||
}
|
||||
|
||||
ConcatStream.prototype.getBody = function () {
|
||||
if (!this.encoding && this.body.length === 0) return []
|
||||
if (this.shouldInferEncoding) this.encoding = this.inferEncoding()
|
||||
if (this.encoding === 'array') return arrayConcat(this.body)
|
||||
if (this.encoding === 'string') return stringConcat(this.body)
|
||||
if (this.encoding === 'buffer') return bufferConcat(this.body)
|
||||
if (this.encoding === 'uint8array') return u8Concat(this.body)
|
||||
return this.body
|
||||
}
|
||||
|
||||
var isArray = Array.isArray || function (arr) {
|
||||
return Object.prototype.toString.call(arr) == '[object Array]'
|
||||
}
|
||||
|
||||
function isArrayish (arr) {
|
||||
return /Array\]$/.test(Object.prototype.toString.call(arr))
|
||||
}
|
||||
|
||||
function isBufferish (p) {
|
||||
return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function')
|
||||
}
|
||||
|
||||
function stringConcat (parts) {
|
||||
var strings = []
|
||||
var needsToString = false
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var p = parts[i]
|
||||
if (typeof p === 'string') {
|
||||
strings.push(p)
|
||||
} else if (Buffer.isBuffer(p)) {
|
||||
strings.push(p)
|
||||
} else if (isBufferish(p)) {
|
||||
strings.push(new Buffer(p))
|
||||
} else {
|
||||
strings.push(new Buffer(String(p)))
|
||||
}
|
||||
}
|
||||
if (Buffer.isBuffer(parts[0])) {
|
||||
strings = Buffer.concat(strings)
|
||||
strings = strings.toString('utf8')
|
||||
} else {
|
||||
strings = strings.join('')
|
||||
}
|
||||
return strings
|
||||
}
|
||||
|
||||
function bufferConcat (parts) {
|
||||
var bufs = []
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var p = parts[i]
|
||||
if (Buffer.isBuffer(p)) {
|
||||
bufs.push(p)
|
||||
} else if (isBufferish(p)) {
|
||||
bufs.push(new Buffer(p))
|
||||
} else {
|
||||
bufs.push(new Buffer(String(p)))
|
||||
}
|
||||
}
|
||||
return Buffer.concat(bufs)
|
||||
}
|
||||
|
||||
function arrayConcat (parts) {
|
||||
var res = []
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
res.push.apply(res, parts[i])
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
function u8Concat (parts) {
|
||||
var len = 0
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
if (typeof parts[i] === 'string') {
|
||||
parts[i] = new Buffer(parts[i])
|
||||
}
|
||||
len += parts[i].length
|
||||
}
|
||||
var u8 = new U8(len)
|
||||
for (var i = 0, offset = 0; i < parts.length; i++) {
|
||||
var part = parts[i]
|
||||
for (var j = 0; j < part.length; j++) {
|
||||
u8[offset++] = part[j]
|
||||
}
|
||||
}
|
||||
return u8
|
||||
}
|
||||
83
build/node_modules/insert-module-globals/node_modules/concat-stream/package.json
generated
vendored
Normal file
83
build/node_modules/insert-module-globals/node_modules/concat-stream/package.json
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"_from": "concat-stream@~1.5.1",
|
||||
"_id": "concat-stream@1.5.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=",
|
||||
"_location": "/insert-module-globals/concat-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "concat-stream@~1.5.1",
|
||||
"name": "concat-stream",
|
||||
"escapedName": "concat-stream",
|
||||
"rawSpec": "~1.5.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.5.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/insert-module-globals"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz",
|
||||
"_shasum": "708978624d856af41a5a741defdd261da752c266",
|
||||
"_spec": "concat-stream@~1.5.1",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/insert-module-globals",
|
||||
"author": {
|
||||
"name": "Max Ogden",
|
||||
"email": "max@maxogden.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/maxogden/concat-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"inherits": "~2.0.1",
|
||||
"readable-stream": "~2.0.0",
|
||||
"typedarray": "~0.0.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "writable stream that concatenates strings or binary data and calls a callback with the result",
|
||||
"devDependencies": {
|
||||
"tape": "~2.3.2"
|
||||
},
|
||||
"engines": [
|
||||
"node >= 0.8"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/maxogden/concat-stream#readme",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "concat-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/maxogden/concat-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js test/server/*.js"
|
||||
},
|
||||
"tags": [
|
||||
"stream",
|
||||
"simple",
|
||||
"util",
|
||||
"utility"
|
||||
],
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/17..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/22..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"version": "1.5.2"
|
||||
}
|
||||
102
build/node_modules/insert-module-globals/node_modules/concat-stream/readme.md
generated
vendored
Normal file
102
build/node_modules/insert-module-globals/node_modules/concat-stream/readme.md
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
# concat-stream
|
||||
|
||||
Writable stream that concatenates all the data from a stream and calls a callback with the result. Use this when you want to collect all the data from a stream into a single buffer.
|
||||
|
||||
[](https://travis-ci.org/maxogden/concat-stream)
|
||||
|
||||
[](https://nodei.co/npm/concat-stream/)
|
||||
|
||||
### description
|
||||
|
||||
Streams emit many buffers. If you want to collect all of the buffers, and when the stream ends concatenate all of the buffers together and receive a single buffer then this is the module for you.
|
||||
|
||||
Only use this if you know you can fit all of the output of your stream into a single Buffer (e.g. in RAM).
|
||||
|
||||
There are also `objectMode` streams that emit things other than Buffers, and you can concatenate these too. See below for details.
|
||||
|
||||
## Related
|
||||
|
||||
`stream-each` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.
|
||||
|
||||
### examples
|
||||
|
||||
#### Buffers
|
||||
|
||||
```js
|
||||
var fs = require('fs')
|
||||
var concat = require('concat-stream')
|
||||
|
||||
var readStream = fs.createReadStream('cat.png')
|
||||
var concatStream = concat(gotPicture)
|
||||
|
||||
readStream.on('error', handleError)
|
||||
readStream.pipe(concatStream)
|
||||
|
||||
function gotPicture(imageBuffer) {
|
||||
// imageBuffer is all of `cat.png` as a node.js Buffer
|
||||
}
|
||||
|
||||
function handleError(err) {
|
||||
// handle your error appropriately here, e.g.:
|
||||
console.error(err) // print the error to STDERR
|
||||
process.exit(1) // exit program with non-zero exit code
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### Arrays
|
||||
|
||||
```js
|
||||
var write = concat(function(data) {})
|
||||
write.write([1,2,3])
|
||||
write.write([4,5,6])
|
||||
write.end()
|
||||
// data will be [1,2,3,4,5,6] in the above callback
|
||||
```
|
||||
|
||||
#### Uint8Arrays
|
||||
|
||||
```js
|
||||
var write = concat(function(data) {})
|
||||
var a = new Uint8Array(3)
|
||||
a[0] = 97; a[1] = 98; a[2] = 99
|
||||
write.write(a)
|
||||
write.write('!')
|
||||
write.end(Buffer('!!1'))
|
||||
```
|
||||
|
||||
See `test/` for more examples
|
||||
|
||||
# methods
|
||||
|
||||
```js
|
||||
var concat = require('concat-stream')
|
||||
```
|
||||
|
||||
## var writable = concat(opts={}, cb)
|
||||
|
||||
Return a `writable` stream that will fire `cb(data)` with all of the data that
|
||||
was written to the stream. Data can be written to `writable` as strings,
|
||||
Buffers, arrays of byte integers, and Uint8Arrays.
|
||||
|
||||
By default `concat-stream` will give you back the same data type as the type of the first buffer written to the stream. Use `opts.encoding` to set what format `data` should be returned as, e.g. if you if you don't want to rely on the built-in type checking or for some other reason.
|
||||
|
||||
* `string` - get a string
|
||||
* `buffer` - get back a Buffer
|
||||
* `array` - get an array of byte integers
|
||||
* `uint8array`, `u8`, `uint8` - get back a Uint8Array
|
||||
* `object`, get back an array of Objects
|
||||
|
||||
If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a `Buffer`.
|
||||
|
||||
If nothing is written to `writable` then `data` will be an empty array `[]`.
|
||||
|
||||
# error handling
|
||||
|
||||
`concat-stream` does not handle errors for you, so you must handle errors on whatever streams you pipe into `concat-stream`. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since `concat-stream` is not itself a stream it does not emit errors.
|
||||
|
||||
We recommend using [`end-of-stream`](https://npmjs.org/end-of-stream) or [`pump`](https://npmjs.org/pump) for writing error tolerant stream code.
|
||||
|
||||
# license
|
||||
|
||||
MIT LICENSE
|
||||
21
build/node_modules/insert-module-globals/node_modules/process/.eslintrc
generated
vendored
Normal file
21
build/node_modules/insert-module-globals/node_modules/process/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
extends: "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"es6" : true,
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"indent": [2, 4],
|
||||
"brace-style": [2, "1tbs"],
|
||||
"quotes": [2, "single"],
|
||||
"no-console": 0,
|
||||
"no-shadow": 0,
|
||||
"no-use-before-define": [2, "nofunc"],
|
||||
"no-underscore-dangle": 0,
|
||||
"no-constant-condition": 0,
|
||||
"space-after-function-name": 0,
|
||||
"consistent-return": 0
|
||||
}
|
||||
}
|
||||
22
build/node_modules/insert-module-globals/node_modules/process/LICENSE
generated
vendored
Normal file
22
build/node_modules/insert-module-globals/node_modules/process/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Roman Shtylman <shtylman@gmail.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.
|
||||
26
build/node_modules/insert-module-globals/node_modules/process/README.md
generated
vendored
Normal file
26
build/node_modules/insert-module-globals/node_modules/process/README.md
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# process
|
||||
|
||||
```require('process');``` just like any other module.
|
||||
|
||||
Works in node.js and browsers via the browser.js shim provided with the module.
|
||||
|
||||
## browser implementation
|
||||
|
||||
The goal of this module is not to be a full-fledged alternative to the builtin process module. This module mostly exists to provide the nextTick functionality and little more. We keep this module lean because it will often be included by default by tools like browserify when it detects a module has used the `process` global.
|
||||
|
||||
It also exposes a "browser" member (i.e. `process.browser`) which is `true` in this implementation but `undefined` in node. This can be used in isomorphic code that adjusts it's behavior depending on which environment it's running in.
|
||||
|
||||
If you are looking to provide other process methods, I suggest you monkey patch them onto the process global in your app. A list of user created patches is below.
|
||||
|
||||
* [hrtime](https://github.com/kumavis/browser-process-hrtime)
|
||||
* [stdout](https://github.com/kumavis/browser-stdout)
|
||||
|
||||
## package manager notes
|
||||
|
||||
If you are writing a bundler to package modules for client side use, make sure you use the ```browser``` field hint in package.json.
|
||||
|
||||
See https://gist.github.com/4339901 for details.
|
||||
|
||||
The [browserify](https://github.com/substack/node-browserify) module will properly handle this field when bundling your files.
|
||||
|
||||
|
||||
184
build/node_modules/insert-module-globals/node_modules/process/browser.js
generated
vendored
Normal file
184
build/node_modules/insert-module-globals/node_modules/process/browser.js
generated
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
// shim for using process in browser
|
||||
var process = module.exports = {};
|
||||
|
||||
// cached from whatever global is present so that test runners that stub it
|
||||
// don't break things. But we need to wrap it in a try catch in case it is
|
||||
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
||||
// function because try/catches deoptimize in certain engines.
|
||||
|
||||
var cachedSetTimeout;
|
||||
var cachedClearTimeout;
|
||||
|
||||
function defaultSetTimout() {
|
||||
throw new Error('setTimeout has not been defined');
|
||||
}
|
||||
function defaultClearTimeout () {
|
||||
throw new Error('clearTimeout has not been defined');
|
||||
}
|
||||
(function () {
|
||||
try {
|
||||
if (typeof setTimeout === 'function') {
|
||||
cachedSetTimeout = setTimeout;
|
||||
} else {
|
||||
cachedSetTimeout = defaultSetTimout;
|
||||
}
|
||||
} catch (e) {
|
||||
cachedSetTimeout = defaultSetTimout;
|
||||
}
|
||||
try {
|
||||
if (typeof clearTimeout === 'function') {
|
||||
cachedClearTimeout = clearTimeout;
|
||||
} else {
|
||||
cachedClearTimeout = defaultClearTimeout;
|
||||
}
|
||||
} catch (e) {
|
||||
cachedClearTimeout = defaultClearTimeout;
|
||||
}
|
||||
} ())
|
||||
function runTimeout(fun) {
|
||||
if (cachedSetTimeout === setTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return setTimeout(fun, 0);
|
||||
}
|
||||
// if setTimeout wasn't available but was latter defined
|
||||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
||||
cachedSetTimeout = setTimeout;
|
||||
return setTimeout(fun, 0);
|
||||
}
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedSetTimeout(fun, 0);
|
||||
} catch(e){
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedSetTimeout.call(null, fun, 0);
|
||||
} catch(e){
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
||||
return cachedSetTimeout.call(this, fun, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function runClearTimeout(marker) {
|
||||
if (cachedClearTimeout === clearTimeout) {
|
||||
//normal enviroments in sane situations
|
||||
return clearTimeout(marker);
|
||||
}
|
||||
// if clearTimeout wasn't available but was latter defined
|
||||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
||||
cachedClearTimeout = clearTimeout;
|
||||
return clearTimeout(marker);
|
||||
}
|
||||
try {
|
||||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||||
return cachedClearTimeout(marker);
|
||||
} catch (e){
|
||||
try {
|
||||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||||
return cachedClearTimeout.call(null, marker);
|
||||
} catch (e){
|
||||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
||||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
||||
return cachedClearTimeout.call(this, marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
var queue = [];
|
||||
var draining = false;
|
||||
var currentQueue;
|
||||
var queueIndex = -1;
|
||||
|
||||
function cleanUpNextTick() {
|
||||
if (!draining || !currentQueue) {
|
||||
return;
|
||||
}
|
||||
draining = false;
|
||||
if (currentQueue.length) {
|
||||
queue = currentQueue.concat(queue);
|
||||
} else {
|
||||
queueIndex = -1;
|
||||
}
|
||||
if (queue.length) {
|
||||
drainQueue();
|
||||
}
|
||||
}
|
||||
|
||||
function drainQueue() {
|
||||
if (draining) {
|
||||
return;
|
||||
}
|
||||
var timeout = runTimeout(cleanUpNextTick);
|
||||
draining = true;
|
||||
|
||||
var len = queue.length;
|
||||
while(len) {
|
||||
currentQueue = queue;
|
||||
queue = [];
|
||||
while (++queueIndex < len) {
|
||||
if (currentQueue) {
|
||||
currentQueue[queueIndex].run();
|
||||
}
|
||||
}
|
||||
queueIndex = -1;
|
||||
len = queue.length;
|
||||
}
|
||||
currentQueue = null;
|
||||
draining = false;
|
||||
runClearTimeout(timeout);
|
||||
}
|
||||
|
||||
process.nextTick = function (fun) {
|
||||
var args = new Array(arguments.length - 1);
|
||||
if (arguments.length > 1) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
args[i - 1] = arguments[i];
|
||||
}
|
||||
}
|
||||
queue.push(new Item(fun, args));
|
||||
if (queue.length === 1 && !draining) {
|
||||
runTimeout(drainQueue);
|
||||
}
|
||||
};
|
||||
|
||||
// v8 likes predictible objects
|
||||
function Item(fun, array) {
|
||||
this.fun = fun;
|
||||
this.array = array;
|
||||
}
|
||||
Item.prototype.run = function () {
|
||||
this.fun.apply(null, this.array);
|
||||
};
|
||||
process.title = 'browser';
|
||||
process.browser = true;
|
||||
process.env = {};
|
||||
process.argv = [];
|
||||
process.version = ''; // empty string to avoid regexp issues
|
||||
process.versions = {};
|
||||
|
||||
function noop() {}
|
||||
|
||||
process.on = noop;
|
||||
process.addListener = noop;
|
||||
process.once = noop;
|
||||
process.off = noop;
|
||||
process.removeListener = noop;
|
||||
process.removeAllListeners = noop;
|
||||
process.emit = noop;
|
||||
process.prependListener = noop;
|
||||
process.prependOnceListener = noop;
|
||||
|
||||
process.listeners = function (name) { return [] }
|
||||
|
||||
process.binding = function (name) {
|
||||
throw new Error('process.binding is not supported');
|
||||
};
|
||||
|
||||
process.cwd = function () { return '/' };
|
||||
process.chdir = function (dir) {
|
||||
throw new Error('process.chdir is not supported');
|
||||
};
|
||||
process.umask = function() { return 0; };
|
||||
2
build/node_modules/insert-module-globals/node_modules/process/index.js
generated
vendored
Normal file
2
build/node_modules/insert-module-globals/node_modules/process/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// for now just expose the builtin process global from node.js
|
||||
module.exports = global.process;
|
||||
59
build/node_modules/insert-module-globals/node_modules/process/package.json
generated
vendored
Normal file
59
build/node_modules/insert-module-globals/node_modules/process/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"_from": "process@~0.11.0",
|
||||
"_id": "process@0.11.10",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
|
||||
"_location": "/insert-module-globals/process",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "process@~0.11.0",
|
||||
"name": "process",
|
||||
"escapedName": "process",
|
||||
"rawSpec": "~0.11.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~0.11.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/insert-module-globals"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
|
||||
"_shasum": "7332300e840161bda3e69a1d1d91a7d4bc16f182",
|
||||
"_spec": "process@~0.11.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/insert-module-globals",
|
||||
"author": {
|
||||
"name": "Roman Shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
"browser": "./browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/shtylman/node-process/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "process information for node.js and browsers",
|
||||
"devDependencies": {
|
||||
"mocha": "2.2.1",
|
||||
"zuul": "^3.10.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
},
|
||||
"homepage": "https://github.com/shtylman/node-process#readme",
|
||||
"keywords": [
|
||||
"process"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./index.js",
|
||||
"name": "process",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/shtylman/node-process.git"
|
||||
},
|
||||
"scripts": {
|
||||
"browser": "zuul --no-coverage --ui mocha-bdd --local 8080 -- test.js",
|
||||
"test": "mocha test.js"
|
||||
},
|
||||
"version": "0.11.10"
|
||||
}
|
||||
199
build/node_modules/insert-module-globals/node_modules/process/test.js
generated
vendored
Normal file
199
build/node_modules/insert-module-globals/node_modules/process/test.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
var assert = require('assert');
|
||||
var ourProcess = require('./browser');
|
||||
describe('test against our process', function () {
|
||||
test(ourProcess);
|
||||
});
|
||||
if (!process.browser) {
|
||||
describe('test against node', function () {
|
||||
test(process);
|
||||
});
|
||||
vmtest();
|
||||
}
|
||||
function test (ourProcess) {
|
||||
describe('test arguments', function () {
|
||||
it ('works', function (done) {
|
||||
var order = 0;
|
||||
|
||||
|
||||
ourProcess.nextTick(function (num) {
|
||||
assert.equal(num, order++, 'first one works');
|
||||
ourProcess.nextTick(function (num) {
|
||||
assert.equal(num, order++, 'recursive one is 4th');
|
||||
}, 3);
|
||||
}, 0);
|
||||
ourProcess.nextTick(function (num) {
|
||||
assert.equal(num, order++, 'second one starts');
|
||||
ourProcess.nextTick(function (num) {
|
||||
assert.equal(num, order++, 'this is third');
|
||||
ourProcess.nextTick(function (num) {
|
||||
assert.equal(num, order++, 'this is last');
|
||||
done();
|
||||
}, 5);
|
||||
}, 4);
|
||||
}, 1);
|
||||
ourProcess.nextTick(function (num) {
|
||||
|
||||
assert.equal(num, order++, '3rd schedualed happens after the error');
|
||||
}, 2);
|
||||
});
|
||||
});
|
||||
if (!process.browser) {
|
||||
describe('test errors', function (t) {
|
||||
it ('works', function (done) {
|
||||
var order = 0;
|
||||
process.removeAllListeners('uncaughtException');
|
||||
process.once('uncaughtException', function(err) {
|
||||
assert.equal(2, order++, 'error is third');
|
||||
ourProcess.nextTick(function () {
|
||||
assert.equal(5, order++, 'schedualed in error is last');
|
||||
done();
|
||||
});
|
||||
});
|
||||
ourProcess.nextTick(function () {
|
||||
assert.equal(0, order++, 'first one works');
|
||||
ourProcess.nextTick(function () {
|
||||
assert.equal(4, order++, 'recursive one is 4th');
|
||||
});
|
||||
});
|
||||
ourProcess.nextTick(function () {
|
||||
assert.equal(1, order++, 'second one starts');
|
||||
throw(new Error('an error is thrown'));
|
||||
});
|
||||
ourProcess.nextTick(function () {
|
||||
assert.equal(3, order++, '3rd schedualed happens after the error');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
describe('rename globals', function (t) {
|
||||
var oldTimeout = setTimeout;
|
||||
var oldClear = clearTimeout;
|
||||
|
||||
it('clearTimeout', function (done){
|
||||
|
||||
var ok = true;
|
||||
clearTimeout = function () {
|
||||
ok = false;
|
||||
}
|
||||
var ran = false;
|
||||
function cleanup() {
|
||||
clearTimeout = oldClear;
|
||||
var err;
|
||||
try {
|
||||
assert.ok(ok, 'fake clearTimeout ran');
|
||||
assert.ok(ran, 'should have run');
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
done(err);
|
||||
}
|
||||
setTimeout(cleanup, 1000);
|
||||
ourProcess.nextTick(function () {
|
||||
ran = true;
|
||||
});
|
||||
});
|
||||
it('just setTimeout', function (done){
|
||||
|
||||
|
||||
setTimeout = function () {
|
||||
setTimeout = oldTimeout;
|
||||
try {
|
||||
assert.ok(false, 'fake setTimeout called')
|
||||
} catch (e) {
|
||||
done(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ourProcess.nextTick(function () {
|
||||
setTimeout = oldTimeout;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
function vmtest() {
|
||||
var vm = require('vm');
|
||||
var fs = require('fs');
|
||||
var process = fs.readFileSync('./browser.js', {encoding: 'utf8'});
|
||||
|
||||
|
||||
describe('should work in vm in strict mode with no globals', function () {
|
||||
it('should parse', function (done) {
|
||||
var str = '"use strict";var module = {exports:{}};';
|
||||
str += process;
|
||||
str += 'this.works = process.browser;';
|
||||
var script = new vm.Script(str);
|
||||
var context = {
|
||||
works: false
|
||||
};
|
||||
script.runInNewContext(context);
|
||||
assert.ok(context.works);
|
||||
done();
|
||||
});
|
||||
it('setTimeout throws error', function (done) {
|
||||
var str = '"use strict";var module = {exports:{}};';
|
||||
str += process;
|
||||
str += 'try {process.nextTick(function () {})} catch (e){this.works = e;}';
|
||||
var script = new vm.Script(str);
|
||||
var context = {
|
||||
works: false
|
||||
};
|
||||
script.runInNewContext(context);
|
||||
assert.ok(context.works);
|
||||
done();
|
||||
});
|
||||
it('should generally work', function (done) {
|
||||
var str = '"use strict";var module = {exports:{}};';
|
||||
str += process;
|
||||
str += 'process.nextTick(function () {assert.ok(true);done();})';
|
||||
var script = new vm.Script(str);
|
||||
var context = {
|
||||
clearTimeout: clearTimeout,
|
||||
setTimeout: setTimeout,
|
||||
done: done,
|
||||
assert: assert
|
||||
};
|
||||
script.runInNewContext(context);
|
||||
});
|
||||
it('late defs setTimeout', function (done) {
|
||||
var str = '"use strict";var module = {exports:{}};';
|
||||
str += process;
|
||||
str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {assert.ok(true);done();})';
|
||||
var script = new vm.Script(str);
|
||||
var context = {
|
||||
clearTimeout: clearTimeout,
|
||||
hiddenSetTimeout: setTimeout,
|
||||
done: done,
|
||||
assert: assert
|
||||
};
|
||||
script.runInNewContext(context);
|
||||
});
|
||||
it('late defs clearTimeout', function (done) {
|
||||
var str = '"use strict";var module = {exports:{}};';
|
||||
str += process;
|
||||
str += 'var clearTimeout = hiddenClearTimeout;process.nextTick(function () {assert.ok(true);done();})';
|
||||
var script = new vm.Script(str);
|
||||
var context = {
|
||||
hiddenClearTimeout: clearTimeout,
|
||||
setTimeout: setTimeout,
|
||||
done: done,
|
||||
assert: assert
|
||||
};
|
||||
script.runInNewContext(context);
|
||||
});
|
||||
it('late defs setTimeout and then redefine', function (done) {
|
||||
var str = '"use strict";var module = {exports:{}};';
|
||||
str += process;
|
||||
str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {setTimeout = function (){throw new Error("foo")};hiddenSetTimeout(function(){process.nextTick(function (){assert.ok(true);done();});});});';
|
||||
var script = new vm.Script(str);
|
||||
var context = {
|
||||
clearTimeout: clearTimeout,
|
||||
hiddenSetTimeout: setTimeout,
|
||||
done: done,
|
||||
assert: assert
|
||||
};
|
||||
script.runInNewContext(context);
|
||||
});
|
||||
});
|
||||
}
|
||||
5
build/node_modules/insert-module-globals/node_modules/readable-stream/.npmignore
generated
vendored
Normal file
5
build/node_modules/insert-module-globals/node_modules/readable-stream/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
build/
|
||||
test/
|
||||
examples/
|
||||
fs.js
|
||||
zlib.js
|
||||
52
build/node_modules/insert-module-globals/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
52
build/node_modules/insert-module-globals/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
before_install:
|
||||
- npm install -g npm@2
|
||||
- npm install -g npm
|
||||
notifications:
|
||||
email: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest"
|
||||
- env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest"
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env: TASK=test
|
||||
- node_js: '0.10'
|
||||
env: TASK=test
|
||||
- node_js: '0.11'
|
||||
env: TASK=test
|
||||
- node_js: '0.12'
|
||||
env: TASK=test
|
||||
- node_js: 1
|
||||
env: TASK=test
|
||||
- node_js: 2
|
||||
env: TASK=test
|
||||
- node_js: 3
|
||||
env: TASK=test
|
||||
- node_js: 4
|
||||
env: TASK=test
|
||||
- node_js: 5
|
||||
env: TASK=test
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest"
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=ie BROWSER_VERSION="9..latest"
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest"
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="-3..latest"
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="-3..latest"
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest"
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest"
|
||||
- node_js: 5
|
||||
env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest"
|
||||
script: "npm run $TASK"
|
||||
env:
|
||||
global:
|
||||
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
|
||||
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
|
||||
1
build/node_modules/insert-module-globals/node_modules/readable-stream/.zuul.yml
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/readable-stream/.zuul.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
ui: tape
|
||||
18
build/node_modules/insert-module-globals/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
18
build/node_modules/insert-module-globals/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
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.
|
||||
36
build/node_modules/insert-module-globals/node_modules/readable-stream/README.md
generated
vendored
Normal file
36
build/node_modules/insert-module-globals/node_modules/readable-stream/README.md
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# readable-stream
|
||||
|
||||
***Node-core v5.8.0 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
|
||||
|
||||
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
|
||||
|
||||
[](https://saucelabs.com/u/readable-stream)
|
||||
|
||||
```bash
|
||||
npm install --save readable-stream
|
||||
```
|
||||
|
||||
***Node-core streams for userland***
|
||||
|
||||
This package is a mirror of the Streams2 and Streams3 implementations in
|
||||
Node-core, including [documentation](doc/stream.markdown).
|
||||
|
||||
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.
|
||||
|
||||
# Streams WG Team Members
|
||||
|
||||
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com>
|
||||
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
|
||||
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
|
||||
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
|
||||
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org>
|
||||
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
|
||||
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com>
|
||||
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
|
||||
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me>
|
||||
1760
build/node_modules/insert-module-globals/node_modules/readable-stream/doc/stream.markdown
generated
vendored
Normal file
1760
build/node_modules/insert-module-globals/node_modules/readable-stream/doc/stream.markdown
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
60
build/node_modules/insert-module-globals/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
60
build/node_modules/insert-module-globals/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# streams WG Meeting 2015-01-30
|
||||
|
||||
## Links
|
||||
|
||||
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
|
||||
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
|
||||
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
|
||||
|
||||
## Agenda
|
||||
|
||||
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
|
||||
|
||||
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
|
||||
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
|
||||
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
|
||||
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
|
||||
|
||||
## Minutes
|
||||
|
||||
### adopt a charter
|
||||
|
||||
* group: +1's all around
|
||||
|
||||
### What versioning scheme should be adopted?
|
||||
* group: +1’s 3.0.0
|
||||
* domenic+group: pulling in patches from other sources where appropriate
|
||||
* mikeal: version independently, suggesting versions for io.js
|
||||
* mikeal+domenic: work with TC to notify in advance of changes
|
||||
simpler stream creation
|
||||
|
||||
### streamline creation of streams
|
||||
* sam: streamline creation of streams
|
||||
* domenic: nice simple solution posted
|
||||
but, we lose the opportunity to change the model
|
||||
may not be backwards incompatible (double check keys)
|
||||
|
||||
**action item:** domenic will check
|
||||
|
||||
### remove implicit flowing of streams on(‘data’)
|
||||
* add isFlowing / isPaused
|
||||
* mikeal: worrying that we’re documenting polyfill methods – confuses users
|
||||
* domenic: more reflective API is probably good, with warning labels for users
|
||||
* new section for mad scientists (reflective stream access)
|
||||
* calvin: name the “third state”
|
||||
* mikeal: maybe borrow the name from whatwg?
|
||||
* domenic: we’re missing the “third state”
|
||||
* consensus: kind of difficult to name the third state
|
||||
* mikeal: figure out differences in states / compat
|
||||
* mathias: always flow on data – eliminates third state
|
||||
* explore what it breaks
|
||||
|
||||
**action items:**
|
||||
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
|
||||
* ask rod/build for infrastructure
|
||||
* **chris**: explore the “flow on data” approach
|
||||
* add isPaused/isFlowing
|
||||
* add new docs section
|
||||
* move isPaused to that section
|
||||
|
||||
|
||||
1
build/node_modules/insert-module-globals/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_duplex.js")
|
||||
75
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
75
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// 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;
|
||||
|
||||
/*<replacement>*/
|
||||
var processNextTick = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Readable = require('./_stream_readable');
|
||||
var Writable = require('./_stream_writable');
|
||||
|
||||
util.inherits(Duplex, Readable);
|
||||
|
||||
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);
|
||||
|
||||
if (options && options.readable === false) this.readable = false;
|
||||
|
||||
if (options && options.writable === false) this.writable = false;
|
||||
|
||||
this.allowHalfOpen = true;
|
||||
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
||||
|
||||
this.once('end', onend);
|
||||
}
|
||||
|
||||
// the no-half-open enforcer
|
||||
function onend() {
|
||||
// if we allow half-open state, or if the writable side ended,
|
||||
// then we're ok.
|
||||
if (this.allowHalfOpen || this._writableState.ended) return;
|
||||
|
||||
// no more data can be written.
|
||||
// But allow more writes to happen in this tick.
|
||||
processNextTick(onEndNT, this);
|
||||
}
|
||||
|
||||
function onEndNT(self) {
|
||||
self.end();
|
||||
}
|
||||
|
||||
function forEach(xs, f) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
f(xs[i], i);
|
||||
}
|
||||
}
|
||||
26
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
26
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.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);
|
||||
};
|
||||
880
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
880
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
@@ -0,0 +1,880 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = Readable;
|
||||
|
||||
/*<replacement>*/
|
||||
var processNextTick = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var isArray = require('isarray');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Buffer = require('buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
Readable.ReadableState = ReadableState;
|
||||
|
||||
var EE = require('events');
|
||||
|
||||
/*<replacement>*/
|
||||
var EElistenerCount = function (emitter, type) {
|
||||
return emitter.listeners(type).length;
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Stream;
|
||||
(function () {
|
||||
try {
|
||||
Stream = require('st' + 'ream');
|
||||
} catch (_) {} finally {
|
||||
if (!Stream) Stream = require('events').EventEmitter;
|
||||
}
|
||||
})();
|
||||
/*</replacement>*/
|
||||
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var debugUtil = require('util');
|
||||
var debug = undefined;
|
||||
if (debugUtil && debugUtil.debuglog) {
|
||||
debug = debugUtil.debuglog('stream');
|
||||
} else {
|
||||
debug = function () {};
|
||||
}
|
||||
/*</replacement>*/
|
||||
|
||||
var StringDecoder;
|
||||
|
||||
util.inherits(Readable, Stream);
|
||||
|
||||
var Duplex;
|
||||
function ReadableState(options, stream) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// object stream flag. Used to make read(n) ignore n and to
|
||||
// make all the buffer merging and length checks go away
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
||||
|
||||
// the point at which it stops calling _read() to fill the buffer
|
||||
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
||||
var hwm = options.highWaterMark;
|
||||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||||
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = ~ ~this.highWaterMark;
|
||||
|
||||
this.buffer = [];
|
||||
this.length = 0;
|
||||
this.pipes = null;
|
||||
this.pipesCount = 0;
|
||||
this.flowing = null;
|
||||
this.ended = false;
|
||||
this.endEmitted = false;
|
||||
this.reading = false;
|
||||
|
||||
// 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;
|
||||
|
||||
// whenever we return null, then we set a flag to say
|
||||
// that we're awaiting a 'readable' event emission.
|
||||
this.needReadable = false;
|
||||
this.emittedReadable = false;
|
||||
this.readableListening = false;
|
||||
this.resumeScheduled = false;
|
||||
|
||||
// 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';
|
||||
|
||||
// when piping, we only care about 'readable' events that happen
|
||||
// after read()ing all the bytes and not getting any pushback.
|
||||
this.ranOut = false;
|
||||
|
||||
// the number of writers that are awaiting a drain event in .pipe()s
|
||||
this.awaitDrain = 0;
|
||||
|
||||
// if true, a maybeReadMore has been scheduled
|
||||
this.readingMore = false;
|
||||
|
||||
this.decoder = null;
|
||||
this.encoding = null;
|
||||
if (options.encoding) {
|
||||
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
|
||||
this.decoder = new StringDecoder(options.encoding);
|
||||
this.encoding = options.encoding;
|
||||
}
|
||||
}
|
||||
|
||||
var Duplex;
|
||||
function Readable(options) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
if (!(this instanceof Readable)) return new Readable(options);
|
||||
|
||||
this._readableState = new ReadableState(options, this);
|
||||
|
||||
// legacy
|
||||
this.readable = true;
|
||||
|
||||
if (options && typeof options.read === 'function') this._read = options.read;
|
||||
|
||||
Stream.call(this);
|
||||
}
|
||||
|
||||
// Manually shove something into the read() buffer.
|
||||
// This returns true if the highWaterMark has not been hit yet,
|
||||
// similar to how Writable.write() returns true if you should
|
||||
// write() some more.
|
||||
Readable.prototype.push = function (chunk, encoding) {
|
||||
var state = this._readableState;
|
||||
|
||||
if (!state.objectMode && typeof chunk === 'string') {
|
||||
encoding = encoding || state.defaultEncoding;
|
||||
if (encoding !== state.encoding) {
|
||||
chunk = new Buffer(chunk, encoding);
|
||||
encoding = '';
|
||||
}
|
||||
}
|
||||
|
||||
return readableAddChunk(this, state, chunk, encoding, false);
|
||||
};
|
||||
|
||||
// Unshift should *always* be something directly out of read()
|
||||
Readable.prototype.unshift = function (chunk) {
|
||||
var state = this._readableState;
|
||||
return readableAddChunk(this, state, chunk, '', true);
|
||||
};
|
||||
|
||||
Readable.prototype.isPaused = function () {
|
||||
return this._readableState.flowing === false;
|
||||
};
|
||||
|
||||
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
||||
var er = chunkInvalid(state, chunk);
|
||||
if (er) {
|
||||
stream.emit('error', er);
|
||||
} else if (chunk === null) {
|
||||
state.reading = false;
|
||||
onEofChunk(stream, state);
|
||||
} else if (state.objectMode || chunk && chunk.length > 0) {
|
||||
if (state.ended && !addToFront) {
|
||||
var e = new Error('stream.push() after EOF');
|
||||
stream.emit('error', e);
|
||||
} else if (state.endEmitted && addToFront) {
|
||||
var e = new Error('stream.unshift() after end event');
|
||||
stream.emit('error', e);
|
||||
} else {
|
||||
var skipAdd;
|
||||
if (state.decoder && !addToFront && !encoding) {
|
||||
chunk = state.decoder.write(chunk);
|
||||
skipAdd = !state.objectMode && chunk.length === 0;
|
||||
}
|
||||
|
||||
if (!addToFront) state.reading = false;
|
||||
|
||||
// Don't add to the buffer if we've decoded to an empty string chunk and
|
||||
// we're not in object mode
|
||||
if (!skipAdd) {
|
||||
// if we want the data now, just emit it.
|
||||
if (state.flowing && state.length === 0 && !state.sync) {
|
||||
stream.emit('data', chunk);
|
||||
stream.read(0);
|
||||
} else {
|
||||
// update the buffer info.
|
||||
state.length += state.objectMode ? 1 : chunk.length;
|
||||
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
||||
|
||||
if (state.needReadable) emitReadable(stream);
|
||||
}
|
||||
}
|
||||
|
||||
maybeReadMore(stream, state);
|
||||
}
|
||||
} else if (!addToFront) {
|
||||
state.reading = false;
|
||||
}
|
||||
|
||||
return needMoreData(state);
|
||||
}
|
||||
|
||||
// if it's past the high water mark, we can push in some more.
|
||||
// Also, if we have no data yet, we can stand some
|
||||
// more bytes. This is to work around cases where hwm=0,
|
||||
// such as the repl. Also, if the push() triggered a
|
||||
// readable event, and the user called read(largeNumber) such that
|
||||
// needReadable was set, then we ought to push more, so that another
|
||||
// 'readable' event will be triggered.
|
||||
function needMoreData(state) {
|
||||
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
||||
}
|
||||
|
||||
// backwards compatibility.
|
||||
Readable.prototype.setEncoding = function (enc) {
|
||||
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
|
||||
this._readableState.decoder = new StringDecoder(enc);
|
||||
this._readableState.encoding = enc;
|
||||
return this;
|
||||
};
|
||||
|
||||
// Don't raise the hwm > 8MB
|
||||
var MAX_HWM = 0x800000;
|
||||
function computeNewHighWaterMark(n) {
|
||||
if (n >= MAX_HWM) {
|
||||
n = MAX_HWM;
|
||||
} else {
|
||||
// Get the next highest power of 2
|
||||
n--;
|
||||
n |= n >>> 1;
|
||||
n |= n >>> 2;
|
||||
n |= n >>> 4;
|
||||
n |= n >>> 8;
|
||||
n |= n >>> 16;
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
function howMuchToRead(n, state) {
|
||||
if (state.length === 0 && state.ended) return 0;
|
||||
|
||||
if (state.objectMode) return n === 0 ? 0 : 1;
|
||||
|
||||
if (n === null || isNaN(n)) {
|
||||
// only flow one buffer at a time
|
||||
if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length;
|
||||
}
|
||||
|
||||
if (n <= 0) return 0;
|
||||
|
||||
// If we're asking for more than the target buffer level,
|
||||
// then raise the water mark. Bump up to the next highest
|
||||
// power of 2, to prevent increasing it excessively in tiny
|
||||
// amounts.
|
||||
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
||||
|
||||
// don't have that much. return null, unless we've ended.
|
||||
if (n > state.length) {
|
||||
if (!state.ended) {
|
||||
state.needReadable = true;
|
||||
return 0;
|
||||
} else {
|
||||
return state.length;
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// you can override either this method, or the async _read(n) below.
|
||||
Readable.prototype.read = function (n) {
|
||||
debug('read', n);
|
||||
var state = this._readableState;
|
||||
var nOrig = n;
|
||||
|
||||
if (typeof n !== 'number' || n > 0) state.emittedReadable = false;
|
||||
|
||||
// if we're doing read(0) to trigger a readable event, but we
|
||||
// already have a bunch of data in the buffer, then just trigger
|
||||
// the 'readable' event and move on.
|
||||
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
||||
debug('read: emitReadable', state.length, state.ended);
|
||||
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
n = howMuchToRead(n, state);
|
||||
|
||||
// if we've ended, and we're now clear, then finish it up.
|
||||
if (n === 0 && state.ended) {
|
||||
if (state.length === 0) endReadable(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
// All the actual chunk generation logic needs to be
|
||||
// *below* the call to _read. The reason is that in certain
|
||||
// synthetic stream cases, such as passthrough streams, _read
|
||||
// may be a completely synchronous operation which may change
|
||||
// the state of the read buffer, providing enough data when
|
||||
// before there was *not* enough.
|
||||
//
|
||||
// So, the steps are:
|
||||
// 1. Figure out what the state of things will be after we do
|
||||
// a read from the buffer.
|
||||
//
|
||||
// 2. If that resulting state will trigger a _read, then call _read.
|
||||
// Note that this may be asynchronous, or synchronous. Yes, it is
|
||||
// deeply ugly to write APIs this way, but that still doesn't mean
|
||||
// that the Readable class should behave improperly, as streams are
|
||||
// designed to be sync/async agnostic.
|
||||
// Take note if the _read call is sync or async (ie, if the read call
|
||||
// has returned yet), so that we know whether or not it's safe to emit
|
||||
// 'readable' etc.
|
||||
//
|
||||
// 3. Actually pull the requested chunks out of the buffer and return.
|
||||
|
||||
// if we need a readable event, then we need to do some reading.
|
||||
var doRead = state.needReadable;
|
||||
debug('need readable', doRead);
|
||||
|
||||
// if we currently have less than the highWaterMark, then also read some
|
||||
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
||||
doRead = true;
|
||||
debug('length less than watermark', doRead);
|
||||
}
|
||||
|
||||
// however, if we've ended, then there's no point, and if we're already
|
||||
// reading, then it's unnecessary.
|
||||
if (state.ended || state.reading) {
|
||||
doRead = false;
|
||||
debug('reading or ended', doRead);
|
||||
}
|
||||
|
||||
if (doRead) {
|
||||
debug('do read');
|
||||
state.reading = true;
|
||||
state.sync = true;
|
||||
// if the length is currently zero, then we *need* a readable event.
|
||||
if (state.length === 0) state.needReadable = true;
|
||||
// call internal read method
|
||||
this._read(state.highWaterMark);
|
||||
state.sync = false;
|
||||
}
|
||||
|
||||
// If _read pushed data synchronously, then `reading` will be false,
|
||||
// and we need to re-evaluate how much data we can return to the user.
|
||||
if (doRead && !state.reading) n = howMuchToRead(nOrig, state);
|
||||
|
||||
var ret;
|
||||
if (n > 0) ret = fromList(n, state);else ret = null;
|
||||
|
||||
if (ret === null) {
|
||||
state.needReadable = true;
|
||||
n = 0;
|
||||
}
|
||||
|
||||
state.length -= n;
|
||||
|
||||
// If we have nothing in the buffer, then we want to know
|
||||
// as soon as we *do* get something into the buffer.
|
||||
if (state.length === 0 && !state.ended) state.needReadable = true;
|
||||
|
||||
// If we tried to read() past the EOF, then emit end on the next tick.
|
||||
if (nOrig !== n && state.ended && state.length === 0) endReadable(this);
|
||||
|
||||
if (ret !== null) this.emit('data', ret);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
function chunkInvalid(state, chunk) {
|
||||
var er = null;
|
||||
if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
|
||||
er = new TypeError('Invalid non-string/buffer chunk');
|
||||
}
|
||||
return er;
|
||||
}
|
||||
|
||||
function onEofChunk(stream, state) {
|
||||
if (state.ended) return;
|
||||
if (state.decoder) {
|
||||
var chunk = state.decoder.end();
|
||||
if (chunk && chunk.length) {
|
||||
state.buffer.push(chunk);
|
||||
state.length += state.objectMode ? 1 : chunk.length;
|
||||
}
|
||||
}
|
||||
state.ended = true;
|
||||
|
||||
// emit 'readable' now to make sure it gets picked up.
|
||||
emitReadable(stream);
|
||||
}
|
||||
|
||||
// Don't emit readable right away in sync mode, because this can trigger
|
||||
// another read() call => stack overflow. This way, it might trigger
|
||||
// a nextTick recursion warning, but that's not so bad.
|
||||
function emitReadable(stream) {
|
||||
var state = stream._readableState;
|
||||
state.needReadable = false;
|
||||
if (!state.emittedReadable) {
|
||||
debug('emitReadable', state.flowing);
|
||||
state.emittedReadable = true;
|
||||
if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
|
||||
}
|
||||
}
|
||||
|
||||
function emitReadable_(stream) {
|
||||
debug('emit readable');
|
||||
stream.emit('readable');
|
||||
flow(stream);
|
||||
}
|
||||
|
||||
// at this point, the user has presumably seen the 'readable' event,
|
||||
// and called read() to consume some data. that may have triggered
|
||||
// in turn another _read(n) call, in which case reading = true if
|
||||
// it's in progress.
|
||||
// However, if we're not ended, or reading, and the length < hwm,
|
||||
// then go ahead and try to read some more preemptively.
|
||||
function maybeReadMore(stream, state) {
|
||||
if (!state.readingMore) {
|
||||
state.readingMore = true;
|
||||
processNextTick(maybeReadMore_, stream, state);
|
||||
}
|
||||
}
|
||||
|
||||
function maybeReadMore_(stream, state) {
|
||||
var len = state.length;
|
||||
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
||||
debug('maybeReadMore read 0');
|
||||
stream.read(0);
|
||||
if (len === state.length)
|
||||
// didn't get any data, stop spinning.
|
||||
break;else len = state.length;
|
||||
}
|
||||
state.readingMore = false;
|
||||
}
|
||||
|
||||
// abstract method. to be overridden in specific implementation classes.
|
||||
// call cb(er, data) where data is <= n in length.
|
||||
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
||||
// arbitrary, and perhaps not very meaningful.
|
||||
Readable.prototype._read = function (n) {
|
||||
this.emit('error', new Error('not implemented'));
|
||||
};
|
||||
|
||||
Readable.prototype.pipe = function (dest, pipeOpts) {
|
||||
var src = this;
|
||||
var state = this._readableState;
|
||||
|
||||
switch (state.pipesCount) {
|
||||
case 0:
|
||||
state.pipes = dest;
|
||||
break;
|
||||
case 1:
|
||||
state.pipes = [state.pipes, dest];
|
||||
break;
|
||||
default:
|
||||
state.pipes.push(dest);
|
||||
break;
|
||||
}
|
||||
state.pipesCount += 1;
|
||||
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
||||
|
||||
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
||||
|
||||
var endFn = doEnd ? onend : cleanup;
|
||||
if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
|
||||
|
||||
dest.on('unpipe', onunpipe);
|
||||
function onunpipe(readable) {
|
||||
debug('onunpipe');
|
||||
if (readable === src) {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
function onend() {
|
||||
debug('onend');
|
||||
dest.end();
|
||||
}
|
||||
|
||||
// when the dest drains, it reduces the awaitDrain counter
|
||||
// on the source. This would be more elegant with a .once()
|
||||
// handler in flow(), but adding and removing repeatedly is
|
||||
// too slow.
|
||||
var ondrain = pipeOnDrain(src);
|
||||
dest.on('drain', ondrain);
|
||||
|
||||
var cleanedUp = false;
|
||||
function cleanup() {
|
||||
debug('cleanup');
|
||||
// cleanup event handlers once the pipe is broken
|
||||
dest.removeListener('close', onclose);
|
||||
dest.removeListener('finish', onfinish);
|
||||
dest.removeListener('drain', ondrain);
|
||||
dest.removeListener('error', onerror);
|
||||
dest.removeListener('unpipe', onunpipe);
|
||||
src.removeListener('end', onend);
|
||||
src.removeListener('end', cleanup);
|
||||
src.removeListener('data', ondata);
|
||||
|
||||
cleanedUp = true;
|
||||
|
||||
// if the reader is waiting for a drain event from this
|
||||
// specific writer, then it would cause it to never start
|
||||
// flowing again.
|
||||
// So, if this is awaiting a drain, then we just call it now.
|
||||
// If we don't know, then assume that we are waiting for one.
|
||||
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
||||
}
|
||||
|
||||
src.on('data', ondata);
|
||||
function ondata(chunk) {
|
||||
debug('ondata');
|
||||
var ret = dest.write(chunk);
|
||||
if (false === ret) {
|
||||
// If the user unpiped during `dest.write()`, it is possible
|
||||
// to get stuck in a permanently paused state if that write
|
||||
// also returned false.
|
||||
if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) {
|
||||
debug('false write response, pause', src._readableState.awaitDrain);
|
||||
src._readableState.awaitDrain++;
|
||||
}
|
||||
src.pause();
|
||||
}
|
||||
}
|
||||
|
||||
// if the dest has an error, then stop piping into it.
|
||||
// however, don't suppress the throwing behavior for this.
|
||||
function onerror(er) {
|
||||
debug('onerror', er);
|
||||
unpipe();
|
||||
dest.removeListener('error', onerror);
|
||||
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
|
||||
}
|
||||
// This is a brutally ugly hack to make sure that our error handler
|
||||
// is attached before any userland ones. NEVER DO THIS.
|
||||
if (!dest._events || !dest._events.error) dest.on('error', onerror);else if (isArray(dest._events.error)) dest._events.error.unshift(onerror);else dest._events.error = [onerror, dest._events.error];
|
||||
|
||||
// Both close and finish should trigger unpipe, but only once.
|
||||
function onclose() {
|
||||
dest.removeListener('finish', onfinish);
|
||||
unpipe();
|
||||
}
|
||||
dest.once('close', onclose);
|
||||
function onfinish() {
|
||||
debug('onfinish');
|
||||
dest.removeListener('close', onclose);
|
||||
unpipe();
|
||||
}
|
||||
dest.once('finish', onfinish);
|
||||
|
||||
function unpipe() {
|
||||
debug('unpipe');
|
||||
src.unpipe(dest);
|
||||
}
|
||||
|
||||
// tell the dest that it's being piped to
|
||||
dest.emit('pipe', src);
|
||||
|
||||
// start the flow if it hasn't been started already.
|
||||
if (!state.flowing) {
|
||||
debug('pipe resume');
|
||||
src.resume();
|
||||
}
|
||||
|
||||
return dest;
|
||||
};
|
||||
|
||||
function pipeOnDrain(src) {
|
||||
return function () {
|
||||
var state = src._readableState;
|
||||
debug('pipeOnDrain', state.awaitDrain);
|
||||
if (state.awaitDrain) state.awaitDrain--;
|
||||
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
||||
state.flowing = true;
|
||||
flow(src);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Readable.prototype.unpipe = function (dest) {
|
||||
var state = this._readableState;
|
||||
|
||||
// if we're not piping anywhere, then do nothing.
|
||||
if (state.pipesCount === 0) return this;
|
||||
|
||||
// just one destination. most common case.
|
||||
if (state.pipesCount === 1) {
|
||||
// passed in one, but it's not the right one.
|
||||
if (dest && dest !== state.pipes) return this;
|
||||
|
||||
if (!dest) dest = state.pipes;
|
||||
|
||||
// got a match.
|
||||
state.pipes = null;
|
||||
state.pipesCount = 0;
|
||||
state.flowing = false;
|
||||
if (dest) dest.emit('unpipe', this);
|
||||
return this;
|
||||
}
|
||||
|
||||
// slow case. multiple pipe destinations.
|
||||
|
||||
if (!dest) {
|
||||
// remove all.
|
||||
var dests = state.pipes;
|
||||
var len = state.pipesCount;
|
||||
state.pipes = null;
|
||||
state.pipesCount = 0;
|
||||
state.flowing = false;
|
||||
|
||||
for (var _i = 0; _i < len; _i++) {
|
||||
dests[_i].emit('unpipe', this);
|
||||
}return this;
|
||||
}
|
||||
|
||||
// try to find the right one.
|
||||
var i = indexOf(state.pipes, dest);
|
||||
if (i === -1) return this;
|
||||
|
||||
state.pipes.splice(i, 1);
|
||||
state.pipesCount -= 1;
|
||||
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
||||
|
||||
dest.emit('unpipe', this);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// set up data events if they are asked for
|
||||
// Ensure readable listeners eventually get something
|
||||
Readable.prototype.on = function (ev, fn) {
|
||||
var res = Stream.prototype.on.call(this, ev, fn);
|
||||
|
||||
// If listening to data, and it has not explicitly been paused,
|
||||
// then call resume to start the flow of data on the next tick.
|
||||
if (ev === 'data' && false !== this._readableState.flowing) {
|
||||
this.resume();
|
||||
}
|
||||
|
||||
if (ev === 'readable' && !this._readableState.endEmitted) {
|
||||
var state = this._readableState;
|
||||
if (!state.readableListening) {
|
||||
state.readableListening = true;
|
||||
state.emittedReadable = false;
|
||||
state.needReadable = true;
|
||||
if (!state.reading) {
|
||||
processNextTick(nReadingNextTick, this);
|
||||
} else if (state.length) {
|
||||
emitReadable(this, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
Readable.prototype.addListener = Readable.prototype.on;
|
||||
|
||||
function nReadingNextTick(self) {
|
||||
debug('readable nexttick read 0');
|
||||
self.read(0);
|
||||
}
|
||||
|
||||
// pause() and resume() are remnants of the legacy readable stream API
|
||||
// If the user uses them, then switch into old mode.
|
||||
Readable.prototype.resume = function () {
|
||||
var state = this._readableState;
|
||||
if (!state.flowing) {
|
||||
debug('resume');
|
||||
state.flowing = true;
|
||||
resume(this, state);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
function resume(stream, state) {
|
||||
if (!state.resumeScheduled) {
|
||||
state.resumeScheduled = true;
|
||||
processNextTick(resume_, stream, state);
|
||||
}
|
||||
}
|
||||
|
||||
function resume_(stream, state) {
|
||||
if (!state.reading) {
|
||||
debug('resume read 0');
|
||||
stream.read(0);
|
||||
}
|
||||
|
||||
state.resumeScheduled = false;
|
||||
stream.emit('resume');
|
||||
flow(stream);
|
||||
if (state.flowing && !state.reading) stream.read(0);
|
||||
}
|
||||
|
||||
Readable.prototype.pause = function () {
|
||||
debug('call pause flowing=%j', this._readableState.flowing);
|
||||
if (false !== this._readableState.flowing) {
|
||||
debug('pause');
|
||||
this._readableState.flowing = false;
|
||||
this.emit('pause');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
function flow(stream) {
|
||||
var state = stream._readableState;
|
||||
debug('flow', state.flowing);
|
||||
if (state.flowing) {
|
||||
do {
|
||||
var chunk = stream.read();
|
||||
} while (null !== chunk && state.flowing);
|
||||
}
|
||||
}
|
||||
|
||||
// wrap an old-style stream as the async data source.
|
||||
// This is *not* part of the readable stream interface.
|
||||
// It is an ugly unfortunate mess of history.
|
||||
Readable.prototype.wrap = function (stream) {
|
||||
var state = this._readableState;
|
||||
var paused = false;
|
||||
|
||||
var self = this;
|
||||
stream.on('end', function () {
|
||||
debug('wrapped end');
|
||||
if (state.decoder && !state.ended) {
|
||||
var chunk = state.decoder.end();
|
||||
if (chunk && chunk.length) self.push(chunk);
|
||||
}
|
||||
|
||||
self.push(null);
|
||||
});
|
||||
|
||||
stream.on('data', function (chunk) {
|
||||
debug('wrapped data');
|
||||
if (state.decoder) chunk = state.decoder.write(chunk);
|
||||
|
||||
// don't skip over falsy values in objectMode
|
||||
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
||||
|
||||
var ret = self.push(chunk);
|
||||
if (!ret) {
|
||||
paused = true;
|
||||
stream.pause();
|
||||
}
|
||||
});
|
||||
|
||||
// proxy all the other methods.
|
||||
// important when wrapping filters and duplexes.
|
||||
for (var i in stream) {
|
||||
if (this[i] === undefined && typeof stream[i] === 'function') {
|
||||
this[i] = function (method) {
|
||||
return function () {
|
||||
return stream[method].apply(stream, arguments);
|
||||
};
|
||||
}(i);
|
||||
}
|
||||
}
|
||||
|
||||
// proxy certain important events.
|
||||
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
||||
forEach(events, function (ev) {
|
||||
stream.on(ev, self.emit.bind(self, ev));
|
||||
});
|
||||
|
||||
// when we try to consume some more bytes, simply unpause the
|
||||
// underlying stream.
|
||||
self._read = function (n) {
|
||||
debug('wrapped _read', n);
|
||||
if (paused) {
|
||||
paused = false;
|
||||
stream.resume();
|
||||
}
|
||||
};
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
// exposed for testing purposes only.
|
||||
Readable._fromList = fromList;
|
||||
|
||||
// Pluck off n bytes from an array of buffers.
|
||||
// Length is the combined lengths of all the buffers in the list.
|
||||
function fromList(n, state) {
|
||||
var list = state.buffer;
|
||||
var length = state.length;
|
||||
var stringMode = !!state.decoder;
|
||||
var objectMode = !!state.objectMode;
|
||||
var ret;
|
||||
|
||||
// nothing in the list, definitely empty.
|
||||
if (list.length === 0) return null;
|
||||
|
||||
if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) {
|
||||
// read it all, truncate the array.
|
||||
if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length);
|
||||
list.length = 0;
|
||||
} else {
|
||||
// read just some of it.
|
||||
if (n < list[0].length) {
|
||||
// just take a part of the first list item.
|
||||
// slice is the same for buffers and strings.
|
||||
var buf = list[0];
|
||||
ret = buf.slice(0, n);
|
||||
list[0] = buf.slice(n);
|
||||
} else if (n === list[0].length) {
|
||||
// first list is a perfect match
|
||||
ret = list.shift();
|
||||
} else {
|
||||
// complex case.
|
||||
// we have enough to cover it, but it spans past the first buffer.
|
||||
if (stringMode) ret = '';else ret = new Buffer(n);
|
||||
|
||||
var c = 0;
|
||||
for (var i = 0, l = list.length; i < l && c < n; i++) {
|
||||
var buf = list[0];
|
||||
var cpy = Math.min(n - c, buf.length);
|
||||
|
||||
if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy);
|
||||
|
||||
if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift();
|
||||
|
||||
c += cpy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function endReadable(stream) {
|
||||
var state = stream._readableState;
|
||||
|
||||
// If we get here before consuming all the bytes, then that is a
|
||||
// bug in node. Should never happen.
|
||||
if (state.length > 0) throw new Error('endReadable called on non-empty stream');
|
||||
|
||||
if (!state.endEmitted) {
|
||||
state.ended = true;
|
||||
processNextTick(endReadableNT, state, stream);
|
||||
}
|
||||
}
|
||||
|
||||
function endReadableNT(state, stream) {
|
||||
// Check that we didn't get one last unshift.
|
||||
if (!state.endEmitted && state.length === 0) {
|
||||
state.endEmitted = true;
|
||||
stream.readable = false;
|
||||
stream.emit('end');
|
||||
}
|
||||
}
|
||||
|
||||
function forEach(xs, f) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
f(xs[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
function indexOf(xs, x) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
if (xs[i] === x) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
180
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
180
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
// 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 Duplex = require('./_stream_duplex');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(Transform, Duplex);
|
||||
|
||||
function TransformState(stream) {
|
||||
this.afterTransform = function (er, data) {
|
||||
return afterTransform(stream, er, data);
|
||||
};
|
||||
|
||||
this.needTransform = false;
|
||||
this.transforming = false;
|
||||
this.writecb = null;
|
||||
this.writechunk = null;
|
||||
this.writeencoding = null;
|
||||
}
|
||||
|
||||
function afterTransform(stream, er, data) {
|
||||
var ts = stream._transformState;
|
||||
ts.transforming = false;
|
||||
|
||||
var cb = ts.writecb;
|
||||
|
||||
if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
|
||||
|
||||
ts.writechunk = null;
|
||||
ts.writecb = null;
|
||||
|
||||
if (data !== null && data !== undefined) stream.push(data);
|
||||
|
||||
cb(er);
|
||||
|
||||
var rs = stream._readableState;
|
||||
rs.reading = false;
|
||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||
stream._read(rs.highWaterMark);
|
||||
}
|
||||
}
|
||||
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform)) return new Transform(options);
|
||||
|
||||
Duplex.call(this, options);
|
||||
|
||||
this._transformState = new TransformState(this);
|
||||
|
||||
// when the writable side finishes, then flush out anything remaining.
|
||||
var stream = this;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
this.once('prefinish', function () {
|
||||
if (typeof this._flush === 'function') this._flush(function (er) {
|
||||
done(stream, er);
|
||||
});else done(stream);
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
throw new Error('not implemented');
|
||||
};
|
||||
|
||||
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.writecb && !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;
|
||||
}
|
||||
};
|
||||
|
||||
function done(stream, er) {
|
||||
if (er) return stream.emit('error', er);
|
||||
|
||||
// if there's nothing in the write buffer, then that means
|
||||
// that nothing more will ever be provided
|
||||
var ws = stream._writableState;
|
||||
var ts = stream._transformState;
|
||||
|
||||
if (ws.length) throw new Error('calling transform done when ws.length != 0');
|
||||
|
||||
if (ts.transforming) throw new Error('calling transform done when still transforming');
|
||||
|
||||
return stream.push(null);
|
||||
}
|
||||
516
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
516
build/node_modules/insert-module-globals/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
@@ -0,0 +1,516 @@
|
||||
// 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>*/
|
||||
var processNextTick = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Buffer = require('buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var internalUtil = {
|
||||
deprecate: require('util-deprecate')
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Stream;
|
||||
(function () {
|
||||
try {
|
||||
Stream = require('st' + 'ream');
|
||||
} catch (_) {} finally {
|
||||
if (!Stream) Stream = require('events').EventEmitter;
|
||||
}
|
||||
})();
|
||||
/*</replacement>*/
|
||||
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
|
||||
function nop() {}
|
||||
|
||||
function WriteReq(chunk, encoding, cb) {
|
||||
this.chunk = chunk;
|
||||
this.encoding = encoding;
|
||||
this.callback = cb;
|
||||
this.next = null;
|
||||
}
|
||||
|
||||
var Duplex;
|
||||
function WritableState(options, stream) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (stream instanceof Duplex) 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()
|
||||
var hwm = options.highWaterMark;
|
||||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||||
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = ~ ~this.highWaterMark;
|
||||
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
// count buffered requests
|
||||
this.bufferedRequestCount = 0;
|
||||
|
||||
// create the two objects needed to store the corked requests
|
||||
// they are not a linked list, as no new elements are inserted in there
|
||||
this.corkedRequestsFree = new CorkedRequest(this);
|
||||
this.corkedRequestsFree.next = new CorkedRequest(this);
|
||||
}
|
||||
|
||||
WritableState.prototype.getBuffer = function writableStateGetBuffer() {
|
||||
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 () {
|
||||
return this.getBuffer();
|
||||
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
|
||||
});
|
||||
} catch (_) {}
|
||||
})();
|
||||
|
||||
var Duplex;
|
||||
function Writable(options) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
// Writable ctor is applied to Duplexes, though they're not
|
||||
// instanceof Writable, they're instanceof Readable.
|
||||
if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
|
||||
|
||||
this._writableState = new WritableState(options, this);
|
||||
|
||||
// legacy.
|
||||
this.writable = true;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.write === 'function') this._write = options.write;
|
||||
|
||||
if (typeof options.writev === 'function') this._writev = options.writev;
|
||||
}
|
||||
|
||||
Stream.call(this);
|
||||
}
|
||||
|
||||
// Otherwise people can pipe Writable streams, which is just wrong.
|
||||
Writable.prototype.pipe = function () {
|
||||
this.emit('error', new Error('Cannot pipe. Not readable.'));
|
||||
};
|
||||
|
||||
function writeAfterEnd(stream, cb) {
|
||||
var er = new Error('write after end');
|
||||
// TODO: defer error events consistently everywhere, not just the cb
|
||||
stream.emit('error', er);
|
||||
processNextTick(cb, er);
|
||||
}
|
||||
|
||||
// If we get something that is not a buffer, string, null, or undefined,
|
||||
// and we're not in objectMode, then that's an error.
|
||||
// Otherwise stream chunks are all considered to be of length=1, and the
|
||||
// watermarks determine how many objects to keep in the buffer, rather than
|
||||
// how many bytes or characters.
|
||||
function validChunk(stream, state, chunk, cb) {
|
||||
var valid = true;
|
||||
|
||||
if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
|
||||
var er = new TypeError('Invalid non-string/buffer chunk');
|
||||
stream.emit('error', er);
|
||||
processNextTick(cb, er);
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
Writable.prototype.write = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
var ret = false;
|
||||
|
||||
if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
||||
|
||||
if (typeof cb !== 'function') cb = nop;
|
||||
|
||||
if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
|
||||
state.pendingcb++;
|
||||
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Writable.prototype.cork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
state.corked++;
|
||||
};
|
||||
|
||||
Writable.prototype.uncork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
if (state.corked) {
|
||||
state.corked--;
|
||||
|
||||
if (!state.writing && !state.corked && !state.finished && !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 TypeError('Unknown encoding: ' + encoding);
|
||||
this._writableState.defaultEncoding = encoding;
|
||||
};
|
||||
|
||||
function decodeChunk(state, chunk, encoding) {
|
||||
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
||||
chunk = new Buffer(chunk, encoding);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
// 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, chunk, encoding, cb) {
|
||||
chunk = decodeChunk(state, chunk, encoding);
|
||||
|
||||
if (Buffer.isBuffer(chunk)) encoding = 'buffer';
|
||||
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 = new WriteReq(chunk, encoding, cb);
|
||||
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 (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) processNextTick(cb, er);else cb(er);
|
||||
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
||||
clearBuffer(stream, state);
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
/*<replacement>*/
|
||||
asyncWrite(afterWrite, stream, state, finished, cb);
|
||||
/*</replacement>*/
|
||||
} 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;
|
||||
while (entry) {
|
||||
buffer[count] = entry;
|
||||
entry = entry.next;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
||||
|
||||
// doWrite is always async, defer these to save a bit of time
|
||||
// as the hot path ends with doWrite
|
||||
state.pendingcb++;
|
||||
state.lastBufferedRequest = null;
|
||||
state.corkedRequestsFree = holder.next;
|
||||
holder.next = null;
|
||||
} 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;
|
||||
// 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.bufferedRequestCount = 0;
|
||||
state.bufferedRequest = entry;
|
||||
state.bufferProcessing = false;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function (chunk, encoding, cb) {
|
||||
cb(new Error('not implemented'));
|
||||
};
|
||||
|
||||
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 && !state.finished) endWritable(this, state, cb);
|
||||
};
|
||||
|
||||
function needFinish(state) {
|
||||
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
||||
}
|
||||
|
||||
function prefinish(stream, state) {
|
||||
if (!state.prefinished) {
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
}
|
||||
}
|
||||
|
||||
function finishMaybe(stream, state) {
|
||||
var need = needFinish(state);
|
||||
if (need) {
|
||||
if (state.pendingcb === 0) {
|
||||
prefinish(stream, state);
|
||||
state.finished = true;
|
||||
stream.emit('finish');
|
||||
} else {
|
||||
prefinish(stream, state);
|
||||
}
|
||||
}
|
||||
return need;
|
||||
}
|
||||
|
||||
function endWritable(stream, state, cb) {
|
||||
state.ending = true;
|
||||
finishMaybe(stream, state);
|
||||
if (cb) {
|
||||
if (state.finished) processNextTick(cb);else stream.once('finish', cb);
|
||||
}
|
||||
state.ended = true;
|
||||
stream.writable = false;
|
||||
}
|
||||
|
||||
// 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 (err) {
|
||||
var entry = _this.entry;
|
||||
_this.entry = null;
|
||||
while (entry) {
|
||||
var cb = entry.callback;
|
||||
state.pendingcb--;
|
||||
cb(err);
|
||||
entry = entry.next;
|
||||
}
|
||||
if (state.corkedRequestsFree) {
|
||||
state.corkedRequestsFree.next = _this;
|
||||
} else {
|
||||
state.corkedRequestsFree = _this;
|
||||
}
|
||||
};
|
||||
}
|
||||
66
build/node_modules/insert-module-globals/node_modules/readable-stream/package.json
generated
vendored
Normal file
66
build/node_modules/insert-module-globals/node_modules/readable-stream/package.json
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "readable-stream@~2.0.0",
|
||||
"_id": "readable-stream@2.0.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=",
|
||||
"_location": "/insert-module-globals/readable-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "readable-stream@~2.0.0",
|
||||
"name": "readable-stream",
|
||||
"escapedName": "readable-stream",
|
||||
"rawSpec": "~2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/insert-module-globals/concat-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
|
||||
"_shasum": "8f90341e68a53ccc928788dacfcd11b36eb9b78e",
|
||||
"_spec": "readable-stream@~2.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/insert-module-globals/node_modules/concat-stream",
|
||||
"browser": {
|
||||
"util": false
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodejs/readable-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~1.0.6",
|
||||
"string_decoder": "~0.10.x",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Streams3, a user-land copy of the stream library from Node.js",
|
||||
"devDependencies": {
|
||||
"tap": "~0.2.6",
|
||||
"tape": "~4.5.1",
|
||||
"zuul": "~3.9.0"
|
||||
},
|
||||
"homepage": "https://github.com/nodejs/readable-stream#readme",
|
||||
"keywords": [
|
||||
"readable",
|
||||
"stream",
|
||||
"pipe"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "readable.js",
|
||||
"name": "readable-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/readable-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"browser": "npm run write-zuul && zuul -- test/browser.js",
|
||||
"test": "tap test/parallel/*.js test/ours/*.js",
|
||||
"write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml"
|
||||
},
|
||||
"version": "2.0.6"
|
||||
}
|
||||
1
build/node_modules/insert-module-globals/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_passthrough.js")
|
||||
12
build/node_modules/insert-module-globals/node_modules/readable-stream/readable.js
generated
vendored
Normal file
12
build/node_modules/insert-module-globals/node_modules/readable-stream/readable.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var Stream = (function (){
|
||||
try {
|
||||
return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify
|
||||
} catch(_){}
|
||||
}());
|
||||
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');
|
||||
1
build/node_modules/insert-module-globals/node_modules/readable-stream/transform.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/readable-stream/transform.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_transform.js")
|
||||
1
build/node_modules/insert-module-globals/node_modules/readable-stream/writable.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/readable-stream/writable.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_writable.js")
|
||||
2
build/node_modules/insert-module-globals/node_modules/string_decoder/.npmignore
generated
vendored
Normal file
2
build/node_modules/insert-module-globals/node_modules/string_decoder/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
build
|
||||
test
|
||||
20
build/node_modules/insert-module-globals/node_modules/string_decoder/LICENSE
generated
vendored
Normal file
20
build/node_modules/insert-module-globals/node_modules/string_decoder/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
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.
|
||||
7
build/node_modules/insert-module-globals/node_modules/string_decoder/README.md
generated
vendored
Normal file
7
build/node_modules/insert-module-globals/node_modules/string_decoder/README.md
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
**string_decoder.js** (`require('string_decoder')`) from Node.js core
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors. See LICENCE file for details.
|
||||
|
||||
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. **Prefer the stable version over the unstable.**
|
||||
|
||||
The *build/* directory contains a build script that will scrape the source from the [joyent/node](https://github.com/joyent/node) repo given a specific Node version.
|
||||
221
build/node_modules/insert-module-globals/node_modules/string_decoder/index.js
generated
vendored
Normal file
221
build/node_modules/insert-module-globals/node_modules/string_decoder/index.js
generated
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
// 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.
|
||||
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
var isBufferEncoding = Buffer.isEncoding
|
||||
|| function(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 assertEncoding(encoding) {
|
||||
if (encoding && !isBufferEncoding(encoding)) {
|
||||
throw new Error('Unknown encoding: ' + encoding);
|
||||
}
|
||||
}
|
||||
|
||||
// StringDecoder provides an interface for efficiently splitting a series of
|
||||
// buffers into a series of JS strings without breaking apart multi-byte
|
||||
// characters. CESU-8 is handled as part of the UTF-8 encoding.
|
||||
//
|
||||
// @TODO Handling all encodings inside a single object makes it very difficult
|
||||
// to reason about this code, so it should be split up in the future.
|
||||
// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
|
||||
// points as used by CESU-8.
|
||||
var StringDecoder = exports.StringDecoder = function(encoding) {
|
||||
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
||||
assertEncoding(encoding);
|
||||
switch (this.encoding) {
|
||||
case 'utf8':
|
||||
// CESU-8 represents each of Surrogate Pair by 3-bytes
|
||||
this.surrogateSize = 3;
|
||||
break;
|
||||
case 'ucs2':
|
||||
case 'utf16le':
|
||||
// UTF-16 represents each of Surrogate Pair by 2-bytes
|
||||
this.surrogateSize = 2;
|
||||
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
||||
break;
|
||||
case 'base64':
|
||||
// Base-64 stores 3 bytes in 4 chars, and pads the remainder.
|
||||
this.surrogateSize = 3;
|
||||
this.detectIncompleteChar = base64DetectIncompleteChar;
|
||||
break;
|
||||
default:
|
||||
this.write = passThroughWrite;
|
||||
return;
|
||||
}
|
||||
|
||||
// Enough space to store all bytes of a single character. UTF-8 needs 4
|
||||
// bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
|
||||
this.charBuffer = new Buffer(6);
|
||||
// Number of bytes received for the current incomplete multi-byte character.
|
||||
this.charReceived = 0;
|
||||
// Number of bytes expected for the current incomplete multi-byte character.
|
||||
this.charLength = 0;
|
||||
};
|
||||
|
||||
|
||||
// write decodes the given buffer and returns it as JS string that is
|
||||
// guaranteed to not contain any partial multi-byte characters. Any partial
|
||||
// character found at the end of the buffer is buffered up, and will be
|
||||
// returned when calling write again with the remaining bytes.
|
||||
//
|
||||
// Note: Converting a Buffer containing an orphan surrogate to a String
|
||||
// currently works, but converting a String to a Buffer (via `new Buffer`, or
|
||||
// Buffer#write) will replace incomplete surrogates with the unicode
|
||||
// replacement character. See https://codereview.chromium.org/121173009/ .
|
||||
StringDecoder.prototype.write = function(buffer) {
|
||||
var charStr = '';
|
||||
// if our last write ended with an incomplete multibyte character
|
||||
while (this.charLength) {
|
||||
// determine how many remaining bytes this buffer has to offer for this char
|
||||
var available = (buffer.length >= this.charLength - this.charReceived) ?
|
||||
this.charLength - this.charReceived :
|
||||
buffer.length;
|
||||
|
||||
// add the new bytes to the char buffer
|
||||
buffer.copy(this.charBuffer, this.charReceived, 0, available);
|
||||
this.charReceived += available;
|
||||
|
||||
if (this.charReceived < this.charLength) {
|
||||
// still not enough chars in this buffer? wait for more ...
|
||||
return '';
|
||||
}
|
||||
|
||||
// remove bytes belonging to the current character from the buffer
|
||||
buffer = buffer.slice(available, buffer.length);
|
||||
|
||||
// get the character that was split
|
||||
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
||||
|
||||
// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
|
||||
var charCode = charStr.charCodeAt(charStr.length - 1);
|
||||
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
||||
this.charLength += this.surrogateSize;
|
||||
charStr = '';
|
||||
continue;
|
||||
}
|
||||
this.charReceived = this.charLength = 0;
|
||||
|
||||
// if there are no more bytes in this buffer, just emit our char
|
||||
if (buffer.length === 0) {
|
||||
return charStr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// determine and set charLength / charReceived
|
||||
this.detectIncompleteChar(buffer);
|
||||
|
||||
var end = buffer.length;
|
||||
if (this.charLength) {
|
||||
// buffer the incomplete character bytes we got
|
||||
buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
|
||||
end -= this.charReceived;
|
||||
}
|
||||
|
||||
charStr += buffer.toString(this.encoding, 0, end);
|
||||
|
||||
var end = charStr.length - 1;
|
||||
var charCode = charStr.charCodeAt(end);
|
||||
// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
|
||||
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
||||
var size = this.surrogateSize;
|
||||
this.charLength += size;
|
||||
this.charReceived += size;
|
||||
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
||||
buffer.copy(this.charBuffer, 0, 0, size);
|
||||
return charStr.substring(0, end);
|
||||
}
|
||||
|
||||
// or just emit the charStr
|
||||
return charStr;
|
||||
};
|
||||
|
||||
// detectIncompleteChar determines if there is an incomplete UTF-8 character at
|
||||
// the end of the given buffer. If so, it sets this.charLength to the byte
|
||||
// length that character, and sets this.charReceived to the number of bytes
|
||||
// that are available for this character.
|
||||
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
||||
// determine how many bytes we have to check at the end of this buffer
|
||||
var i = (buffer.length >= 3) ? 3 : buffer.length;
|
||||
|
||||
// Figure out if one of the last i bytes of our buffer announces an
|
||||
// incomplete char.
|
||||
for (; i > 0; i--) {
|
||||
var c = buffer[buffer.length - i];
|
||||
|
||||
// See http://en.wikipedia.org/wiki/UTF-8#Description
|
||||
|
||||
// 110XXXXX
|
||||
if (i == 1 && c >> 5 == 0x06) {
|
||||
this.charLength = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
// 1110XXXX
|
||||
if (i <= 2 && c >> 4 == 0x0E) {
|
||||
this.charLength = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
// 11110XXX
|
||||
if (i <= 3 && c >> 3 == 0x1E) {
|
||||
this.charLength = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.charReceived = i;
|
||||
};
|
||||
|
||||
StringDecoder.prototype.end = function(buffer) {
|
||||
var res = '';
|
||||
if (buffer && buffer.length)
|
||||
res = this.write(buffer);
|
||||
|
||||
if (this.charReceived) {
|
||||
var cr = this.charReceived;
|
||||
var buf = this.charBuffer;
|
||||
var enc = this.encoding;
|
||||
res += buf.slice(0, cr).toString(enc);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
function passThroughWrite(buffer) {
|
||||
return buffer.toString(this.encoding);
|
||||
}
|
||||
|
||||
function utf16DetectIncompleteChar(buffer) {
|
||||
this.charReceived = buffer.length % 2;
|
||||
this.charLength = this.charReceived ? 2 : 0;
|
||||
}
|
||||
|
||||
function base64DetectIncompleteChar(buffer) {
|
||||
this.charReceived = buffer.length % 3;
|
||||
this.charLength = this.charReceived ? 3 : 0;
|
||||
}
|
||||
53
build/node_modules/insert-module-globals/node_modules/string_decoder/package.json
generated
vendored
Normal file
53
build/node_modules/insert-module-globals/node_modules/string_decoder/package.json
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"_from": "string_decoder@~0.10.x",
|
||||
"_id": "string_decoder@0.10.31",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
|
||||
"_location": "/insert-module-globals/string_decoder",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "string_decoder@~0.10.x",
|
||||
"name": "string_decoder",
|
||||
"escapedName": "string_decoder",
|
||||
"rawSpec": "~0.10.x",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~0.10.x"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/insert-module-globals/readable-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||
"_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94",
|
||||
"_spec": "string_decoder@~0.10.x",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/insert-module-globals/node_modules/readable-stream",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rvagg/string_decoder/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "The string_decoder module from Node core",
|
||||
"devDependencies": {
|
||||
"tap": "~0.4.8"
|
||||
},
|
||||
"homepage": "https://github.com/rvagg/string_decoder",
|
||||
"keywords": [
|
||||
"string",
|
||||
"decoder",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "string_decoder",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/rvagg/string_decoder.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/simple/*.js"
|
||||
},
|
||||
"version": "0.10.31"
|
||||
}
|
||||
3
build/node_modules/insert-module-globals/node_modules/through2/.npmignore
generated
vendored
Normal file
3
build/node_modules/insert-module-globals/node_modules/through2/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
test
|
||||
.jshintrc
|
||||
.travis.yml
|
||||
336
build/node_modules/insert-module-globals/node_modules/through2/LICENSE.html
generated
vendored
Normal file
336
build/node_modules/insert-module-globals/node_modules/through2/LICENSE.html
generated
vendored
Normal file
@@ -0,0 +1,336 @@
|
||||
<!doctype html>
|
||||
<!-- Created with GFM2HTML: https://github.com/rvagg/gfm2html -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title></title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="created-with" content="https://github.com/rvagg/gfm2html">
|
||||
|
||||
<style type="text/css">
|
||||
/* most of normalize.css */
|
||||
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}[hidden],template{display:none;}html{font-family:sans-serif;/*1*/-ms-text-size-adjust:100%;/*2*/-webkit-text-size-adjust:100%;/*2*/}body{margin:0;}a{background:transparent;}a:focus{outline:thindotted;}a:active,a:hover{outline:0;}h1{font-size:2em;margin:0.67em0;}abbr[title]{border-bottom:1pxdotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;}mark{background:#ff0;color:#000;}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em;}pre{white-space:pre-wrap;}q{quotes:"\201C""\201D""\2018""\2019";}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}table{border-collapse:collapse;border-spacing:0;}
|
||||
|
||||
html {
|
||||
font: 14px 'Helvetica Neue', Helvetica, arial, freesans, clean, sans-serif;
|
||||
}
|
||||
|
||||
.container {
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
background: #eee;
|
||||
border-radius: 3px;
|
||||
padding: 3px;
|
||||
width: 790px;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
.body-content {
|
||||
background-color: #fff;
|
||||
border: 1px solid #CACACA;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.body-content > *:first-child {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #4183c4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
p, blockquote, ul, ol, dl, table, pre {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.markdown-body h1
|
||||
, .markdown-body h2
|
||||
, .markdown-body h3
|
||||
, .markdown-body h4
|
||||
, .markdown-body h5
|
||||
, .markdown-body h6 {
|
||||
margin: 20px 0 10px;
|
||||
padding: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
color: #000;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2em;
|
||||
border-bottom: 1px solid #eee;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
background: transparent url("/img/hr.png") repeat-x 0 0;
|
||||
border: 0 none;
|
||||
color: #ccc;
|
||||
height: 4px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
tr:nth-child(2n) {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.markdown-body tr {
|
||||
border-top: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
td, th {
|
||||
border: 1px solid #ccc;
|
||||
padding: 6px 13px;
|
||||
}
|
||||
|
||||
th {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border-left: 4px solid #ddd;
|
||||
padding: 0 15px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
blockquote > :last-child, blockquote > :first-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-size: 13px;
|
||||
font-family: 'UbuntuMono', monospace;
|
||||
white-space: nowrap;
|
||||
margin: 0 2px;
|
||||
padding: 0px 5px;
|
||||
border: 1px solid #eaeaea;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
pre > code {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
pre {
|
||||
overflow-x: auto;
|
||||
white-space: pre;
|
||||
padding: 10px;
|
||||
line-height: 150%;
|
||||
background-color: #f8f8f8;
|
||||
border-color: #ccc;
|
||||
}
|
||||
|
||||
pre code, pre tt {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.highlight .c
|
||||
, .highlight .cm
|
||||
, .highlight .cp
|
||||
, .highlight .c1 {
|
||||
color:#999988;
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
.highlight .err {
|
||||
color:#a61717;
|
||||
background-color:#e3d2d2
|
||||
}
|
||||
|
||||
.highlight .o
|
||||
, .highlight .gs
|
||||
, .highlight .kc
|
||||
, .highlight .kd
|
||||
, .highlight .kn
|
||||
, .highlight .kp
|
||||
, .highlight .kr {
|
||||
font-weight:bold
|
||||
}
|
||||
|
||||
.highlight .cs {
|
||||
color:#999999;
|
||||
font-weight:bold;
|
||||
font-style:italic
|
||||
}
|
||||
|
||||
.highlight .gd {
|
||||
color:#000000;
|
||||
background-color:#ffdddd
|
||||
}
|
||||
|
||||
.highlight .gd .x {
|
||||
color:#000000;
|
||||
background-color:#ffaaaa
|
||||
}
|
||||
|
||||
.highlight .ge {
|
||||
font-style:italic
|
||||
}
|
||||
|
||||
.highlight .gr
|
||||
, .highlight .gt {
|
||||
color:#aa0000
|
||||
}
|
||||
|
||||
.highlight .gh
|
||||
, .highlight .bp {
|
||||
color:#999999
|
||||
}
|
||||
|
||||
.highlight .gi {
|
||||
color:#000000;
|
||||
background-color:#ddffdd
|
||||
}
|
||||
|
||||
.highlight .gi .x {
|
||||
color:#000000;
|
||||
background-color:#aaffaa
|
||||
}
|
||||
|
||||
.highlight .go {
|
||||
color:#888888
|
||||
}
|
||||
|
||||
.highlight .gp
|
||||
, .highlight .nn {
|
||||
color:#555555
|
||||
}
|
||||
|
||||
|
||||
.highlight .gu {
|
||||
color:#800080;
|
||||
font-weight:bold
|
||||
}
|
||||
|
||||
|
||||
.highlight .kt {
|
||||
color:#445588;
|
||||
font-weight:bold
|
||||
}
|
||||
|
||||
.highlight .m
|
||||
, .highlight .mf
|
||||
, .highlight .mh
|
||||
, .highlight .mi
|
||||
, .highlight .mo
|
||||
, .highlight .il {
|
||||
color:#009999
|
||||
}
|
||||
|
||||
.highlight .s
|
||||
, .highlight .sb
|
||||
, .highlight .sc
|
||||
, .highlight .sd
|
||||
, .highlight .s2
|
||||
, .highlight .se
|
||||
, .highlight .sh
|
||||
, .highlight .si
|
||||
, .highlight .sx
|
||||
, .highlight .s1 {
|
||||
color:#d14
|
||||
}
|
||||
|
||||
.highlight .n {
|
||||
color:#333333
|
||||
}
|
||||
|
||||
.highlight .na
|
||||
, .highlight .no
|
||||
, .highlight .nv
|
||||
, .highlight .vc
|
||||
, .highlight .vg
|
||||
, .highlight .vi
|
||||
, .highlight .nb {
|
||||
color:#0086B3
|
||||
}
|
||||
|
||||
.highlight .nc {
|
||||
color:#445588;
|
||||
font-weight:bold
|
||||
}
|
||||
|
||||
.highlight .ni {
|
||||
color:#800080
|
||||
}
|
||||
|
||||
.highlight .ne
|
||||
, .highlight .nf {
|
||||
color:#990000;
|
||||
font-weight:bold
|
||||
}
|
||||
|
||||
.highlight .nt {
|
||||
color:#000080
|
||||
}
|
||||
|
||||
.highlight .ow {
|
||||
font-weight:bold
|
||||
}
|
||||
|
||||
.highlight .w {
|
||||
color:#bbbbbb
|
||||
}
|
||||
|
||||
.highlight .sr {
|
||||
color:#009926
|
||||
}
|
||||
|
||||
.highlight .ss {
|
||||
color:#990073
|
||||
}
|
||||
|
||||
.highlight .gc {
|
||||
color:#999;
|
||||
background-color:#EAF2F5
|
||||
}
|
||||
|
||||
@media print {
|
||||
.container {
|
||||
background: transparent;
|
||||
border-radius: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.body-content {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="body-content"><h1 id="the-mit-license-mit-">The MIT License (MIT)</h1>
|
||||
<p><strong>Copyright (c) 2016 Rod Vagg (the "Original Author") and additional contributors</strong></p>
|
||||
<p>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:</p>
|
||||
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
9
build/node_modules/insert-module-globals/node_modules/through2/LICENSE.md
generated
vendored
Normal file
9
build/node_modules/insert-module-globals/node_modules/through2/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
**Copyright (c) 2016 Rod Vagg (the "Original Author") and additional 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.
|
||||
136
build/node_modules/insert-module-globals/node_modules/through2/README.md
generated
vendored
Normal file
136
build/node_modules/insert-module-globals/node_modules/through2/README.md
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
# through2
|
||||
|
||||
[](https://nodei.co/npm/through2/)
|
||||
|
||||
**A tiny wrapper around Node streams.Transform (Streams2) to avoid explicit subclassing noise**
|
||||
|
||||
Inspired by [Dominic Tarr](https://github.com/dominictarr)'s [through](https://github.com/dominictarr/through) in that it's so much easier to make a stream out of a function than it is to set up the prototype chain properly: `through(function (chunk) { ... })`.
|
||||
|
||||
Note: As 2.x.x this module starts using **Streams3** instead of Stream2. To continue using a Streams2 version use `npm install through2@0` to fetch the latest version of 0.x.x. More information about Streams2 vs Streams3 and recommendations see the article **[Why I don't use Node's core 'stream' module](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html)**.
|
||||
|
||||
```js
|
||||
fs.createReadStream('ex.txt')
|
||||
.pipe(through2(function (chunk, enc, callback) {
|
||||
for (var i = 0; i < chunk.length; i++)
|
||||
if (chunk[i] == 97)
|
||||
chunk[i] = 122 // swap 'a' for 'z'
|
||||
|
||||
this.push(chunk)
|
||||
|
||||
callback()
|
||||
}))
|
||||
.pipe(fs.createWriteStream('out.txt'))
|
||||
.on('finish', function () {
|
||||
doSomethingSpecial()
|
||||
})
|
||||
```
|
||||
|
||||
Or object streams:
|
||||
|
||||
```js
|
||||
var all = []
|
||||
|
||||
fs.createReadStream('data.csv')
|
||||
.pipe(csv2())
|
||||
.pipe(through2.obj(function (chunk, enc, callback) {
|
||||
var data = {
|
||||
name : chunk[0]
|
||||
, address : chunk[3]
|
||||
, phone : chunk[10]
|
||||
}
|
||||
this.push(data)
|
||||
|
||||
callback()
|
||||
}))
|
||||
.on('data', function (data) {
|
||||
all.push(data)
|
||||
})
|
||||
.on('end', function () {
|
||||
doSomethingSpecial(all)
|
||||
})
|
||||
```
|
||||
|
||||
Note that `through2.obj(fn)` is a convenience wrapper around `through2({ objectMode: true }, fn)`.
|
||||
|
||||
## API
|
||||
|
||||
<b><code>through2([ options, ] [ transformFunction ] [, flushFunction ])</code></b>
|
||||
|
||||
Consult the **[stream.Transform](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform)** documentation for the exact rules of the `transformFunction` (i.e. `this._transform`) and the optional `flushFunction` (i.e. `this._flush`).
|
||||
|
||||
### options
|
||||
|
||||
The options argument is optional and is passed straight through to `stream.Transform`. So you can use `objectMode:true` if you are processing non-binary streams (or just use `through2.obj()`).
|
||||
|
||||
The `options` argument is first, unlike standard convention, because if I'm passing in an anonymous function then I'd prefer for the options argument to not get lost at the end of the call:
|
||||
|
||||
```js
|
||||
fs.createReadStream('/tmp/important.dat')
|
||||
.pipe(through2({ objectMode: true, allowHalfOpen: false },
|
||||
function (chunk, enc, cb) {
|
||||
cb(null, 'wut?') // note we can use the second argument on the callback
|
||||
// to provide data as an alternative to this.push('wut?')
|
||||
}
|
||||
)
|
||||
.pipe(fs.createWriteStream('/tmp/wut.txt'))
|
||||
```
|
||||
|
||||
### transformFunction
|
||||
|
||||
The `transformFunction` must have the following signature: `function (chunk, encoding, callback) {}`. A minimal implementation should call the `callback` function to indicate that the transformation is done, even if that transformation means discarding the chunk.
|
||||
|
||||
To queue a new chunk, call `this.push(chunk)`—this can be called as many times as required before the `callback()` if you have multiple pieces to send on.
|
||||
|
||||
Alternatively, you may use `callback(err, chunk)` as shorthand for emitting a single chunk or an error.
|
||||
|
||||
If you **do not provide a `transformFunction`** then you will get a simple pass-through stream.
|
||||
|
||||
### flushFunction
|
||||
|
||||
The optional `flushFunction` is provided as the last argument (2nd or 3rd, depending on whether you've supplied options) is called just prior to the stream ending. Can be used to finish up any processing that may be in progress.
|
||||
|
||||
```js
|
||||
fs.createReadStream('/tmp/important.dat')
|
||||
.pipe(through2(
|
||||
function (chunk, enc, cb) { cb(null, chunk) }, // transform is a noop
|
||||
function (cb) { // flush function
|
||||
this.push('tacking on an extra buffer to the end');
|
||||
cb();
|
||||
}
|
||||
))
|
||||
.pipe(fs.createWriteStream('/tmp/wut.txt'));
|
||||
```
|
||||
|
||||
<b><code>through2.ctor([ options, ] transformFunction[, flushFunction ])</code></b>
|
||||
|
||||
Instead of returning a `stream.Transform` instance, `through2.ctor()` returns a **constructor** for a custom Transform. This is useful when you want to use the same transform logic in multiple instances.
|
||||
|
||||
```js
|
||||
var FToC = through2.ctor({objectMode: true}, function (record, encoding, callback) {
|
||||
if (record.temp != null && record.unit == "F") {
|
||||
record.temp = ( ( record.temp - 32 ) * 5 ) / 9
|
||||
record.unit = "C"
|
||||
}
|
||||
this.push(record)
|
||||
callback()
|
||||
})
|
||||
|
||||
// Create instances of FToC like so:
|
||||
var converter = new FToC()
|
||||
// Or:
|
||||
var converter = FToC()
|
||||
// Or specify/override options when you instantiate, if you prefer:
|
||||
var converter = FToC({objectMode: true})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [through2-map](https://github.com/brycebaril/through2-map) - Array.prototype.map analog for streams.
|
||||
- [through2-filter](https://github.com/brycebaril/through2-filter) - Array.prototype.filter analog for streams.
|
||||
- [through2-reduce](https://github.com/brycebaril/through2-reduce) - Array.prototype.reduce analog for streams.
|
||||
- [through2-spy](https://github.com/brycebaril/through2-spy) - Wrapper for simple stream.PassThrough spies.
|
||||
- the [mississippi stream utility collection](https://github.com/maxogden/mississippi) includes `through2` as well as many more useful stream modules similar to this one
|
||||
|
||||
## License
|
||||
|
||||
**through2** is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
||||
9
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/.npmignore
generated
vendored
Normal file
9
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
build/
|
||||
test/
|
||||
examples/
|
||||
fs.js
|
||||
zlib.js
|
||||
.zuul.yml
|
||||
.nyc_output
|
||||
coverage
|
||||
docs/
|
||||
65
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
65
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
before_install:
|
||||
- npm install -g npm@2
|
||||
- test $NPM_LEGACY && npm install -g npm@latest-3 || npm install npm -g
|
||||
notifications:
|
||||
email: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.10'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.11'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.12'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 1
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 2
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 3
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 4
|
||||
env: TASK=test
|
||||
- node_js: 5
|
||||
env: TASK=test
|
||||
- node_js: 6
|
||||
env: TASK=test
|
||||
- node_js: 7
|
||||
env: TASK=test
|
||||
- node_js: 8
|
||||
env: TASK=test
|
||||
- node_js: 6
|
||||
env: TASK=browser BROWSER_NAME=ie BROWSER_VERSION="9..latest"
|
||||
- node_js: 6
|
||||
env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest"
|
||||
- node_js: 6
|
||||
env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="-3..latest"
|
||||
- node_js: 6
|
||||
env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="-3..latest"
|
||||
- node_js: 6
|
||||
env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest"
|
||||
- node_js: 6
|
||||
env: TASK=browser BROWSER_NAME=microsoftedge BROWSER_VERSION=latest
|
||||
script: "npm run $TASK"
|
||||
env:
|
||||
global:
|
||||
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
|
||||
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
|
||||
38
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal file
38
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal 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
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal file
136
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal 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
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
47
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/LICENSE
generated
vendored
Normal 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.
|
||||
"""
|
||||
57
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/README.md
generated
vendored
Normal file
57
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/README.md
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# readable-stream
|
||||
|
||||
***Node-core v8.1.3 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
|
||||
|
||||
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
|
||||
|
||||
[](https://saucelabs.com/u/readable-stream)
|
||||
|
||||
```bash
|
||||
npm install --save readable-stream
|
||||
```
|
||||
|
||||
***Node-core streams for userland***
|
||||
|
||||
This package is a mirror of the Streams2 and Streams3 implementations in
|
||||
Node-core.
|
||||
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.1.3/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.
|
||||
|
||||
# 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
|
||||
|
||||
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com>
|
||||
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
|
||||
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
|
||||
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
|
||||
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org>
|
||||
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
|
||||
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com>
|
||||
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
|
||||
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me>
|
||||
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com>
|
||||
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
|
||||
60
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
60
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# streams WG Meeting 2015-01-30
|
||||
|
||||
## Links
|
||||
|
||||
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
|
||||
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
|
||||
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
|
||||
|
||||
## Agenda
|
||||
|
||||
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
|
||||
|
||||
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
|
||||
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
|
||||
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
|
||||
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
|
||||
|
||||
## Minutes
|
||||
|
||||
### adopt a charter
|
||||
|
||||
* group: +1's all around
|
||||
|
||||
### What versioning scheme should be adopted?
|
||||
* group: +1’s 3.0.0
|
||||
* domenic+group: pulling in patches from other sources where appropriate
|
||||
* mikeal: version independently, suggesting versions for io.js
|
||||
* mikeal+domenic: work with TC to notify in advance of changes
|
||||
simpler stream creation
|
||||
|
||||
### streamline creation of streams
|
||||
* sam: streamline creation of streams
|
||||
* domenic: nice simple solution posted
|
||||
but, we lose the opportunity to change the model
|
||||
may not be backwards incompatible (double check keys)
|
||||
|
||||
**action item:** domenic will check
|
||||
|
||||
### remove implicit flowing of streams on(‘data’)
|
||||
* add isFlowing / isPaused
|
||||
* mikeal: worrying that we’re documenting polyfill methods – confuses users
|
||||
* domenic: more reflective API is probably good, with warning labels for users
|
||||
* new section for mad scientists (reflective stream access)
|
||||
* calvin: name the “third state”
|
||||
* mikeal: maybe borrow the name from whatwg?
|
||||
* domenic: we’re missing the “third state”
|
||||
* consensus: kind of difficult to name the third state
|
||||
* mikeal: figure out differences in states / compat
|
||||
* mathias: always flow on data – eliminates third state
|
||||
* explore what it breaks
|
||||
|
||||
**action items:**
|
||||
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
|
||||
* ask rod/build for infrastructure
|
||||
* **chris**: explore the “flow on data” approach
|
||||
* add isPaused/isFlowing
|
||||
* add new docs section
|
||||
* move isPaused to that section
|
||||
|
||||
|
||||
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_duplex.js');
|
||||
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Duplex
|
||||
124
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
124
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
// 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 processNextTick = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) {
|
||||
keys.push(key);
|
||||
}return keys;
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
module.exports = Duplex;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Readable = require('./_stream_readable');
|
||||
var Writable = require('./_stream_writable');
|
||||
|
||||
util.inherits(Duplex, Readable);
|
||||
|
||||
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);
|
||||
|
||||
if (options && options.readable === false) this.readable = false;
|
||||
|
||||
if (options && options.writable === false) this.writable = false;
|
||||
|
||||
this.allowHalfOpen = true;
|
||||
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
||||
|
||||
this.once('end', onend);
|
||||
}
|
||||
|
||||
// the no-half-open enforcer
|
||||
function onend() {
|
||||
// if we allow half-open state, or if the writable side ended,
|
||||
// then we're ok.
|
||||
if (this.allowHalfOpen || this._writableState.ended) return;
|
||||
|
||||
// no more data can be written.
|
||||
// But allow more writes to happen in this tick.
|
||||
processNextTick(onEndNT, this);
|
||||
}
|
||||
|
||||
function onEndNT(self) {
|
||||
self.end();
|
||||
}
|
||||
|
||||
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._readableState === undefined || this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._readableState.destroyed && this._writableState.destroyed;
|
||||
},
|
||||
set: function (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;
|
||||
}
|
||||
});
|
||||
|
||||
Duplex.prototype._destroy = function (err, cb) {
|
||||
this.push(null);
|
||||
this.end();
|
||||
|
||||
processNextTick(cb, err);
|
||||
};
|
||||
|
||||
function forEach(xs, f) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
f(xs[i], i);
|
||||
}
|
||||
}
|
||||
47
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
47
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.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);
|
||||
};
|
||||
1007
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
1007
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
214
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
214
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
// 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 Duplex = require('./_stream_duplex');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(Transform, Duplex);
|
||||
|
||||
function TransformState(stream) {
|
||||
this.afterTransform = function (er, data) {
|
||||
return afterTransform(stream, er, data);
|
||||
};
|
||||
|
||||
this.needTransform = false;
|
||||
this.transforming = false;
|
||||
this.writecb = null;
|
||||
this.writechunk = null;
|
||||
this.writeencoding = null;
|
||||
}
|
||||
|
||||
function afterTransform(stream, er, data) {
|
||||
var ts = stream._transformState;
|
||||
ts.transforming = false;
|
||||
|
||||
var cb = ts.writecb;
|
||||
|
||||
if (!cb) {
|
||||
return stream.emit('error', new Error('write callback called multiple times'));
|
||||
}
|
||||
|
||||
ts.writechunk = null;
|
||||
ts.writecb = null;
|
||||
|
||||
if (data !== null && data !== undefined) stream.push(data);
|
||||
|
||||
cb(er);
|
||||
|
||||
var rs = stream._readableState;
|
||||
rs.reading = false;
|
||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||
stream._read(rs.highWaterMark);
|
||||
}
|
||||
}
|
||||
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform)) return new Transform(options);
|
||||
|
||||
Duplex.call(this, options);
|
||||
|
||||
this._transformState = new TransformState(this);
|
||||
|
||||
var stream = this;
|
||||
|
||||
// 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.once('prefinish', function () {
|
||||
if (typeof this._flush === 'function') this._flush(function (er, data) {
|
||||
done(stream, er, data);
|
||||
});else done(stream);
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
throw new Error('_transform() is not implemented');
|
||||
};
|
||||
|
||||
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.writecb && !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) {
|
||||
var _this = this;
|
||||
|
||||
Duplex.prototype._destroy.call(this, err, function (err2) {
|
||||
cb(err2);
|
||||
_this.emit('close');
|
||||
});
|
||||
};
|
||||
|
||||
function done(stream, er, data) {
|
||||
if (er) return stream.emit('error', er);
|
||||
|
||||
if (data !== null && data !== undefined) stream.push(data);
|
||||
|
||||
// if there's nothing in the write buffer, then that means
|
||||
// that nothing more will ever be provided
|
||||
var ws = stream._writableState;
|
||||
var ts = stream._transformState;
|
||||
|
||||
if (ws.length) throw new Error('Calling transform done when ws.length != 0');
|
||||
|
||||
if (ts.transforming) throw new Error('Calling transform done when still transforming');
|
||||
|
||||
return stream.push(null);
|
||||
}
|
||||
664
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
664
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
@@ -0,0 +1,664 @@
|
||||
// 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';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var processNextTick = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
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 asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Duplex;
|
||||
/*</replacement>*/
|
||||
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var internalUtil = {
|
||||
deprecate: require('util-deprecate')
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Stream = require('./internal/streams/stream');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var OurUint8Array = global.Uint8Array || function () {};
|
||||
function _uint8ArrayToBuffer(chunk) {
|
||||
return Buffer.from(chunk);
|
||||
}
|
||||
function _isUint8Array(obj) {
|
||||
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
||||
}
|
||||
/*</replacement>*/
|
||||
|
||||
var destroyImpl = require('./internal/streams/destroy');
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
|
||||
function nop() {}
|
||||
|
||||
function WritableState(options, stream) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (stream instanceof Duplex) 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()
|
||||
var hwm = options.highWaterMark;
|
||||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||||
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = Math.floor(this.highWaterMark);
|
||||
|
||||
// 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;
|
||||
|
||||
// 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 () {
|
||||
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 (object) {
|
||||
if (realHasInstance.call(this, object)) return true;
|
||||
|
||||
return object && object._writableState instanceof WritableState;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
realHasInstance = function (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.
|
||||
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
||||
return new Writable(options);
|
||||
}
|
||||
|
||||
this._writableState = new WritableState(options, this);
|
||||
|
||||
// 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 () {
|
||||
this.emit('error', new Error('Cannot pipe, not readable'));
|
||||
};
|
||||
|
||||
function writeAfterEnd(stream, cb) {
|
||||
var er = new Error('write after end');
|
||||
// TODO: defer error events consistently everywhere, not just the cb
|
||||
stream.emit('error', er);
|
||||
processNextTick(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 valid = true;
|
||||
var er = false;
|
||||
|
||||
if (chunk === null) {
|
||||
er = new TypeError('May not write null values to stream');
|
||||
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
||||
er = new TypeError('Invalid non-string/buffer chunk');
|
||||
}
|
||||
if (er) {
|
||||
stream.emit('error', er);
|
||||
processNextTick(cb, er);
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
Writable.prototype.write = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
var ret = false;
|
||||
var isBuf = _isUint8Array(chunk) && !state.objectMode;
|
||||
|
||||
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.ended) 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 () {
|
||||
var state = this._writableState;
|
||||
|
||||
state.corked++;
|
||||
};
|
||||
|
||||
Writable.prototype.uncork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
if (state.corked) {
|
||||
state.corked--;
|
||||
|
||||
if (!state.writing && !state.corked && !state.finished && !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 TypeError('Unknown encoding: ' + encoding);
|
||||
this._writableState.defaultEncoding = encoding;
|
||||
return this;
|
||||
};
|
||||
|
||||
function decodeChunk(state, chunk, encoding) {
|
||||
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
||||
chunk = Buffer.from(chunk, encoding);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
// 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 (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
|
||||
processNextTick(cb, er);
|
||||
// this can emit finish, and it will always happen
|
||||
// after error
|
||||
processNextTick(finishMaybe, stream, state);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
} else {
|
||||
// the caller expect this to happen before if
|
||||
// it is async
|
||||
cb(er);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', 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;
|
||||
|
||||
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);
|
||||
|
||||
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
||||
clearBuffer(stream, state);
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
/*<replacement>*/
|
||||
asyncWrite(afterWrite, stream, state, finished, cb);
|
||||
/*</replacement>*/
|
||||
} 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);
|
||||
}
|
||||
} 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;
|
||||
// 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.bufferedRequestCount = 0;
|
||||
state.bufferedRequest = entry;
|
||||
state.bufferProcessing = false;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function (chunk, encoding, cb) {
|
||||
cb(new Error('_write() is not implemented'));
|
||||
};
|
||||
|
||||
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 && !state.finished) endWritable(this, state, cb);
|
||||
};
|
||||
|
||||
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) {
|
||||
stream.emit('error', 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.pendingcb++;
|
||||
state.finalCalled = true;
|
||||
processNextTick(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');
|
||||
}
|
||||
}
|
||||
return need;
|
||||
}
|
||||
|
||||
function endWritable(stream, state, cb) {
|
||||
state.ending = true;
|
||||
finishMaybe(stream, state);
|
||||
if (cb) {
|
||||
if (state.finished) processNextTick(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;
|
||||
}
|
||||
if (state.corkedRequestsFree) {
|
||||
state.corkedRequestsFree.next = corkReq;
|
||||
} else {
|
||||
state.corkedRequestsFree = corkReq;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._writableState.destroyed;
|
||||
},
|
||||
set: function (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) {
|
||||
this.end();
|
||||
cb(err);
|
||||
};
|
||||
74
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
74
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
function copyBuffer(src, target, offset) {
|
||||
src.copy(target, offset);
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
function BufferList() {
|
||||
_classCallCheck(this, BufferList);
|
||||
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
BufferList.prototype.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;
|
||||
};
|
||||
|
||||
BufferList.prototype.unshift = function unshift(v) {
|
||||
var entry = { data: v, next: this.head };
|
||||
if (this.length === 0) this.tail = entry;
|
||||
this.head = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
BufferList.prototype.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;
|
||||
};
|
||||
|
||||
BufferList.prototype.clear = function clear() {
|
||||
this.head = this.tail = null;
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
BufferList.prototype.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;
|
||||
};
|
||||
|
||||
BufferList.prototype.concat = function concat(n) {
|
||||
if (this.length === 0) return Buffer.alloc(0);
|
||||
if (this.length === 1) return this.head.data;
|
||||
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;
|
||||
};
|
||||
|
||||
return BufferList;
|
||||
}();
|
||||
72
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
72
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var processNextTick = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
// 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 && (!this._writableState || !this._writableState.errorEmitted)) {
|
||||
processNextTick(emitErrorNT, this, err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
processNextTick(emitErrorNT, _this, err);
|
||||
if (_this._writableState) {
|
||||
_this._writableState.errorEmitted = true;
|
||||
}
|
||||
} else if (cb) {
|
||||
cb(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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.finished = false;
|
||||
this._writableState.errorEmitted = false;
|
||||
}
|
||||
}
|
||||
|
||||
function emitErrorNT(self, err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
destroy: destroy,
|
||||
undestroy: undestroy
|
||||
};
|
||||
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('events').EventEmitter;
|
||||
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('stream');
|
||||
83
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/package.json
generated
vendored
Normal file
83
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/package.json
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"_from": "readable-stream@^2.1.5",
|
||||
"_id": "readable-stream@2.3.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
|
||||
"_location": "/insert-module-globals/through2/readable-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "readable-stream@^2.1.5",
|
||||
"name": "readable-stream",
|
||||
"escapedName": "readable-stream",
|
||||
"rawSpec": "^2.1.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/insert-module-globals/through2"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
|
||||
"_shasum": "368f2512d79f9d46fdfc71349ae7878bbc1eb95c",
|
||||
"_spec": "readable-stream@^2.1.5",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/insert-module-globals/node_modules/through2",
|
||||
"browser": {
|
||||
"util": false,
|
||||
"./readable.js": "./readable-browser.js",
|
||||
"./writable.js": "./writable-browser.js",
|
||||
"./duplex.js": "./duplex-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": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~1.0.6",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.0.3",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Streams3, a user-land copy of the stream library from Node.js",
|
||||
"devDependencies": {
|
||||
"assert": "~1.4.0",
|
||||
"babel-polyfill": "^6.9.1",
|
||||
"buffer": "^4.9.0",
|
||||
"nyc": "^6.4.0",
|
||||
"tap": "~0.7.1",
|
||||
"tape": "~4.5.1",
|
||||
"zuul": "~3.10.0"
|
||||
},
|
||||
"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": {
|
||||
"browser": "npm run write-zuul && zuul --browser-retries 2 -- test/browser.js",
|
||||
"cover": "nyc npm test",
|
||||
"local": "zuul --local 3000 --no-coverage -- test/browser.js",
|
||||
"report": "nyc report --reporter=lcov",
|
||||
"test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js",
|
||||
"write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml"
|
||||
},
|
||||
"version": "2.3.3"
|
||||
}
|
||||
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').PassThrough
|
||||
7
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
7
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
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');
|
||||
19
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/readable.js
generated
vendored
Normal file
19
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/readable.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var Stream = require('stream');
|
||||
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
||||
module.exports = Stream;
|
||||
exports = module.exports = Stream.Readable;
|
||||
exports.Readable = Stream.Readable;
|
||||
exports.Writable = Stream.Writable;
|
||||
exports.Duplex = Stream.Duplex;
|
||||
exports.Transform = Stream.Transform;
|
||||
exports.PassThrough = Stream.PassThrough;
|
||||
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');
|
||||
}
|
||||
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/transform.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/transform.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Transform
|
||||
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_writable.js');
|
||||
8
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/writable.js
generated
vendored
Normal file
8
build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream/writable.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
var Stream = require("stream")
|
||||
var Writable = require("./lib/_stream_writable.js")
|
||||
|
||||
if (process.env.READABLE_STREAM === 'disable') {
|
||||
module.exports = Stream && Stream.Writable || Writable
|
||||
} else {
|
||||
module.exports = Writable
|
||||
}
|
||||
2
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/.npmignore
generated
vendored
Normal file
2
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
build
|
||||
test
|
||||
48
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/LICENSE
generated
vendored
Normal file
48
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/LICENSE
generated
vendored
Normal 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.
|
||||
"""
|
||||
|
||||
28
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/README.md
generated
vendored
Normal file
28
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/README.md
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# string_decoder
|
||||
|
||||
***Node-core v7.0.0 string_decoder for userland***
|
||||
|
||||
|
||||
[](https://nodei.co/npm/string_decoder/)
|
||||
[](https://nodei.co/npm/string_decoder/)
|
||||
|
||||
|
||||
```bash
|
||||
npm install --save string_decoder
|
||||
```
|
||||
|
||||
***Node-core string_decoderstring_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/v7.8.0/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.
|
||||
272
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/lib/string_decoder.js
generated
vendored
Normal file
272
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/lib/string_decoder.js
generated
vendored
Normal file
@@ -0,0 +1,272 @@
|
||||
'use strict';
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
|
||||
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.
|
||||
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 -1;
|
||||
}
|
||||
|
||||
// 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) return 0;
|
||||
nb = utf8CheckByte(buf[j]);
|
||||
if (nb >= 0) {
|
||||
if (nb > 0) self.lastNeed = nb - 2;
|
||||
return nb;
|
||||
}
|
||||
if (--j < i) 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
|
||||
// UTF-8 replacement characters ('\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'.repeat(p);
|
||||
}
|
||||
if (self.lastNeed > 1 && buf.length > 1) {
|
||||
if ((buf[1] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 1;
|
||||
return '\ufffd'.repeat(p + 1);
|
||||
}
|
||||
if (self.lastNeed > 2 && buf.length > 2) {
|
||||
if ((buf[2] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 2;
|
||||
return '\ufffd'.repeat(p + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 for each buffered byte of a (partial)
|
||||
// character needs to be added to the output.
|
||||
function utf8End(buf) {
|
||||
var r = buf && buf.length ? this.write(buf) : '';
|
||||
if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
|
||||
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) : '';
|
||||
}
|
||||
56
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/package.json
generated
vendored
Normal file
56
build/node_modules/insert-module-globals/node_modules/through2/node_modules/string_decoder/package.json
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"_from": "string_decoder@~1.0.3",
|
||||
"_id": "string_decoder@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
||||
"_location": "/insert-module-globals/through2/string_decoder",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "string_decoder@~1.0.3",
|
||||
"name": "string_decoder",
|
||||
"escapedName": "string_decoder",
|
||||
"rawSpec": "~1.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/insert-module-globals/through2/readable-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||
"_shasum": "0fc67d7c141825de94282dd536bec6b9bce860ab",
|
||||
"_spec": "string_decoder@~1.0.3",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/insert-module-globals/node_modules/through2/node_modules/readable-stream",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rvagg/string_decoder/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "The string_decoder module from Node core",
|
||||
"devDependencies": {
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"tap": "~0.4.8"
|
||||
},
|
||||
"homepage": "https://github.com/rvagg/string_decoder",
|
||||
"keywords": [
|
||||
"string",
|
||||
"decoder",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/string_decoder.js",
|
||||
"name": "string_decoder",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/rvagg/string_decoder.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/parallel/*.js && node test/verify-dependencies"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
||||
72
build/node_modules/insert-module-globals/node_modules/through2/package.json
generated
vendored
Normal file
72
build/node_modules/insert-module-globals/node_modules/through2/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"_from": "through2@^2.0.0",
|
||||
"_id": "through2@2.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
|
||||
"_location": "/insert-module-globals/through2",
|
||||
"_phantomChildren": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "1.0.0",
|
||||
"process-nextick-args": "1.0.7",
|
||||
"safe-buffer": "5.1.1",
|
||||
"util-deprecate": "1.0.2"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "through2@^2.0.0",
|
||||
"name": "through2",
|
||||
"escapedName": "through2",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/insert-module-globals"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
|
||||
"_shasum": "0004569b37c7c74ba39c43f3ced78d1ad94140be",
|
||||
"_spec": "through2@^2.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/insert-module-globals",
|
||||
"author": {
|
||||
"name": "Rod Vagg",
|
||||
"email": "r@va.gg",
|
||||
"url": "https://github.com/rvagg"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/rvagg/through2/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"readable-stream": "^2.1.5",
|
||||
"xtend": "~4.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
|
||||
"devDependencies": {
|
||||
"bl": "~1.1.2",
|
||||
"faucet": "0.0.1",
|
||||
"stream-spigot": "~3.0.5",
|
||||
"tape": "~4.6.2"
|
||||
},
|
||||
"homepage": "https://github.com/rvagg/through2#readme",
|
||||
"keywords": [
|
||||
"stream",
|
||||
"streams2",
|
||||
"through",
|
||||
"transform"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "through2.js",
|
||||
"name": "through2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rvagg/through2.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js | faucet",
|
||||
"test-local": "brtapsauce-local test/basic-test.js"
|
||||
},
|
||||
"version": "2.0.3"
|
||||
}
|
||||
96
build/node_modules/insert-module-globals/node_modules/through2/through2.js
generated
vendored
Normal file
96
build/node_modules/insert-module-globals/node_modules/through2/through2.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
var Transform = require('readable-stream/transform')
|
||||
, inherits = require('util').inherits
|
||||
, xtend = require('xtend')
|
||||
|
||||
function DestroyableTransform(opts) {
|
||||
Transform.call(this, opts)
|
||||
this._destroyed = false
|
||||
}
|
||||
|
||||
inherits(DestroyableTransform, Transform)
|
||||
|
||||
DestroyableTransform.prototype.destroy = function(err) {
|
||||
if (this._destroyed) return
|
||||
this._destroyed = true
|
||||
|
||||
var self = this
|
||||
process.nextTick(function() {
|
||||
if (err)
|
||||
self.emit('error', err)
|
||||
self.emit('close')
|
||||
})
|
||||
}
|
||||
|
||||
// a noop _transform function
|
||||
function noop (chunk, enc, callback) {
|
||||
callback(null, chunk)
|
||||
}
|
||||
|
||||
|
||||
// create a new export function, used by both the main export and
|
||||
// the .ctor export, contains common logic for dealing with arguments
|
||||
function through2 (construct) {
|
||||
return function (options, transform, flush) {
|
||||
if (typeof options == 'function') {
|
||||
flush = transform
|
||||
transform = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
if (typeof transform != 'function')
|
||||
transform = noop
|
||||
|
||||
if (typeof flush != 'function')
|
||||
flush = null
|
||||
|
||||
return construct(options, transform, flush)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// main export, just make me a transform stream!
|
||||
module.exports = through2(function (options, transform, flush) {
|
||||
var t2 = new DestroyableTransform(options)
|
||||
|
||||
t2._transform = transform
|
||||
|
||||
if (flush)
|
||||
t2._flush = flush
|
||||
|
||||
return t2
|
||||
})
|
||||
|
||||
|
||||
// make me a reusable prototype that I can `new`, or implicitly `new`
|
||||
// with a constructor call
|
||||
module.exports.ctor = through2(function (options, transform, flush) {
|
||||
function Through2 (override) {
|
||||
if (!(this instanceof Through2))
|
||||
return new Through2(override)
|
||||
|
||||
this.options = xtend(options, override)
|
||||
|
||||
DestroyableTransform.call(this, this.options)
|
||||
}
|
||||
|
||||
inherits(Through2, DestroyableTransform)
|
||||
|
||||
Through2.prototype._transform = transform
|
||||
|
||||
if (flush)
|
||||
Through2.prototype._flush = flush
|
||||
|
||||
return Through2
|
||||
})
|
||||
|
||||
|
||||
module.exports.obj = through2(function (options, transform, flush) {
|
||||
var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
|
||||
|
||||
t2._transform = transform
|
||||
|
||||
if (flush)
|
||||
t2._flush = flush
|
||||
|
||||
return t2
|
||||
})
|
||||
86
build/node_modules/insert-module-globals/package.json
generated
vendored
Normal file
86
build/node_modules/insert-module-globals/package.json
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"_from": "insert-module-globals@^7.0.0",
|
||||
"_id": "insert-module-globals@7.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=",
|
||||
"_location": "/insert-module-globals",
|
||||
"_phantomChildren": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "1.0.0",
|
||||
"process-nextick-args": "1.0.7",
|
||||
"safe-buffer": "5.1.1",
|
||||
"typedarray": "0.0.6",
|
||||
"util-deprecate": "1.0.2",
|
||||
"xtend": "4.0.1"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "insert-module-globals@^7.0.0",
|
||||
"name": "insert-module-globals",
|
||||
"escapedName": "insert-module-globals",
|
||||
"rawSpec": "^7.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^7.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/browserify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz",
|
||||
"_shasum": "c03bf4e01cb086d5b5e5ace8ad0afe7889d638c3",
|
||||
"_spec": "insert-module-globals@^7.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/browserify",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bin": {
|
||||
"insert-module-globals": "bin/cmd.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/insert-module-globals/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"JSONStream": "^1.0.3",
|
||||
"combine-source-map": "~0.7.1",
|
||||
"concat-stream": "~1.5.1",
|
||||
"is-buffer": "^1.1.0",
|
||||
"lexical-scope": "^1.2.0",
|
||||
"process": "~0.11.0",
|
||||
"through2": "^2.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "insert implicit module globals into a module-deps stream",
|
||||
"devDependencies": {
|
||||
"browser-pack": "^6.0.0",
|
||||
"buffer": "^3.0.0",
|
||||
"convert-source-map": "~1.1.0",
|
||||
"module-deps": "^4.0.2",
|
||||
"tape": "^4.2.0"
|
||||
},
|
||||
"homepage": "https://github.com/substack/insert-module-globals",
|
||||
"keywords": [
|
||||
"__filename",
|
||||
"__dirname",
|
||||
"global",
|
||||
"process",
|
||||
"module-deps",
|
||||
"browser-pack",
|
||||
"browserify"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "insert-module-globals",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/insert-module-globals.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"version": "7.0.1"
|
||||
}
|
||||
146
build/node_modules/insert-module-globals/readme.markdown
generated
vendored
Normal file
146
build/node_modules/insert-module-globals/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
# insert-module-globals
|
||||
|
||||
insert implicit module globals
|
||||
(`__filename`, `__dirname`, `process`, `global`, and `Buffer`)
|
||||
as a browserify-style transform
|
||||
|
||||
[](http://travis-ci.org/substack/insert-module-globals)
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var mdeps = require('module-deps');
|
||||
var bpack = require('browser-pack');
|
||||
var insert = require('insert-module-globals');
|
||||
function inserter (file) {
|
||||
return insert(file, { basedir: __dirname + '/files' });
|
||||
}
|
||||
|
||||
var files = [ __dirname + '/files/main.js' ];
|
||||
mdeps(files, { transform: inserter })
|
||||
.pipe(bpack({ raw: true }))
|
||||
.pipe(process.stdout)
|
||||
;
|
||||
```
|
||||
|
||||
```
|
||||
$ node example/insert.js | node
|
||||
in main.js: {"__filename":"/main.js","__dirname":"/"}
|
||||
in foo/index.js: {"__filename":"/foo/index.js","__dirname":"/foo"}
|
||||
```
|
||||
|
||||
or use the command-line scripts:
|
||||
|
||||
```
|
||||
$ module-deps main.js | insert-module-globals | browser-pack | node
|
||||
in main.js: {"__filename":"/main.js","__dirname":"/"}
|
||||
in foo/index.js: {"__filename":"/foo/index.js","__dirname":"/foo"}
|
||||
```
|
||||
|
||||
or use insert-module-globals as a transform:
|
||||
|
||||
```
|
||||
$ module-deps main.js --transform insert-module-globals | browser-pack | node
|
||||
in main.js: {"__filename":"/main.js","__dirname":"/"}
|
||||
in foo/index.js: {"__filename":"/foo/index.js","__dirname":"/foo"}
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var insertGlobals = require('insert-module-globals')
|
||||
```
|
||||
|
||||
## var inserter = insertGlobals(file, opts)
|
||||
|
||||
Return a transform stream `inserter` for the filename `file` that will accept a
|
||||
javascript file as input and will output the file with a closure around the
|
||||
contents as necessary to define extra builtins.
|
||||
|
||||
When `opts.always` is true, wrap every file with all the global variables
|
||||
without parsing. This is handy because parsing the scope can take a long time,
|
||||
so you can prioritize fast builds over saving bytes in the final output. When
|
||||
`opts.always` is truthy but not true, avoid parsing but perform a quick test to
|
||||
determine if wrapping should be skipped.
|
||||
|
||||
Use `opts.vars` to override the default inserted variables, or set
|
||||
`opts.vars[name]` to `undefined` to not insert a variable which would otherwise
|
||||
be inserted.
|
||||
|
||||
`opts.vars` properties with a `.` in their name will be executed instead of the
|
||||
parent object if ONLY that property is used. For example, `"Buffer.isBuffer"`
|
||||
will mask `"Buffer"` only when there is a `Buffer.isBuffer()` call in a file and
|
||||
no other references to `Buffer`.
|
||||
|
||||
If `opts.debug` is true, an inline source map will be generated to compensate
|
||||
for the extra lines.
|
||||
|
||||
# events
|
||||
|
||||
## inserter.on('global', function (name) {})
|
||||
|
||||
When a global is detected, the inserter stream emits a `'global'` event.
|
||||
|
||||
# usage
|
||||
|
||||
```
|
||||
usage: insert-module-globals {basedir}
|
||||
```
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org), to get the library do:
|
||||
|
||||
```
|
||||
npm install insert-module-globals
|
||||
```
|
||||
|
||||
and to get the bin script do:
|
||||
|
||||
```
|
||||
npm install -g insert-module-globals
|
||||
```
|
||||
|
||||
# insert custom globals.
|
||||
|
||||
`insert-module-globals` can also insert arbitary globals into files.
|
||||
Pass in an object of functions as the `vars` option.
|
||||
|
||||
``` js
|
||||
var vars = {
|
||||
process: function (file, basedir) {
|
||||
return {
|
||||
id: "path/to/custom_process.js",
|
||||
source: customProcessContent
|
||||
}
|
||||
},
|
||||
Buffer: function (file, basedir) {
|
||||
return {
|
||||
id: 'path/to/custom_buffer.js',
|
||||
source: customProcessContent,
|
||||
//suffix is optional
|
||||
//it's used to extract the value from the module.
|
||||
//it becomes: require(...).Buffer in this case.
|
||||
suffix: '.Buffer'
|
||||
}
|
||||
},
|
||||
Math: function () {
|
||||
//if you return a string,
|
||||
//it's simply set as the value.
|
||||
return '{}'
|
||||
//^ any attempt to use Math[x] will throw!
|
||||
}
|
||||
}
|
||||
|
||||
function inserter (file) {
|
||||
return insert(file, { vars: vars });
|
||||
}
|
||||
mdeps(files, { transform: inserter })
|
||||
.pipe(bpack({ raw: true }))
|
||||
.pipe(process.stdout)
|
||||
```
|
||||
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
105
build/node_modules/insert-module-globals/test/always.js
generated
vendored
Normal file
105
build/node_modules/insert-module-globals/test/always.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
var test = require('tape')
|
||||
var mdeps = require('module-deps');
|
||||
var bpack = require('browser-pack');
|
||||
var insert = require('../');
|
||||
var concat = require('concat-stream');
|
||||
var vm = require('vm');
|
||||
|
||||
test('always true insert', function (t) {
|
||||
t.plan(10);
|
||||
var s = mdeps({
|
||||
modules: {
|
||||
buffer: require.resolve('buffer/')
|
||||
}
|
||||
});
|
||||
s.pipe(bpack({ raw: true })).pipe(concat(function (src) {
|
||||
var c = {
|
||||
t: t,
|
||||
process: 'sandbox process',
|
||||
Buffer: 'sandbox Buffer',
|
||||
__filename: 'sandbox __filename',
|
||||
__dirname: 'sandbox __dirname',
|
||||
custom: 'sandbox custom',
|
||||
self: { xyz: 555 }
|
||||
};
|
||||
vm.runInNewContext(src, c);
|
||||
}));
|
||||
s.write({ transform: inserter({ always: true }), global: true });
|
||||
s.end(__dirname + '/always/main.js');
|
||||
});
|
||||
|
||||
test('always true insert custom globals without defaults', function (t) {
|
||||
t.plan(7);
|
||||
var s = mdeps({
|
||||
modules: {
|
||||
buffer: require.resolve('buffer/')
|
||||
}
|
||||
});
|
||||
s.pipe(bpack({ raw: true })).pipe(concat(function (src) {
|
||||
var c = {
|
||||
t: t,
|
||||
process: 'sandbox process',
|
||||
Buffer: 'sandbox Buffer',
|
||||
__filename: 'sandbox __filename',
|
||||
__dirname: 'sandbox __dirname',
|
||||
custom: 'sandbox custom',
|
||||
self: { xyz: 555 }
|
||||
};
|
||||
vm.runInNewContext(src, c);
|
||||
}));
|
||||
s.write({
|
||||
transform: inserter({ always: true, vars: {
|
||||
global: {},
|
||||
process: undefined,
|
||||
Buffer: undefined,
|
||||
__filename: undefined,
|
||||
__dirname: undefined,
|
||||
custom: function() { return '"inserted custom"' }
|
||||
}}),
|
||||
global: true
|
||||
});
|
||||
s.end(__dirname + '/always/custom_globals_without_defaults.js');
|
||||
});
|
||||
|
||||
test('always truthy-but-not-true insert hidden from quick test is not really inserted; true is', function (t) {
|
||||
t.plan(2);
|
||||
var testit = function(always, expected) {
|
||||
var s = mdeps({
|
||||
modules: {
|
||||
buffer: require.resolve('buffer/')
|
||||
}
|
||||
});
|
||||
s.pipe(bpack({ raw: true })).pipe(concat(function (src) {
|
||||
var c = {
|
||||
t: t,
|
||||
process: 'sandbox process',
|
||||
Buffer: 'sandbox Buffer',
|
||||
__filename: 'sandbox __filename',
|
||||
__dirname: 'sandbox __dirname',
|
||||
custom: 'sandbox custom',
|
||||
expected: expected,
|
||||
self: { xyz: 555 }
|
||||
};
|
||||
vm.runInNewContext(src, c);
|
||||
}));
|
||||
s.write({
|
||||
transform: inserter({ always: always, vars: {
|
||||
custom: function() { return '"inserted custom"' }
|
||||
}}),
|
||||
global: true
|
||||
})
|
||||
s.end(__dirname + '/always/hidden_from_quick_test.js');
|
||||
};
|
||||
|
||||
var always = 'truthy', expected = 'sandbox custom';
|
||||
testit(always, expected);
|
||||
|
||||
always = true; expected = 'inserted custom';
|
||||
testit(always, expected);
|
||||
});
|
||||
|
||||
function inserter (opts) {
|
||||
return function (file) {
|
||||
return insert(file, opts);
|
||||
};
|
||||
}
|
||||
7
build/node_modules/insert-module-globals/test/always/custom_globals_without_defaults.js
generated
vendored
Normal file
7
build/node_modules/insert-module-globals/test/always/custom_globals_without_defaults.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
t.equal(eval('process'), 'sandbox process');
|
||||
t.equal(eval('typeof global'), 'undefined');
|
||||
t.equal(eval('self.xyz'), 555);
|
||||
t.equal(eval('Buffer'), 'sandbox Buffer');
|
||||
t.equal(eval('__filename'), 'sandbox __filename');
|
||||
t.equal(eval('__dirname'), 'sandbox __dirname');
|
||||
t.equal(eval('custom'), 'inserted custom');
|
||||
1
build/node_modules/insert-module-globals/test/always/hidden_from_quick_test.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/test/always/hidden_from_quick_test.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
t.equal(eval('cust' + 'om'), eval('expected'));
|
||||
10
build/node_modules/insert-module-globals/test/always/main.js
generated
vendored
Normal file
10
build/node_modules/insert-module-globals/test/always/main.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
t.equal(eval('typeof process'), 'object');
|
||||
t.equal(eval('typeof process.nextTick'), 'function');
|
||||
t.equal(eval('typeof global'), 'object');
|
||||
t.equal(eval('global.xyz'), 555);
|
||||
t.equal(eval('typeof Buffer'), 'function');
|
||||
t.equal(eval('typeof __filename'), 'string');
|
||||
t.notEqual(eval('__filename'), 'sandbox __filename');
|
||||
t.equal(eval('typeof __dirname'), 'string');
|
||||
t.notEqual(eval('__dirname'), 'sandbox __dirname');
|
||||
t.equal(eval('custom'), 'sandbox custom');
|
||||
63
build/node_modules/insert-module-globals/test/global.js
generated
vendored
Normal file
63
build/node_modules/insert-module-globals/test/global.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
var test = require('tape');
|
||||
var vm = require('vm');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
var insert = require('../');
|
||||
var bpack = require('browser-pack');
|
||||
var mdeps = require('module-deps');
|
||||
|
||||
test('insert globals', function (t) {
|
||||
var expected = [ 'global' ];
|
||||
t.plan(2 + expected.length);
|
||||
|
||||
var deps = mdeps()
|
||||
var pack = bpack({ raw: true });
|
||||
|
||||
deps.pipe(pack);
|
||||
|
||||
pack.pipe(concat(function (src) {
|
||||
var c = {
|
||||
t : t,
|
||||
a : 555,
|
||||
};
|
||||
c.self = c;
|
||||
vm.runInNewContext(src, c);
|
||||
}));
|
||||
|
||||
deps.write({
|
||||
transform: function (file) {
|
||||
var tr = inserter(file)
|
||||
tr.on('global', function (name) {
|
||||
t.equal(name, expected.shift());
|
||||
});
|
||||
return tr;
|
||||
},
|
||||
global: true
|
||||
});
|
||||
deps.end(__dirname + '/global/main.js');
|
||||
});
|
||||
|
||||
test('__filename and __dirname', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var file = __dirname + '/global/filename.js';
|
||||
var deps = mdeps()
|
||||
var pack = bpack({ raw: true });
|
||||
|
||||
deps.pipe(pack);
|
||||
|
||||
pack.pipe(concat(function (src) {
|
||||
var c = {};
|
||||
vm.runInNewContext('require=' + src, c);
|
||||
var x = c.require(file);
|
||||
t.equal(x.filename, '/filename.js');
|
||||
t.equal(x.dirname, '/');
|
||||
}));
|
||||
|
||||
deps.write({ transform: inserter, global: true });
|
||||
deps.end(file);
|
||||
});
|
||||
|
||||
function inserter (file) {
|
||||
return insert(file, { basedir: __dirname + '/global' });
|
||||
}
|
||||
2
build/node_modules/insert-module-globals/test/global/filename.js
generated
vendored
Normal file
2
build/node_modules/insert-module-globals/test/global/filename.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
exports.filename = __filename;
|
||||
exports.dirname = __dirname;
|
||||
2
build/node_modules/insert-module-globals/test/global/main.js
generated
vendored
Normal file
2
build/node_modules/insert-module-globals/test/global/main.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
t.equal(a, 555);
|
||||
t.equal(a, global.a);
|
||||
46
build/node_modules/insert-module-globals/test/insert.js
generated
vendored
Normal file
46
build/node_modules/insert-module-globals/test/insert.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
var test = require('tape');
|
||||
var mdeps = require('module-deps');
|
||||
var bpack = require('browser-pack');
|
||||
var insert = require('../');
|
||||
var concat = require('concat-stream');
|
||||
var vm = require('vm');
|
||||
|
||||
test('process.nextTick inserts', function (t) {
|
||||
t.plan(4);
|
||||
var s = mdeps()
|
||||
s.pipe(bpack({ raw: true })).pipe(concat(function (src) {
|
||||
var c = {
|
||||
t: t,
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout
|
||||
};
|
||||
vm.runInNewContext(src, c);
|
||||
}));
|
||||
s.write({ transform: inserter, global: true })
|
||||
s.end(__dirname + '/insert/main.js');
|
||||
});
|
||||
|
||||
test('buffer inserts', function (t) {
|
||||
t.plan(2);
|
||||
var s = mdeps({
|
||||
modules: { buffer: require.resolve('buffer/') }
|
||||
});
|
||||
s.pipe(bpack({ raw: true })).pipe(concat(function (src) {
|
||||
var c = {
|
||||
t: t,
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
Uint8Array: Uint8Array,
|
||||
DataView: DataView
|
||||
};
|
||||
vm.runInNewContext(src, c);
|
||||
}));
|
||||
s.write({ transform: inserter, global: true })
|
||||
s.end(__dirname + '/insert/buffer.js');
|
||||
});
|
||||
|
||||
function inserter (file) {
|
||||
return insert(file, {
|
||||
basedir: __dirname + '/insert'
|
||||
});
|
||||
}
|
||||
1
build/node_modules/insert-module-globals/test/insert/buffer.js
generated
vendored
Normal file
1
build/node_modules/insert-module-globals/test/insert/buffer.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
require('./foo/buf');
|
||||
4
build/node_modules/insert-module-globals/test/insert/foo/buf.js
generated
vendored
Normal file
4
build/node_modules/insert-module-globals/test/insert/foo/buf.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
process.nextTick(function () {
|
||||
t.equal(Buffer('abc').toString('base64'), 'YWJj');
|
||||
t.equal(Buffer([98,99,100]).toString(), 'bcd');
|
||||
});
|
||||
4
build/node_modules/insert-module-globals/test/insert/foo/index.js
generated
vendored
Normal file
4
build/node_modules/insert-module-globals/test/insert/foo/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
process.nextTick(function () {
|
||||
t.equal(__filename, '/foo/index.js');
|
||||
t.equal(__dirname, '/foo');
|
||||
});
|
||||
4
build/node_modules/insert-module-globals/test/insert/main.js
generated
vendored
Normal file
4
build/node_modules/insert-module-globals/test/insert/main.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
t.equal(__filename, '/main.js');
|
||||
t.equal(__dirname, '/');
|
||||
|
||||
require('./foo');
|
||||
27
build/node_modules/insert-module-globals/test/isbuffer.js
generated
vendored
Normal file
27
build/node_modules/insert-module-globals/test/isbuffer.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var test = require('tape');
|
||||
var mdeps = require('module-deps');
|
||||
var bpack = require('browser-pack');
|
||||
var insert = require('../');
|
||||
var concat = require('concat-stream');
|
||||
var vm = require('vm');
|
||||
|
||||
test('isbuffer', function (t) {
|
||||
t.plan(5);
|
||||
var deps = mdeps()
|
||||
var pack = bpack({ raw: true, hasExports: true });
|
||||
deps.pipe(pack).pipe(concat(function (src) {
|
||||
var c = { global: {} };
|
||||
vm.runInNewContext(src, c);
|
||||
t.equal(c.require('main')(Buffer('wow')), true, 'is a buffer');
|
||||
t.equal(c.require('main')('wow'), false, 'not a buffer (string)');
|
||||
t.equal(c.require('main')({}), false, 'not a buffer (object)');
|
||||
t.notOk(/require("buffer")/.test(src), 'buffer not required in source')
|
||||
t.notOk(/require\("\//.test(src), 'absolute path not required in source')
|
||||
}));
|
||||
deps.write({ transform: inserter, global: true });
|
||||
deps.end({ id: 'main', file: __dirname + '/isbuffer/main.js' });
|
||||
});
|
||||
|
||||
function inserter (file) {
|
||||
return insert(file, { basedir: __dirname + '/isbuffer' });
|
||||
}
|
||||
3
build/node_modules/insert-module-globals/test/isbuffer/main.js
generated
vendored
Normal file
3
build/node_modules/insert-module-globals/test/isbuffer/main.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function (buf) {
|
||||
return Buffer.isBuffer(buf);
|
||||
};
|
||||
27
build/node_modules/insert-module-globals/test/return.js
generated
vendored
Normal file
27
build/node_modules/insert-module-globals/test/return.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var test = require('tape');
|
||||
var mdeps = require('module-deps');
|
||||
var bpack = require('browser-pack');
|
||||
var insert = require('../');
|
||||
var concat = require('concat-stream');
|
||||
var vm = require('vm');
|
||||
|
||||
test('early return', function (t) {
|
||||
t.plan(4);
|
||||
var s = mdeps()
|
||||
s.pipe(bpack({ raw: true })).pipe(concat(function (src) {
|
||||
var c = {
|
||||
t: t,
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout
|
||||
};
|
||||
vm.runInNewContext(src, c);
|
||||
}));
|
||||
s.write({ transform: inserter, global: true });
|
||||
s.end(__dirname + '/return/main.js');
|
||||
});
|
||||
|
||||
function inserter (file) {
|
||||
return insert(file, {
|
||||
basedir: __dirname + '/return'
|
||||
});
|
||||
}
|
||||
4
build/node_modules/insert-module-globals/test/return/foo/index.js
generated
vendored
Normal file
4
build/node_modules/insert-module-globals/test/return/foo/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
process.nextTick(function () {
|
||||
t.equal(__filename, '/foo/index.js');
|
||||
t.equal(__dirname, '/foo');
|
||||
});
|
||||
6
build/node_modules/insert-module-globals/test/return/main.js
generated
vendored
Normal file
6
build/node_modules/insert-module-globals/test/return/main.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
t.equal(__filename, '/main.js');
|
||||
t.equal(__dirname, '/');
|
||||
|
||||
require('./foo');
|
||||
|
||||
return;
|
||||
40
build/node_modules/insert-module-globals/test/sourcemap.js
generated
vendored
Normal file
40
build/node_modules/insert-module-globals/test/sourcemap.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
var test = require('tape');
|
||||
var convert = require('convert-source-map');
|
||||
var insert = require('../');
|
||||
var mdeps = require('module-deps');
|
||||
var vm = require('vm');
|
||||
|
||||
test('sourcemap', function (t) {
|
||||
t.plan(6);
|
||||
|
||||
var file = __dirname + '/sourcemap/main.js';
|
||||
var deps = mdeps()
|
||||
|
||||
deps.on('data', function(row) {
|
||||
var src = row.source;
|
||||
|
||||
var sm = convert.fromSource(src).toObject();
|
||||
t.deepEqual(sm.sources, [ 'test/sourcemap/main_es6.js' ]);
|
||||
t.deepEqual(sm.sourcesContent, [ 'console.log(`${__dirname}`, `${__filename}`);\n' ]);
|
||||
t.deepEqual(sm.mappings, ';AAAA,OAAO,CAAC,GAAG,MAAI,SAAS,OAAO,UAAU,CAAG,CAAC');
|
||||
|
||||
t.equal(src.match(convert.commentRegex).length, 1);
|
||||
|
||||
var c = {
|
||||
console: {
|
||||
log: function(dirname, filename) {
|
||||
t.equal(dirname, '/');
|
||||
t.equal(filename, '/main.js');
|
||||
}
|
||||
},
|
||||
};
|
||||
vm.runInNewContext(src, c);
|
||||
});
|
||||
|
||||
deps.write({ transform: inserter, global: true });
|
||||
deps.end(file);
|
||||
});
|
||||
|
||||
function inserter (file) {
|
||||
return insert(file, { debug: true, basedir: __dirname + '/sourcemap' });
|
||||
}
|
||||
3
build/node_modules/insert-module-globals/test/sourcemap/main.js
generated
vendored
Normal file
3
build/node_modules/insert-module-globals/test/sourcemap/main.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
console.log("" + __dirname, "" + __filename);
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3Qvc291cmNlbWFwL21haW5fZXM2LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sQ0FBQyxHQUFHLE1BQUksU0FBUyxPQUFPLFVBQVUsQ0FBRyxDQUFDIiwiZmlsZSI6InVuZGVmaW5lZCIsInNvdXJjZXNDb250ZW50IjpbImNvbnNvbGUubG9nKGAke19fZGlybmFtZX1gLCBgJHtfX2ZpbGVuYW1lfWApO1xuIl19
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user