schnee effeckt und fehler Korektur
This commit is contained in:
75
node_modules/decompress-targz/index.js
generated
vendored
75
node_modules/decompress-targz/index.js
generated
vendored
@@ -1,63 +1,26 @@
|
||||
'use strict';
|
||||
const zlib = require('zlib');
|
||||
const decompressTar = require('decompress-tar');
|
||||
const fileType = require('file-type');
|
||||
const isStream = require('is-stream');
|
||||
|
||||
var File = require('vinyl');
|
||||
var fs = require('fs');
|
||||
var isGzip = require('is-gzip');
|
||||
var objectAssign = require('object-assign');
|
||||
var stripDirs = require('strip-dirs');
|
||||
var tar = require('tar-stream');
|
||||
var through = require('through2');
|
||||
var zlib = require('zlib');
|
||||
module.exports = () => input => {
|
||||
if (!Buffer.isBuffer(input) && !isStream(input)) {
|
||||
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
|
||||
}
|
||||
|
||||
module.exports = function (opts) {
|
||||
opts = opts || {};
|
||||
opts.strip = +opts.strip || 0;
|
||||
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'gz')) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
return through.obj(function (file, enc, cb) {
|
||||
var self = this;
|
||||
var extract = tar.extract();
|
||||
var unzip = zlib.Unzip();
|
||||
const unzip = zlib.createGunzip();
|
||||
const result = decompressTar()(unzip);
|
||||
|
||||
if (file.isNull()) {
|
||||
cb(null, file);
|
||||
return;
|
||||
}
|
||||
if (Buffer.isBuffer(input)) {
|
||||
unzip.end(input);
|
||||
} else {
|
||||
input.pipe(unzip);
|
||||
}
|
||||
|
||||
if (file.isStream()) {
|
||||
cb(new Error('Streaming is not supported'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.extract || !isGzip(file.contents)) {
|
||||
cb(null, file);
|
||||
return;
|
||||
}
|
||||
|
||||
extract.on('entry', function (header, stream, done) {
|
||||
var chunk = [];
|
||||
var len = 0;
|
||||
|
||||
stream.on('data', function (data) {
|
||||
chunk.push(data);
|
||||
len += data.length;
|
||||
});
|
||||
|
||||
stream.on('end', function () {
|
||||
if (header.type !== 'directory') {
|
||||
self.push(new File({
|
||||
contents: Buffer.concat(chunk, len),
|
||||
path: stripDirs(header.name, opts.strip),
|
||||
stat: objectAssign(new fs.Stats(), header)
|
||||
}));
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
extract.on('finish', cb);
|
||||
extract.on('error', cb);
|
||||
unzip.end(file.contents);
|
||||
unzip.pipe(extract);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
22
node_modules/decompress-targz/license
generated
vendored
22
node_modules/decompress-targz/license
generated
vendored
@@ -1,21 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
MIT License
|
||||
|
||||
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
|
||||
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva)
|
||||
|
||||
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:
|
||||
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 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.
|
||||
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.
|
||||
|
||||
21
node_modules/decompress-targz/node_modules/clone-stats/LICENSE.md
generated
vendored
21
node_modules/decompress-targz/node_modules/clone-stats/LICENSE.md
generated
vendored
@@ -1,21 +0,0 @@
|
||||
## The MIT License (MIT) ##
|
||||
|
||||
Copyright (c) 2014 Hugh Kennedy
|
||||
|
||||
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.
|
||||
17
node_modules/decompress-targz/node_modules/clone-stats/README.md
generated
vendored
17
node_modules/decompress-targz/node_modules/clone-stats/README.md
generated
vendored
@@ -1,17 +0,0 @@
|
||||
# clone-stats [](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/clone-stats&title=clone-stats&description=hughsk/clone-stats%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[](http://github.com/hughsk/stability-badges) #
|
||||
|
||||
Safely clone node's
|
||||
[`fs.Stats`](http://nodejs.org/api/fs.html#fs_class_fs_stats) instances without
|
||||
losing their class methods, i.e. `stat.isDirectory()` and co.
|
||||
|
||||
## Usage ##
|
||||
|
||||
[](https://nodei.co/npm/clone-stats)
|
||||
|
||||
### `copy = require('clone-stats')(stat)` ###
|
||||
|
||||
Returns a clone of the original `fs.Stats` instance (`stat`).
|
||||
|
||||
## License ##
|
||||
|
||||
MIT. See [LICENSE.md](http://github.com/hughsk/clone-stats/blob/master/LICENSE.md) for details.
|
||||
13
node_modules/decompress-targz/node_modules/clone-stats/index.js
generated
vendored
13
node_modules/decompress-targz/node_modules/clone-stats/index.js
generated
vendored
@@ -1,13 +0,0 @@
|
||||
var Stat = require('fs').Stats
|
||||
|
||||
module.exports = cloneStats
|
||||
|
||||
function cloneStats(stats) {
|
||||
var replacement = new Stat
|
||||
|
||||
Object.keys(stats).forEach(function(key) {
|
||||
replacement[key] = stats[key]
|
||||
})
|
||||
|
||||
return replacement
|
||||
}
|
||||
31
node_modules/decompress-targz/node_modules/clone-stats/package.json
generated
vendored
31
node_modules/decompress-targz/node_modules/clone-stats/package.json
generated
vendored
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "clone-stats",
|
||||
"description": "Safely clone node's fs.Stats instances without losing their class methods",
|
||||
"version": "0.0.1",
|
||||
"main": "index.js",
|
||||
"browser": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "~2.3.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test"
|
||||
},
|
||||
"author": "Hugh Kennedy <hughskennedy@gmail.com> (http://hughsk.io/)",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hughsk/clone-stats"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/hughsk/clone-stats/issues"
|
||||
},
|
||||
"homepage": "https://github.com/hughsk/clone-stats",
|
||||
"keywords": [
|
||||
"stats",
|
||||
"fs",
|
||||
"clone",
|
||||
"copy",
|
||||
"prototype"
|
||||
]
|
||||
}
|
||||
36
node_modules/decompress-targz/node_modules/clone-stats/test.js
generated
vendored
36
node_modules/decompress-targz/node_modules/clone-stats/test.js
generated
vendored
@@ -1,36 +0,0 @@
|
||||
var test = require('tape')
|
||||
var clone = require('./')
|
||||
var fs = require('fs')
|
||||
|
||||
test('file', function(t) {
|
||||
compare(t, fs.statSync(__filename))
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('directory', function(t) {
|
||||
compare(t, fs.statSync(__dirname))
|
||||
t.end()
|
||||
})
|
||||
|
||||
function compare(t, stat) {
|
||||
var copy = clone(stat)
|
||||
|
||||
t.deepEqual(stat, copy, 'clone has equal properties')
|
||||
t.ok(stat instanceof fs.Stats, 'original is an fs.Stat')
|
||||
t.ok(copy instanceof fs.Stats, 'copy is an fs.Stat')
|
||||
|
||||
;['isDirectory'
|
||||
, 'isFile'
|
||||
, 'isBlockDevice'
|
||||
, 'isCharacterDevice'
|
||||
, 'isSymbolicLink'
|
||||
, 'isFIFO'
|
||||
, 'isSocket'
|
||||
].forEach(function(method) {
|
||||
t.equal(
|
||||
stat[method].call(stat)
|
||||
, copy[method].call(copy)
|
||||
, 'equal value for stat.' + method + '()'
|
||||
)
|
||||
})
|
||||
}
|
||||
1
node_modules/decompress-targz/node_modules/clone/.npmignore
generated
vendored
1
node_modules/decompress-targz/node_modules/clone/.npmignore
generated
vendored
@@ -1 +0,0 @@
|
||||
node_modules/
|
||||
5
node_modules/decompress-targz/node_modules/clone/.travis.yml
generated
vendored
5
node_modules/decompress-targz/node_modules/clone/.travis.yml
generated
vendored
@@ -1,5 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
- 0.10
|
||||
18
node_modules/decompress-targz/node_modules/clone/LICENSE
generated
vendored
18
node_modules/decompress-targz/node_modules/clone/LICENSE
generated
vendored
@@ -1,18 +0,0 @@
|
||||
Copyright © 2011-2014 Paul Vorbach <paul@vorba.ch>
|
||||
|
||||
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, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
126
node_modules/decompress-targz/node_modules/clone/README.md
generated
vendored
126
node_modules/decompress-targz/node_modules/clone/README.md
generated
vendored
@@ -1,126 +0,0 @@
|
||||
# clone
|
||||
|
||||
[](http://travis-ci.org/pvorb/node-clone)
|
||||
|
||||
offers foolproof _deep cloning_ of variables in JavaScript.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
npm install clone
|
||||
|
||||
or
|
||||
|
||||
ender build clone
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
~~~ javascript
|
||||
var clone = require('clone');
|
||||
|
||||
var a, b;
|
||||
|
||||
a = { foo: { bar: 'baz' } }; // initial value of a
|
||||
|
||||
b = clone(a); // clone a -> b
|
||||
a.foo.bar = 'foo'; // change a
|
||||
|
||||
console.log(a); // show a
|
||||
console.log(b); // show b
|
||||
~~~
|
||||
|
||||
This will print:
|
||||
|
||||
~~~ javascript
|
||||
{ foo: { bar: 'foo' } }
|
||||
{ foo: { bar: 'baz' } }
|
||||
~~~
|
||||
|
||||
**clone** masters cloning simple objects (even with custom prototype), arrays,
|
||||
Date objects, and RegExp objects. Everything is cloned recursively, so that you
|
||||
can clone dates in arrays in objects, for example.
|
||||
|
||||
|
||||
## API
|
||||
|
||||
`clone(val, circular, depth)`
|
||||
|
||||
* `val` -- the value that you want to clone, any type allowed
|
||||
* `circular` -- boolean
|
||||
|
||||
Call `clone` with `circular` set to `false` if you are certain that `obj`
|
||||
contains no circular references. This will give better performance if needed.
|
||||
There is no error if `undefined` or `null` is passed as `obj`.
|
||||
* `depth` -- depth to which the object is to be cloned (optional,
|
||||
defaults to infinity)
|
||||
|
||||
`clone.clonePrototype(obj)`
|
||||
|
||||
* `obj` -- the object that you want to clone
|
||||
|
||||
Does a prototype clone as
|
||||
[described by Oran Looney](http://oranlooney.com/functional-javascript/).
|
||||
|
||||
|
||||
## Circular References
|
||||
|
||||
~~~ javascript
|
||||
var a, b;
|
||||
|
||||
a = { hello: 'world' };
|
||||
|
||||
a.myself = a;
|
||||
b = clone(a);
|
||||
|
||||
console.log(b);
|
||||
~~~
|
||||
|
||||
This will print:
|
||||
|
||||
~~~ javascript
|
||||
{ hello: "world", myself: [Circular] }
|
||||
~~~
|
||||
|
||||
So, `b.myself` points to `b`, not `a`. Neat!
|
||||
|
||||
|
||||
## Test
|
||||
|
||||
npm test
|
||||
|
||||
|
||||
## Caveat
|
||||
|
||||
Some special objects like a socket or `process.stdout`/`stderr` are known to not
|
||||
be cloneable. If you find other objects that cannot be cloned, please [open an
|
||||
issue](https://github.com/pvorb/node-clone/issues/new).
|
||||
|
||||
|
||||
## Bugs and Issues
|
||||
|
||||
If you encounter any bugs or issues, feel free to [open an issue at
|
||||
github](https://github.com/pvorb/node-clone/issues) or send me an email to
|
||||
<paul@vorba.ch>. I also always like to hear from you, if you’re using my code.
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2011-2014 [Paul Vorbach](http://paul.vorba.ch/) and
|
||||
[contributors](https://github.com/pvorb/node-clone/graphs/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, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
144
node_modules/decompress-targz/node_modules/clone/clone.js
generated
vendored
144
node_modules/decompress-targz/node_modules/clone/clone.js
generated
vendored
@@ -1,144 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
function objectToString(o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
}
|
||||
|
||||
// shim for Node's 'util' package
|
||||
// DO NOT REMOVE THIS! It is required for compatibility with EnderJS (http://enderjs.com/).
|
||||
var util = {
|
||||
isArray: function (ar) {
|
||||
return Array.isArray(ar) || (typeof ar === 'object' && objectToString(ar) === '[object Array]');
|
||||
},
|
||||
isDate: function (d) {
|
||||
return typeof d === 'object' && objectToString(d) === '[object Date]';
|
||||
},
|
||||
isRegExp: function (re) {
|
||||
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
|
||||
},
|
||||
getRegExpFlags: function (re) {
|
||||
var flags = '';
|
||||
re.global && (flags += 'g');
|
||||
re.ignoreCase && (flags += 'i');
|
||||
re.multiline && (flags += 'm');
|
||||
return flags;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (typeof module === 'object')
|
||||
module.exports = clone;
|
||||
|
||||
/**
|
||||
* Clones (copies) an Object using deep copying.
|
||||
*
|
||||
* This function supports circular references by default, but if you are certain
|
||||
* there are no circular references in your object, you can save some CPU time
|
||||
* by calling clone(obj, false).
|
||||
*
|
||||
* Caution: if `circular` is false and `parent` contains circular references,
|
||||
* your program may enter an infinite loop and crash.
|
||||
*
|
||||
* @param `parent` - the object to be cloned
|
||||
* @param `circular` - set to true if the object to be cloned may contain
|
||||
* circular references. (optional - true by default)
|
||||
* @param `depth` - set to a number if the object is only to be cloned to
|
||||
* a particular depth. (optional - defaults to Infinity)
|
||||
* @param `prototype` - sets the prototype to be used when cloning an object.
|
||||
* (optional - defaults to parent prototype).
|
||||
*/
|
||||
|
||||
function clone(parent, circular, depth, prototype) {
|
||||
// maintain two arrays for circular references, where corresponding parents
|
||||
// and children have the same index
|
||||
var allParents = [];
|
||||
var allChildren = [];
|
||||
|
||||
var useBuffer = typeof Buffer != 'undefined';
|
||||
|
||||
if (typeof circular == 'undefined')
|
||||
circular = true;
|
||||
|
||||
if (typeof depth == 'undefined')
|
||||
depth = Infinity;
|
||||
|
||||
// recurse this function so we don't reset allParents and allChildren
|
||||
function _clone(parent, depth) {
|
||||
// cloning null always returns null
|
||||
if (parent === null)
|
||||
return null;
|
||||
|
||||
if (depth == 0)
|
||||
return parent;
|
||||
|
||||
var child;
|
||||
var proto;
|
||||
if (typeof parent != 'object') {
|
||||
return parent;
|
||||
}
|
||||
|
||||
if (util.isArray(parent)) {
|
||||
child = [];
|
||||
} else if (util.isRegExp(parent)) {
|
||||
child = new RegExp(parent.source, util.getRegExpFlags(parent));
|
||||
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
||||
} else if (util.isDate(parent)) {
|
||||
child = new Date(parent.getTime());
|
||||
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
||||
child = new Buffer(parent.length);
|
||||
parent.copy(child);
|
||||
return child;
|
||||
} else {
|
||||
if (typeof prototype == 'undefined') {
|
||||
proto = Object.getPrototypeOf(parent);
|
||||
child = Object.create(proto);
|
||||
}
|
||||
else {
|
||||
child = Object.create(prototype);
|
||||
proto = prototype;
|
||||
}
|
||||
}
|
||||
|
||||
if (circular) {
|
||||
var index = allParents.indexOf(parent);
|
||||
|
||||
if (index != -1) {
|
||||
return allChildren[index];
|
||||
}
|
||||
allParents.push(parent);
|
||||
allChildren.push(child);
|
||||
}
|
||||
|
||||
for (var i in parent) {
|
||||
var attrs;
|
||||
if (proto) {
|
||||
attrs = Object.getOwnPropertyDescriptor(proto, i);
|
||||
}
|
||||
|
||||
if (attrs && attrs.set == null) {
|
||||
continue;
|
||||
}
|
||||
child[i] = _clone(parent[i], depth - 1);
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
return _clone(parent, depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple flat clone using prototype, accepts only objects, usefull for property
|
||||
* override on FLAT configuration object (no nested props).
|
||||
*
|
||||
* USE WITH CAUTION! This may not behave as you wish if you do not know how this
|
||||
* works.
|
||||
*/
|
||||
clone.clonePrototype = function(parent) {
|
||||
if (parent === null)
|
||||
return null;
|
||||
|
||||
var c = function () {};
|
||||
c.prototype = parent;
|
||||
return new c();
|
||||
};
|
||||
50
node_modules/decompress-targz/node_modules/clone/package.json
generated
vendored
50
node_modules/decompress-targz/node_modules/clone/package.json
generated
vendored
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "clone",
|
||||
"description": "deep cloning of objects and arrays",
|
||||
"tags": [
|
||||
"clone",
|
||||
"object",
|
||||
"array",
|
||||
"function",
|
||||
"date"
|
||||
],
|
||||
"version": "0.2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/pvorb/node-clone.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pvorb/node-clone/issues"
|
||||
},
|
||||
"main": "clone.js",
|
||||
"author": "Paul Vorbach <paul@vorba.ch> (http://paul.vorba.ch/)",
|
||||
"contributors": [
|
||||
"Blake Miner <miner.blake@gmail.com> (http://www.blakeminer.com/)",
|
||||
"Tian You <axqd001@gmail.com> (http://blog.axqd.net/)",
|
||||
"George Stagas <gstagas@gmail.com> (http://stagas.com/)",
|
||||
"Tobiasz Cudnik <tobiasz.cudnik@gmail.com> (https://github.com/TobiaszCudnik)",
|
||||
"Pavel Lang <langpavel@phpskelet.org> (https://github.com/langpavel)",
|
||||
"Dan MacTough (http://yabfog.com/)",
|
||||
"w1nk (https://github.com/w1nk)",
|
||||
"Hugh Kennedy (http://twitter.com/hughskennedy)",
|
||||
"Dustin Diaz (http://dustindiaz.com)",
|
||||
"Ilya Shaisultanov (https://github.com/diversario)",
|
||||
"Nathan MacInnes <nathan@macinn.es> (http://macinn.es/)",
|
||||
"Benjamin E. Coe <ben@npmjs.com> (https://twitter.com/benjamincoe)",
|
||||
"Nathan Zadoks (https://github.com/nathan7)",
|
||||
"Róbert Oroszi <robert+gh@oroszi.net> (https://github.com/oroce)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"underscore": "*",
|
||||
"nodeunit": "*"
|
||||
},
|
||||
"optionalDependencies": {},
|
||||
"scripts": {
|
||||
"test": "nodeunit test.js"
|
||||
}
|
||||
}
|
||||
289
node_modules/decompress-targz/node_modules/clone/test.js
generated
vendored
289
node_modules/decompress-targz/node_modules/clone/test.js
generated
vendored
@@ -1,289 +0,0 @@
|
||||
if(module.parent === null) {
|
||||
console.log('Run this test file with nodeunit:');
|
||||
console.log('$ nodeunit test.js');
|
||||
}
|
||||
|
||||
|
||||
var clone = require('./');
|
||||
var util = require('util');
|
||||
var _ = require('underscore');
|
||||
|
||||
|
||||
|
||||
exports["clone string"] = function(test) {
|
||||
test.expect(2); // how many tests?
|
||||
|
||||
var a = "foo";
|
||||
test.strictEqual(clone(a), a);
|
||||
a = "";
|
||||
test.strictEqual(clone(a), a);
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports["clone number"] = function(test) {
|
||||
test.expect(5); // how many tests?
|
||||
|
||||
var a = 0;
|
||||
test.strictEqual(clone(a), a);
|
||||
a = 1;
|
||||
test.strictEqual(clone(a), a);
|
||||
a = -1000;
|
||||
test.strictEqual(clone(a), a);
|
||||
a = 3.1415927;
|
||||
test.strictEqual(clone(a), a);
|
||||
a = -3.1415927;
|
||||
test.strictEqual(clone(a), a);
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports["clone date"] = function(test) {
|
||||
test.expect(3); // how many tests?
|
||||
|
||||
var a = new Date;
|
||||
var c = clone(a);
|
||||
test.ok(a instanceof Date);
|
||||
test.ok(c instanceof Date);
|
||||
test.equal(c.getTime(), a.getTime());
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports["clone object"] = function(test) {
|
||||
test.expect(2); // how many tests?
|
||||
|
||||
var a = { foo: { bar: "baz" } };
|
||||
var b = clone(a);
|
||||
|
||||
test.ok(_(a).isEqual(b), "underscore equal");
|
||||
test.deepEqual(b, a);
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports["clone array"] = function(test) {
|
||||
test.expect(2); // how many tests?
|
||||
|
||||
var a = [
|
||||
{ foo: "bar" },
|
||||
"baz"
|
||||
];
|
||||
var b = clone(a);
|
||||
|
||||
test.ok(_(a).isEqual(b), "underscore equal");
|
||||
test.deepEqual(b, a);
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
exports["clone buffer"] = function(test) {
|
||||
test.expect(1);
|
||||
|
||||
var a = new Buffer("this is a test buffer");
|
||||
var b = clone(a);
|
||||
|
||||
// no underscore equal since it has no concept of Buffers
|
||||
test.deepEqual(b, a);
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports["clone regexp"] = function(test) {
|
||||
test.expect(5);
|
||||
|
||||
var a = /abc123/gi;
|
||||
var b = clone(a);
|
||||
|
||||
test.deepEqual(b, a);
|
||||
|
||||
var c = /a/g;
|
||||
test.ok(c.lastIndex === 0);
|
||||
|
||||
c.exec('123a456a');
|
||||
test.ok(c.lastIndex === 4);
|
||||
|
||||
var d = clone(c);
|
||||
test.ok(d.global);
|
||||
test.ok(d.lastIndex === 4);
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
exports["clone object containing array"] = function(test) {
|
||||
test.expect(2); // how many tests?
|
||||
|
||||
var a = {
|
||||
arr1: [ { a: '1234', b: '2345' } ],
|
||||
arr2: [ { c: '345', d: '456' } ]
|
||||
};
|
||||
var b = clone(a);
|
||||
|
||||
test.ok(_(a).isEqual(b), "underscore equal");
|
||||
test.deepEqual(b, a);
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports["clone object with circular reference"] = function(test) {
|
||||
test.expect(8); // how many tests?
|
||||
|
||||
var _ = test.ok;
|
||||
var c = [1, "foo", {'hello': 'bar'}, function() {}, false, [2]];
|
||||
var b = [c, 2, 3, 4];
|
||||
var a = {'b': b, 'c': c};
|
||||
a.loop = a;
|
||||
a.loop2 = a;
|
||||
c.loop = c;
|
||||
c.aloop = a;
|
||||
var aCopy = clone(a);
|
||||
_(a != aCopy);
|
||||
_(a.c != aCopy.c);
|
||||
_(aCopy.c == aCopy.b[0]);
|
||||
_(aCopy.c.loop.loop.aloop == aCopy);
|
||||
_(aCopy.c[0] == a.c[0]);
|
||||
|
||||
//console.log(util.inspect(aCopy, true, null) );
|
||||
//console.log("------------------------------------------------------------");
|
||||
//console.log(util.inspect(a, true, null) );
|
||||
_(eq(a, aCopy));
|
||||
aCopy.c[0] = 2;
|
||||
_(!eq(a, aCopy));
|
||||
aCopy.c = "2";
|
||||
_(!eq(a, aCopy));
|
||||
//console.log("------------------------------------------------------------");
|
||||
//console.log(util.inspect(aCopy, true, null) );
|
||||
|
||||
function eq(x, y) {
|
||||
return util.inspect(x, true, null) === util.inspect(y, true, null);
|
||||
}
|
||||
|
||||
test.done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
exports['clonePrototype'] = function(test) {
|
||||
test.expect(3); // how many tests?
|
||||
|
||||
var a = {
|
||||
a: "aaa",
|
||||
x: 123,
|
||||
y: 45.65
|
||||
};
|
||||
var b = clone.clonePrototype(a);
|
||||
|
||||
test.strictEqual(b.a, a.a);
|
||||
test.strictEqual(b.x, a.x);
|
||||
test.strictEqual(b.y, a.y);
|
||||
|
||||
test.done();
|
||||
}
|
||||
|
||||
exports['cloneWithinNewVMContext'] = function(test) {
|
||||
test.expect(3);
|
||||
var vm = require('vm');
|
||||
var ctx = vm.createContext({ clone: clone });
|
||||
var script = "clone( {array: [1, 2, 3], date: new Date(), regex: /^foo$/ig} );";
|
||||
var results = vm.runInContext(script, ctx);
|
||||
test.ok(results.array instanceof Array);
|
||||
test.ok(results.date instanceof Date);
|
||||
test.ok(results.regex instanceof RegExp);
|
||||
test.done();
|
||||
}
|
||||
|
||||
exports['cloneObjectWithNoConstructor'] = function(test) {
|
||||
test.expect(3);
|
||||
var n = null;
|
||||
var a = { foo: 'bar' };
|
||||
a.__proto__ = n;
|
||||
test.ok(typeof a === 'object');
|
||||
test.ok(typeof a !== null);
|
||||
var b = clone(a);
|
||||
test.ok(a.foo, b.foo);
|
||||
test.done();
|
||||
}
|
||||
|
||||
exports['clone object with depth argument'] = function (test) {
|
||||
test.expect(6);
|
||||
var a = {
|
||||
foo: {
|
||||
bar : {
|
||||
baz : 'qux'
|
||||
}
|
||||
}
|
||||
};
|
||||
var b = clone(a, false, 1);
|
||||
test.deepEqual(b, a);
|
||||
test.notEqual(b, a);
|
||||
test.strictEqual(b.foo, a.foo);
|
||||
|
||||
b = clone(a, true, 2);
|
||||
test.deepEqual(b, a);
|
||||
test.notEqual(b.foo, a.foo);
|
||||
test.strictEqual(b.foo.bar, a.foo.bar);
|
||||
test.done();
|
||||
}
|
||||
|
||||
exports['maintain prototype chain in clones'] = function (test) {
|
||||
test.expect(1);
|
||||
function Constructor() {}
|
||||
var a = new Constructor();
|
||||
var b = clone(a);
|
||||
test.strictEqual(Object.getPrototypeOf(a), Object.getPrototypeOf(b));
|
||||
test.done();
|
||||
}
|
||||
|
||||
exports['parent prototype is overriden with prototype provided'] = function (test) {
|
||||
test.expect(1);
|
||||
function Constructor() {}
|
||||
var a = new Constructor();
|
||||
var b = clone(a, true, Infinity, null);
|
||||
test.strictEqual(b.__defineSetter__, undefined);
|
||||
test.done();
|
||||
}
|
||||
|
||||
exports['clone object with null children'] = function(test) {
|
||||
test.expect(1);
|
||||
var a = {
|
||||
foo: {
|
||||
bar: null,
|
||||
baz: {
|
||||
qux: false
|
||||
}
|
||||
}
|
||||
};
|
||||
var b = clone(a);
|
||||
test.deepEqual(b, a);
|
||||
test.done();
|
||||
}
|
||||
|
||||
exports['clone instance with getter'] = function(test) {
|
||||
test.expect(1);
|
||||
function Ctor() {};
|
||||
Object.defineProperty(Ctor.prototype, 'prop', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return 'value';
|
||||
}
|
||||
});
|
||||
|
||||
var a = new Ctor();
|
||||
var b = clone(a);
|
||||
|
||||
test.strictEqual(b.prop, 'value');
|
||||
test.done();
|
||||
};
|
||||
559
node_modules/decompress-targz/node_modules/file-type/index.js
generated
vendored
Normal file
559
node_modules/decompress-targz/node_modules/file-type/index.js
generated
vendored
Normal file
@@ -0,0 +1,559 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = input => {
|
||||
const buf = new Uint8Array(input);
|
||||
|
||||
if (!(buf && buf.length > 1)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const check = (header, opts) => {
|
||||
opts = Object.assign({
|
||||
offset: 0
|
||||
}, opts);
|
||||
|
||||
for (let i = 0; i < header.length; i++) {
|
||||
if (header[i] !== buf[i + opts.offset]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (check([0xFF, 0xD8, 0xFF])) {
|
||||
return {
|
||||
ext: 'jpg',
|
||||
mime: 'image/jpeg'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
||||
return {
|
||||
ext: 'png',
|
||||
mime: 'image/png'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x47, 0x49, 0x46])) {
|
||||
return {
|
||||
ext: 'gif',
|
||||
mime: 'image/gif'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) {
|
||||
return {
|
||||
ext: 'webp',
|
||||
mime: 'image/webp'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x46, 0x4C, 0x49, 0x46])) {
|
||||
return {
|
||||
ext: 'flif',
|
||||
mime: 'image/flif'
|
||||
};
|
||||
}
|
||||
|
||||
// Needs to be before `tif` check
|
||||
if (
|
||||
(check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) &&
|
||||
check([0x43, 0x52], {offset: 8})
|
||||
) {
|
||||
return {
|
||||
ext: 'cr2',
|
||||
mime: 'image/x-canon-cr2'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x49, 0x49, 0x2A, 0x0]) ||
|
||||
check([0x4D, 0x4D, 0x0, 0x2A])
|
||||
) {
|
||||
return {
|
||||
ext: 'tif',
|
||||
mime: 'image/tiff'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x42, 0x4D])) {
|
||||
return {
|
||||
ext: 'bmp',
|
||||
mime: 'image/bmp'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x49, 0x49, 0xBC])) {
|
||||
return {
|
||||
ext: 'jxr',
|
||||
mime: 'image/vnd.ms-photo'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x38, 0x42, 0x50, 0x53])) {
|
||||
return {
|
||||
ext: 'psd',
|
||||
mime: 'image/vnd.adobe.photoshop'
|
||||
};
|
||||
}
|
||||
|
||||
// Needs to be before the `zip` check
|
||||
if (
|
||||
check([0x50, 0x4B, 0x3, 0x4]) &&
|
||||
check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30})
|
||||
) {
|
||||
return {
|
||||
ext: 'epub',
|
||||
mime: 'application/epub+zip'
|
||||
};
|
||||
}
|
||||
|
||||
// Needs to be before `zip` check
|
||||
// Assumes signed `.xpi` from addons.mozilla.org
|
||||
if (
|
||||
check([0x50, 0x4B, 0x3, 0x4]) &&
|
||||
check([0x4D, 0x45, 0x54, 0x41, 0x2D, 0x49, 0x4E, 0x46, 0x2F, 0x6D, 0x6F, 0x7A, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x72, 0x73, 0x61], {offset: 30})
|
||||
) {
|
||||
return {
|
||||
ext: 'xpi',
|
||||
mime: 'application/x-xpinstall'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x50, 0x4B]) &&
|
||||
(buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) &&
|
||||
(buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)
|
||||
) {
|
||||
return {
|
||||
ext: 'zip',
|
||||
mime: 'application/zip'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x75, 0x73, 0x74, 0x61, 0x72], {offset: 257})) {
|
||||
return {
|
||||
ext: 'tar',
|
||||
mime: 'application/x-tar'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) &&
|
||||
(buf[6] === 0x0 || buf[6] === 0x1)
|
||||
) {
|
||||
return {
|
||||
ext: 'rar',
|
||||
mime: 'application/x-rar-compressed'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x1F, 0x8B, 0x8])) {
|
||||
return {
|
||||
ext: 'gz',
|
||||
mime: 'application/gzip'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x42, 0x5A, 0x68])) {
|
||||
return {
|
||||
ext: 'bz2',
|
||||
mime: 'application/x-bzip2'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
|
||||
return {
|
||||
ext: '7z',
|
||||
mime: 'application/x-7z-compressed'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x78, 0x01])) {
|
||||
return {
|
||||
ext: 'dmg',
|
||||
mime: 'application/x-apple-diskimage'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(
|
||||
check([0x0, 0x0, 0x0]) &&
|
||||
(buf[3] === 0x18 || buf[3] === 0x20) &&
|
||||
check([0x66, 0x74, 0x79, 0x70], {offset: 4})
|
||||
) ||
|
||||
check([0x33, 0x67, 0x70, 0x35]) ||
|
||||
(
|
||||
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32]) &&
|
||||
check([0x6D, 0x70, 0x34, 0x31, 0x6D, 0x70, 0x34, 0x32, 0x69, 0x73, 0x6F, 0x6D], {offset: 16})
|
||||
) ||
|
||||
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6F, 0x6D]) ||
|
||||
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32, 0x0, 0x0, 0x0, 0x0])
|
||||
) {
|
||||
return {
|
||||
ext: 'mp4',
|
||||
mime: 'video/mp4'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56])) {
|
||||
return {
|
||||
ext: 'm4v',
|
||||
mime: 'video/x-m4v'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x4D, 0x54, 0x68, 0x64])) {
|
||||
return {
|
||||
ext: 'mid',
|
||||
mime: 'audio/midi'
|
||||
};
|
||||
}
|
||||
|
||||
// https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska
|
||||
if (check([0x1A, 0x45, 0xDF, 0xA3])) {
|
||||
const sliced = buf.subarray(4, 4 + 4096);
|
||||
const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82);
|
||||
|
||||
if (idPos >= 0) {
|
||||
const docTypePos = idPos + 3;
|
||||
const findDocType = type => Array.from(type).every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0));
|
||||
|
||||
if (findDocType('matroska')) {
|
||||
return {
|
||||
ext: 'mkv',
|
||||
mime: 'video/x-matroska'
|
||||
};
|
||||
}
|
||||
|
||||
if (findDocType('webm')) {
|
||||
return {
|
||||
ext: 'webm',
|
||||
mime: 'video/webm'
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (check([0x0, 0x0, 0x0, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]) ||
|
||||
check([0x66, 0x72, 0x65, 0x65], {offset: 4}) ||
|
||||
check([0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20], {offset: 4}) ||
|
||||
check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // MJPEG
|
||||
check([0x77, 0x69, 0x64, 0x65], {offset: 4})) {
|
||||
return {
|
||||
ext: 'mov',
|
||||
mime: 'video/quicktime'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x52, 0x49, 0x46, 0x46]) &&
|
||||
check([0x41, 0x56, 0x49], {offset: 8})
|
||||
) {
|
||||
return {
|
||||
ext: 'avi',
|
||||
mime: 'video/x-msvideo'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {
|
||||
return {
|
||||
ext: 'wmv',
|
||||
mime: 'video/x-ms-wmv'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x0, 0x0, 0x1, 0xBA])) {
|
||||
return {
|
||||
ext: 'mpg',
|
||||
mime: 'video/mpeg'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x49, 0x44, 0x33]) ||
|
||||
check([0xFF, 0xFB])
|
||||
) {
|
||||
return {
|
||||
ext: 'mp3',
|
||||
mime: 'audio/mpeg'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41], {offset: 4}) ||
|
||||
check([0x4D, 0x34, 0x41, 0x20])
|
||||
) {
|
||||
return {
|
||||
ext: 'm4a',
|
||||
mime: 'audio/m4a'
|
||||
};
|
||||
}
|
||||
|
||||
// Needs to be before `ogg` check
|
||||
if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) {
|
||||
return {
|
||||
ext: 'opus',
|
||||
mime: 'audio/opus'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x4F, 0x67, 0x67, 0x53])) {
|
||||
return {
|
||||
ext: 'ogg',
|
||||
mime: 'audio/ogg'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x66, 0x4C, 0x61, 0x43])) {
|
||||
return {
|
||||
ext: 'flac',
|
||||
mime: 'audio/x-flac'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x52, 0x49, 0x46, 0x46]) &&
|
||||
check([0x57, 0x41, 0x56, 0x45], {offset: 8})
|
||||
) {
|
||||
return {
|
||||
ext: 'wav',
|
||||
mime: 'audio/x-wav'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) {
|
||||
return {
|
||||
ext: 'amr',
|
||||
mime: 'audio/amr'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x25, 0x50, 0x44, 0x46])) {
|
||||
return {
|
||||
ext: 'pdf',
|
||||
mime: 'application/pdf'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x4D, 0x5A])) {
|
||||
return {
|
||||
ext: 'exe',
|
||||
mime: 'application/x-msdownload'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(buf[0] === 0x43 || buf[0] === 0x46) &&
|
||||
check([0x57, 0x53], {offset: 1})
|
||||
) {
|
||||
return {
|
||||
ext: 'swf',
|
||||
mime: 'application/x-shockwave-flash'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) {
|
||||
return {
|
||||
ext: 'rtf',
|
||||
mime: 'application/rtf'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x00, 0x61, 0x73, 0x6D])) {
|
||||
return {
|
||||
ext: 'wasm',
|
||||
mime: 'application/wasm'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x77, 0x4F, 0x46, 0x46]) &&
|
||||
(
|
||||
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
||||
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
||||
)
|
||||
) {
|
||||
return {
|
||||
ext: 'woff',
|
||||
mime: 'font/woff'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x77, 0x4F, 0x46, 0x32]) &&
|
||||
(
|
||||
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
||||
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
||||
)
|
||||
) {
|
||||
return {
|
||||
ext: 'woff2',
|
||||
mime: 'font/woff2'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x4C, 0x50], {offset: 34}) &&
|
||||
(
|
||||
check([0x00, 0x00, 0x01], {offset: 8}) ||
|
||||
check([0x01, 0x00, 0x02], {offset: 8}) ||
|
||||
check([0x02, 0x00, 0x02], {offset: 8})
|
||||
)
|
||||
) {
|
||||
return {
|
||||
ext: 'eot',
|
||||
mime: 'application/octet-stream'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x00, 0x01, 0x00, 0x00, 0x00])) {
|
||||
return {
|
||||
ext: 'ttf',
|
||||
mime: 'font/ttf'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
|
||||
return {
|
||||
ext: 'otf',
|
||||
mime: 'font/otf'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x00, 0x00, 0x01, 0x00])) {
|
||||
return {
|
||||
ext: 'ico',
|
||||
mime: 'image/x-icon'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x46, 0x4C, 0x56, 0x01])) {
|
||||
return {
|
||||
ext: 'flv',
|
||||
mime: 'video/x-flv'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x25, 0x21])) {
|
||||
return {
|
||||
ext: 'ps',
|
||||
mime: 'application/postscript'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
|
||||
return {
|
||||
ext: 'xz',
|
||||
mime: 'application/x-xz'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x53, 0x51, 0x4C, 0x69])) {
|
||||
return {
|
||||
ext: 'sqlite',
|
||||
mime: 'application/x-sqlite3'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x4E, 0x45, 0x53, 0x1A])) {
|
||||
return {
|
||||
ext: 'nes',
|
||||
mime: 'application/x-nintendo-nes-rom'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x43, 0x72, 0x32, 0x34])) {
|
||||
return {
|
||||
ext: 'crx',
|
||||
mime: 'application/x-google-chrome-extension'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x4D, 0x53, 0x43, 0x46]) ||
|
||||
check([0x49, 0x53, 0x63, 0x28])
|
||||
) {
|
||||
return {
|
||||
ext: 'cab',
|
||||
mime: 'application/vnd.ms-cab-compressed'
|
||||
};
|
||||
}
|
||||
|
||||
// Needs to be before `ar` check
|
||||
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) {
|
||||
return {
|
||||
ext: 'deb',
|
||||
mime: 'application/x-deb'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) {
|
||||
return {
|
||||
ext: 'ar',
|
||||
mime: 'application/x-unix-archive'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0xED, 0xAB, 0xEE, 0xDB])) {
|
||||
return {
|
||||
ext: 'rpm',
|
||||
mime: 'application/x-rpm'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
check([0x1F, 0xA0]) ||
|
||||
check([0x1F, 0x9D])
|
||||
) {
|
||||
return {
|
||||
ext: 'Z',
|
||||
mime: 'application/x-compress'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x4C, 0x5A, 0x49, 0x50])) {
|
||||
return {
|
||||
ext: 'lz',
|
||||
mime: 'application/x-lzip'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
|
||||
return {
|
||||
ext: 'msi',
|
||||
mime: 'application/x-msi'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {
|
||||
return {
|
||||
ext: 'mxf',
|
||||
mime: 'application/mxf'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x47], {offset: 4}) && (check([0x47], {offset: 192}) || check([0x47], {offset: 196}))) {
|
||||
return {
|
||||
ext: 'mts',
|
||||
mime: 'video/mp2t'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) {
|
||||
return {
|
||||
ext: 'blend',
|
||||
mime: 'application/x-blender'
|
||||
};
|
||||
}
|
||||
|
||||
if (check([0x42, 0x50, 0x47, 0xFB])) {
|
||||
return {
|
||||
ext: 'bpg',
|
||||
mime: 'image/bpg'
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
109
node_modules/decompress-targz/node_modules/file-type/package.json
generated
vendored
Normal file
109
node_modules/decompress-targz/node_modules/file-type/package.json
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"name": "file-type",
|
||||
"version": "5.2.0",
|
||||
"description": "Detect the file type of a Buffer/Uint8Array",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/file-type",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"mime",
|
||||
"file",
|
||||
"type",
|
||||
"archive",
|
||||
"image",
|
||||
"img",
|
||||
"pic",
|
||||
"picture",
|
||||
"flash",
|
||||
"photo",
|
||||
"video",
|
||||
"type",
|
||||
"detect",
|
||||
"check",
|
||||
"is",
|
||||
"exif",
|
||||
"exe",
|
||||
"binary",
|
||||
"buffer",
|
||||
"uint8array",
|
||||
"jpg",
|
||||
"png",
|
||||
"gif",
|
||||
"webp",
|
||||
"flif",
|
||||
"cr2",
|
||||
"tif",
|
||||
"bmp",
|
||||
"jxr",
|
||||
"psd",
|
||||
"zip",
|
||||
"tar",
|
||||
"rar",
|
||||
"gz",
|
||||
"bz2",
|
||||
"7z",
|
||||
"dmg",
|
||||
"mp4",
|
||||
"m4v",
|
||||
"mid",
|
||||
"mkv",
|
||||
"webm",
|
||||
"mov",
|
||||
"avi",
|
||||
"mpg",
|
||||
"mp3",
|
||||
"m4a",
|
||||
"ogg",
|
||||
"opus",
|
||||
"flac",
|
||||
"wav",
|
||||
"amr",
|
||||
"pdf",
|
||||
"epub",
|
||||
"exe",
|
||||
"swf",
|
||||
"rtf",
|
||||
"woff",
|
||||
"woff2",
|
||||
"eot",
|
||||
"ttf",
|
||||
"otf",
|
||||
"ico",
|
||||
"flv",
|
||||
"ps",
|
||||
"xz",
|
||||
"sqlite",
|
||||
"xpi",
|
||||
"cab",
|
||||
"deb",
|
||||
"ar",
|
||||
"rpm",
|
||||
"Z",
|
||||
"lz",
|
||||
"msi",
|
||||
"mxf",
|
||||
"mts",
|
||||
"wasm",
|
||||
"webassembly",
|
||||
"blend",
|
||||
"bpg"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"read-chunk": "^2.0.0",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
156
node_modules/decompress-targz/node_modules/file-type/readme.md
generated
vendored
Normal file
156
node_modules/decompress-targz/node_modules/file-type/readme.md
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
# file-type [](https://travis-ci.org/sindresorhus/file-type)
|
||||
|
||||
> Detect the file type of a Buffer/Uint8Array
|
||||
|
||||
The file type is detected by checking the [magic number](http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save file-type
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
##### Node.js
|
||||
|
||||
```js
|
||||
const readChunk = require('read-chunk');
|
||||
const fileType = require('file-type');
|
||||
const buffer = readChunk.sync('unicorn.png', 0, 4100);
|
||||
|
||||
fileType(buffer);
|
||||
//=> {ext: 'png', mime: 'image/png'}
|
||||
```
|
||||
|
||||
Or from a remote location:
|
||||
|
||||
```js
|
||||
const http = require('http');
|
||||
const fileType = require('file-type');
|
||||
const url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
|
||||
|
||||
http.get(url, res => {
|
||||
res.once('data', chunk => {
|
||||
res.destroy();
|
||||
console.log(fileType(chunk));
|
||||
//=> {ext: 'gif', mime: 'image/gif'}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
##### Browser
|
||||
|
||||
```js
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'unicorn.png');
|
||||
xhr.responseType = 'arraybuffer';
|
||||
|
||||
xhr.onload = () => {
|
||||
fileType(new Uint8Array(this.response));
|
||||
//=> {ext: 'png', mime: 'image/png'}
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### fileType(input)
|
||||
|
||||
Returns an `Object` with:
|
||||
|
||||
- `ext` - One of the [supported file types](#supported-file-types)
|
||||
- `mime` - The [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)
|
||||
|
||||
Or `null` when no match.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Buffer` `Uint8Array`
|
||||
|
||||
It only needs the first 4100 bytes.
|
||||
|
||||
|
||||
## Supported file types
|
||||
|
||||
- [`jpg`](https://en.wikipedia.org/wiki/JPEG)
|
||||
- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
|
||||
- [`gif`](https://en.wikipedia.org/wiki/GIF)
|
||||
- [`webp`](https://en.wikipedia.org/wiki/WebP)
|
||||
- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format)
|
||||
- [`cr2`](http://fileinfo.com/extension/cr2)
|
||||
- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
|
||||
- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
|
||||
- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
|
||||
- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
|
||||
- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format))
|
||||
- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format)
|
||||
- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format))
|
||||
- [`gz`](https://en.wikipedia.org/wiki/Gzip)
|
||||
- [`bz2`](https://en.wikipedia.org/wiki/Bzip2)
|
||||
- [`7z`](https://en.wikipedia.org/wiki/7z)
|
||||
- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image)
|
||||
- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions)
|
||||
- [`m4v`](https://en.wikipedia.org/wiki/M4V)
|
||||
- [`mid`](https://en.wikipedia.org/wiki/MIDI)
|
||||
- [`mkv`](https://en.wikipedia.org/wiki/Matroska)
|
||||
- [`webm`](https://en.wikipedia.org/wiki/WebM)
|
||||
- [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format)
|
||||
- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave)
|
||||
- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video)
|
||||
- [`mpg`](https://en.wikipedia.org/wiki/MPEG-1)
|
||||
- [`mp3`](https://en.wikipedia.org/wiki/MP3)
|
||||
- [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A)
|
||||
- [`ogg`](https://en.wikipedia.org/wiki/Ogg)
|
||||
- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format))
|
||||
- [`flac`](https://en.wikipedia.org/wiki/FLAC)
|
||||
- [`wav`](https://en.wikipedia.org/wiki/WAV)
|
||||
- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec)
|
||||
- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format)
|
||||
- [`epub`](https://en.wikipedia.org/wiki/EPUB)
|
||||
- [`exe`](https://en.wikipedia.org/wiki/.exe)
|
||||
- [`swf`](https://en.wikipedia.org/wiki/SWF)
|
||||
- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format)
|
||||
- [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
|
||||
- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
|
||||
- [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType)
|
||||
- [`ttf`](https://en.wikipedia.org/wiki/TrueType)
|
||||
- [`otf`](https://en.wikipedia.org/wiki/OpenType)
|
||||
- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
|
||||
- [`flv`](https://en.wikipedia.org/wiki/Flash_Video)
|
||||
- [`ps`](https://en.wikipedia.org/wiki/Postscript)
|
||||
- [`xz`](https://en.wikipedia.org/wiki/Xz)
|
||||
- [`sqlite`](https://www.sqlite.org/fileformat2.html)
|
||||
- [`nes`](http://fileinfo.com/extension/nes)
|
||||
- [`crx`](https://developer.chrome.com/extensions/crx)
|
||||
- [`xpi`](https://en.wikipedia.org/wiki/XPInstall)
|
||||
- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format))
|
||||
- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format))
|
||||
- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix))
|
||||
- [`rpm`](http://fileinfo.com/extension/rpm)
|
||||
- [`Z`](http://fileinfo.com/extension/z)
|
||||
- [`lz`](https://en.wikipedia.org/wiki/Lzip)
|
||||
- [`msi`](https://en.wikipedia.org/wiki/Windows_Installer)
|
||||
- [`mxf`](https://en.wikipedia.org/wiki/Material_Exchange_Format)
|
||||
- [`mts`](https://en.wikipedia.org/wiki/.m2ts)
|
||||
- [`wasm`](https://en.wikipedia.org/wiki/WebAssembly)
|
||||
- [`blend`](https://wiki.blender.org/index.php/Dev:Source/Architecture/File_Format)
|
||||
- [`bpg`](https://bellard.org/bpg/)
|
||||
|
||||
*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*
|
||||
|
||||
*Pull request welcome for additional commonly used file types.*
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
54
node_modules/decompress-targz/node_modules/isarray/README.md
generated
vendored
54
node_modules/decompress-targz/node_modules/isarray/README.md
generated
vendored
@@ -1,54 +0,0 @@
|
||||
|
||||
# isarray
|
||||
|
||||
`Array#isArray` for older browsers.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isArray = require('isarray');
|
||||
|
||||
console.log(isArray([])); // => true
|
||||
console.log(isArray({})); // => false
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](http://npmjs.org) do
|
||||
|
||||
```bash
|
||||
$ npm install isarray
|
||||
```
|
||||
|
||||
Then bundle for the browser with
|
||||
[browserify](https://github.com/substack/browserify).
|
||||
|
||||
With [component](http://component.io) do
|
||||
|
||||
```bash
|
||||
$ component install juliangruber/isarray
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.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.
|
||||
209
node_modules/decompress-targz/node_modules/isarray/build/build.js
generated
vendored
209
node_modules/decompress-targz/node_modules/isarray/build/build.js
generated
vendored
@@ -1,209 +0,0 @@
|
||||
|
||||
/**
|
||||
* Require the given path.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Object} exports
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function require(path, parent, orig) {
|
||||
var resolved = require.resolve(path);
|
||||
|
||||
// lookup failed
|
||||
if (null == resolved) {
|
||||
orig = orig || path;
|
||||
parent = parent || 'root';
|
||||
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
|
||||
err.path = orig;
|
||||
err.parent = parent;
|
||||
err.require = true;
|
||||
throw err;
|
||||
}
|
||||
|
||||
var module = require.modules[resolved];
|
||||
|
||||
// perform real require()
|
||||
// by invoking the module's
|
||||
// registered function
|
||||
if (!module.exports) {
|
||||
module.exports = {};
|
||||
module.client = module.component = true;
|
||||
module.call(this, module.exports, require.relative(resolved), module);
|
||||
}
|
||||
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registered modules.
|
||||
*/
|
||||
|
||||
require.modules = {};
|
||||
|
||||
/**
|
||||
* Registered aliases.
|
||||
*/
|
||||
|
||||
require.aliases = {};
|
||||
|
||||
/**
|
||||
* Resolve `path`.
|
||||
*
|
||||
* Lookup:
|
||||
*
|
||||
* - PATH/index.js
|
||||
* - PATH.js
|
||||
* - PATH
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {String} path or null
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.resolve = function(path) {
|
||||
if (path.charAt(0) === '/') path = path.slice(1);
|
||||
var index = path + '/index.js';
|
||||
|
||||
var paths = [
|
||||
path,
|
||||
path + '.js',
|
||||
path + '.json',
|
||||
path + '/index.js',
|
||||
path + '/index.json'
|
||||
];
|
||||
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
var path = paths[i];
|
||||
if (require.modules.hasOwnProperty(path)) return path;
|
||||
}
|
||||
|
||||
if (require.aliases.hasOwnProperty(index)) {
|
||||
return require.aliases[index];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize `path` relative to the current path.
|
||||
*
|
||||
* @param {String} curr
|
||||
* @param {String} path
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.normalize = function(curr, path) {
|
||||
var segs = [];
|
||||
|
||||
if ('.' != path.charAt(0)) return path;
|
||||
|
||||
curr = curr.split('/');
|
||||
path = path.split('/');
|
||||
|
||||
for (var i = 0; i < path.length; ++i) {
|
||||
if ('..' == path[i]) {
|
||||
curr.pop();
|
||||
} else if ('.' != path[i] && '' != path[i]) {
|
||||
segs.push(path[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return curr.concat(segs).join('/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Register module at `path` with callback `definition`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} definition
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.register = function(path, definition) {
|
||||
require.modules[path] = definition;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias a module definition.
|
||||
*
|
||||
* @param {String} from
|
||||
* @param {String} to
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.alias = function(from, to) {
|
||||
if (!require.modules.hasOwnProperty(from)) {
|
||||
throw new Error('Failed to alias "' + from + '", it does not exist');
|
||||
}
|
||||
require.aliases[to] = from;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a require function relative to the `parent` path.
|
||||
*
|
||||
* @param {String} parent
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.relative = function(parent) {
|
||||
var p = require.normalize(parent, '..');
|
||||
|
||||
/**
|
||||
* lastIndexOf helper.
|
||||
*/
|
||||
|
||||
function lastIndexOf(arr, obj) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === obj) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The relative require() itself.
|
||||
*/
|
||||
|
||||
function localRequire(path) {
|
||||
var resolved = localRequire.resolve(path);
|
||||
return require(resolved, parent, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve relative to the parent.
|
||||
*/
|
||||
|
||||
localRequire.resolve = function(path) {
|
||||
var c = path.charAt(0);
|
||||
if ('/' == c) return path.slice(1);
|
||||
if ('.' == c) return require.normalize(p, path);
|
||||
|
||||
// resolve deps by returning
|
||||
// the dep in the nearest "deps"
|
||||
// directory
|
||||
var segs = parent.split('/');
|
||||
var i = lastIndexOf(segs, 'deps') + 1;
|
||||
if (!i) i = 0;
|
||||
path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if module is defined at `path`.
|
||||
*/
|
||||
|
||||
localRequire.exists = function(path) {
|
||||
return require.modules.hasOwnProperty(localRequire.resolve(path));
|
||||
};
|
||||
|
||||
return localRequire;
|
||||
};
|
||||
require.register("isarray/index.js", function(exports, require, module){
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return Object.prototype.toString.call(arr) == '[object Array]';
|
||||
};
|
||||
|
||||
});
|
||||
require.alias("isarray/index.js", "isarray/index.js");
|
||||
|
||||
19
node_modules/decompress-targz/node_modules/isarray/component.json
generated
vendored
19
node_modules/decompress-targz/node_modules/isarray/component.json
generated
vendored
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name" : "isarray",
|
||||
"description" : "Array#isArray for older browsers",
|
||||
"version" : "0.0.1",
|
||||
"repository" : "juliangruber/isarray",
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"main" : "index.js",
|
||||
"scripts" : [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies" : {},
|
||||
"keywords": ["browser","isarray","array"],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
3
node_modules/decompress-targz/node_modules/isarray/index.js
generated
vendored
3
node_modules/decompress-targz/node_modules/isarray/index.js
generated
vendored
@@ -1,3 +0,0 @@
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return Object.prototype.toString.call(arr) == '[object Array]';
|
||||
};
|
||||
25
node_modules/decompress-targz/node_modules/isarray/package.json
generated
vendored
25
node_modules/decompress-targz/node_modules/isarray/package.json
generated
vendored
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name" : "isarray",
|
||||
"description" : "Array#isArray for older browsers",
|
||||
"version" : "0.0.1",
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "git://github.com/juliangruber/isarray.git"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"main" : "index.js",
|
||||
"scripts" : {
|
||||
"test" : "tap test/*.js"
|
||||
},
|
||||
"dependencies" : {},
|
||||
"devDependencies" : {
|
||||
"tap" : "*"
|
||||
},
|
||||
"keywords": ["browser","isarray","array"],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
26
node_modules/decompress-targz/node_modules/object-assign/index.js
generated
vendored
26
node_modules/decompress-targz/node_modules/object-assign/index.js
generated
vendored
@@ -1,26 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
function ToObject(val) {
|
||||
if (val == null) {
|
||||
throw new TypeError('Object.assign cannot be called with null or undefined');
|
||||
}
|
||||
|
||||
return Object(val);
|
||||
}
|
||||
|
||||
module.exports = Object.assign || function (target, source) {
|
||||
var from;
|
||||
var keys;
|
||||
var to = ToObject(target);
|
||||
|
||||
for (var s = 1; s < arguments.length; s++) {
|
||||
from = arguments[s];
|
||||
keys = Object.keys(Object(from));
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
to[keys[i]] = from[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
};
|
||||
38
node_modules/decompress-targz/node_modules/object-assign/package.json
generated
vendored
38
node_modules/decompress-targz/node_modules/object-assign/package.json
generated
vendored
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"name": "object-assign",
|
||||
"version": "2.1.1",
|
||||
"description": "ES6 Object.assign() ponyfill",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/object-assign",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"object",
|
||||
"assign",
|
||||
"extend",
|
||||
"properties",
|
||||
"es6",
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"ponyfill",
|
||||
"prollyfill",
|
||||
"polyfill",
|
||||
"shim",
|
||||
"browser"
|
||||
],
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
}
|
||||
}
|
||||
51
node_modules/decompress-targz/node_modules/object-assign/readme.md
generated
vendored
51
node_modules/decompress-targz/node_modules/object-assign/readme.md
generated
vendored
@@ -1,51 +0,0 @@
|
||||
# object-assign [](https://travis-ci.org/sindresorhus/object-assign)
|
||||
|
||||
> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill
|
||||
|
||||
> Ponyfill: A polyfill that doesn't overwrite the native method
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save object-assign
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var objectAssign = require('object-assign');
|
||||
|
||||
objectAssign({foo: 0}, {bar: 1});
|
||||
//=> {foo: 0, bar: 1}
|
||||
|
||||
// multiple sources
|
||||
objectAssign({foo: 0}, {bar: 1}, {baz: 2});
|
||||
//=> {foo: 0, bar: 1, baz: 2}
|
||||
|
||||
// overwrites equal keys
|
||||
objectAssign({foo: 0}, {foo: 1}, {foo: 2});
|
||||
//=> {foo: 2}
|
||||
|
||||
// ignores null and undefined sources
|
||||
objectAssign({foo: 0}, null, {bar: 1}, undefined);
|
||||
//=> {foo: 0, bar: 1}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### objectAssign(target, source, [source, ...])
|
||||
|
||||
Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones.
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
5
node_modules/decompress-targz/node_modules/readable-stream/.npmignore
generated
vendored
5
node_modules/decompress-targz/node_modules/readable-stream/.npmignore
generated
vendored
@@ -1,5 +0,0 @@
|
||||
build/
|
||||
test/
|
||||
examples/
|
||||
fs.js
|
||||
zlib.js
|
||||
18
node_modules/decompress-targz/node_modules/readable-stream/LICENSE
generated
vendored
18
node_modules/decompress-targz/node_modules/readable-stream/LICENSE
generated
vendored
@@ -1,18 +0,0 @@
|
||||
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.
|
||||
15
node_modules/decompress-targz/node_modules/readable-stream/README.md
generated
vendored
15
node_modules/decompress-targz/node_modules/readable-stream/README.md
generated
vendored
@@ -1,15 +0,0 @@
|
||||
# readable-stream
|
||||
|
||||
***Node-core streams for userland***
|
||||
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
|
||||
This package is a mirror of the Streams2 and Streams3 implementations in Node-core.
|
||||
|
||||
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.
|
||||
|
||||
**readable-stream** comes in two major versions, v1.0.x and v1.1.x. The former tracks the Streams2 implementation in Node 0.10, including bug-fixes and minor improvements as they are added. The latter tracks Streams3 as it develops in Node 0.11; we will likely see a v1.2.x branch for Node 0.12.
|
||||
|
||||
**readable-stream** uses proper patch-level versioning so if you pin to `"~1.0.0"` you’ll get the latest Node 0.10 Streams2 implementation, including any fixes and minor non-breaking improvements. The patch-level versions of 1.0.x and 1.1.x should mirror the patch-level versions of Node-core releases. You should prefer the **1.0.x** releases for now and when you’re ready to start using Streams3, pin to `"~1.1.0"`
|
||||
|
||||
1
node_modules/decompress-targz/node_modules/readable-stream/duplex.js
generated
vendored
1
node_modules/decompress-targz/node_modules/readable-stream/duplex.js
generated
vendored
@@ -1 +0,0 @@
|
||||
module.exports = require("./lib/_stream_duplex.js")
|
||||
89
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
89
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
@@ -1,89 +0,0 @@
|
||||
// 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.
|
||||
|
||||
module.exports = Duplex;
|
||||
|
||||
/*<replacement>*/
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) keys.push(key);
|
||||
return keys;
|
||||
}
|
||||
/*</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);
|
||||
|
||||
forEach(objectKeys(Writable.prototype), function(method) {
|
||||
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.
|
||||
process.nextTick(this.end.bind(this));
|
||||
}
|
||||
|
||||
function forEach (xs, f) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
f(xs[i], i);
|
||||
}
|
||||
}
|
||||
46
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
46
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
@@ -1,46 +0,0 @@
|
||||
// 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.
|
||||
|
||||
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);
|
||||
};
|
||||
982
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
982
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
@@ -1,982 +0,0 @@
|
||||
// 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.
|
||||
|
||||
module.exports = Readable;
|
||||
|
||||
/*<replacement>*/
|
||||
var isArray = require('isarray');
|
||||
/*</replacement>*/
|
||||
|
||||
|
||||
/*<replacement>*/
|
||||
var Buffer = require('buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
Readable.ReadableState = ReadableState;
|
||||
|
||||
var EE = require('events').EventEmitter;
|
||||
|
||||
/*<replacement>*/
|
||||
if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
|
||||
return emitter.listeners(type).length;
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
var Stream = require('stream');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var StringDecoder;
|
||||
|
||||
util.inherits(Readable, Stream);
|
||||
|
||||
function ReadableState(options, stream) {
|
||||
options = options || {};
|
||||
|
||||
// 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;
|
||||
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = ~~this.highWaterMark;
|
||||
|
||||
this.buffer = [];
|
||||
this.length = 0;
|
||||
this.pipes = null;
|
||||
this.pipesCount = 0;
|
||||
this.flowing = false;
|
||||
this.ended = false;
|
||||
this.endEmitted = false;
|
||||
this.reading = false;
|
||||
|
||||
// In streams that never have any data, and do push(null) right away,
|
||||
// the consumer can miss the 'end' event if they do some I/O before
|
||||
// consuming the stream. So, we don't emit('end') until some reading
|
||||
// happens.
|
||||
this.calledRead = 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, becuase 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;
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
function Readable(options) {
|
||||
if (!(this instanceof Readable))
|
||||
return new Readable(options);
|
||||
|
||||
this._readableState = new ReadableState(options, this);
|
||||
|
||||
// legacy
|
||||
this.readable = true;
|
||||
|
||||
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 (typeof chunk === 'string' && !state.objectMode) {
|
||||
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);
|
||||
};
|
||||
|
||||
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
||||
var er = chunkInvalid(state, chunk);
|
||||
if (er) {
|
||||
stream.emit('error', er);
|
||||
} else if (chunk === null || chunk === undefined) {
|
||||
state.reading = false;
|
||||
if (!state.ended)
|
||||
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 {
|
||||
if (state.decoder && !addToFront && !encoding)
|
||||
chunk = state.decoder.write(chunk);
|
||||
|
||||
// update the buffer info.
|
||||
state.length += state.objectMode ? 1 : chunk.length;
|
||||
if (addToFront) {
|
||||
state.buffer.unshift(chunk);
|
||||
} else {
|
||||
state.reading = false;
|
||||
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;
|
||||
};
|
||||
|
||||
// Don't raise the hwm > 128MB
|
||||
var MAX_HWM = 0x800000;
|
||||
function roundUpToNextPowerOf2(n) {
|
||||
if (n >= MAX_HWM) {
|
||||
n = MAX_HWM;
|
||||
} else {
|
||||
// Get the next highest power of 2
|
||||
n--;
|
||||
for (var p = 1; p < 32; p <<= 1) n |= n >> p;
|
||||
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 = roundUpToNextPowerOf2(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) {
|
||||
var state = this._readableState;
|
||||
state.calledRead = true;
|
||||
var nOrig = n;
|
||||
var ret;
|
||||
|
||||
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)) {
|
||||
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) {
|
||||
ret = null;
|
||||
|
||||
// In cases where the decoder did not receive enough data
|
||||
// to produce a full chunk, then immediately received an
|
||||
// EOF, state.buffer will contain [<Buffer >, <Buffer 00 ...>].
|
||||
// howMuchToRead will see this and coerce the amount to
|
||||
// read to zero (because it's looking at the length of the
|
||||
// first <Buffer > in state.buffer), and we'll end up here.
|
||||
//
|
||||
// This can only happen via state.decoder -- no other venue
|
||||
// exists for pushing a zero-length chunk into state.buffer
|
||||
// and triggering this behavior. In this case, we return our
|
||||
// remaining data and end the stream, if appropriate.
|
||||
if (state.length > 0 && state.decoder) {
|
||||
ret = fromList(n, state);
|
||||
state.length -= ret.length;
|
||||
}
|
||||
|
||||
if (state.length === 0)
|
||||
endReadable(this);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// if we currently have less than the highWaterMark, then also read some
|
||||
if (state.length - n <= state.highWaterMark)
|
||||
doRead = true;
|
||||
|
||||
// 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;
|
||||
|
||||
if (doRead) {
|
||||
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 called its callback 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);
|
||||
|
||||
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 happened to read() exactly the remaining amount in the
|
||||
// buffer, and the EOF has been seen at this point, then make sure
|
||||
// that we emit 'end' on the very next tick.
|
||||
if (state.ended && !state.endEmitted && state.length === 0)
|
||||
endReadable(this);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
function chunkInvalid(state, chunk) {
|
||||
var er = null;
|
||||
if (!Buffer.isBuffer(chunk) &&
|
||||
'string' !== typeof chunk &&
|
||||
chunk !== null &&
|
||||
chunk !== undefined &&
|
||||
!state.objectMode) {
|
||||
er = new TypeError('Invalid non-string/buffer chunk');
|
||||
}
|
||||
return er;
|
||||
}
|
||||
|
||||
|
||||
function onEofChunk(stream, state) {
|
||||
if (state.decoder && !state.ended) {
|
||||
var chunk = state.decoder.end();
|
||||
if (chunk && chunk.length) {
|
||||
state.buffer.push(chunk);
|
||||
state.length += state.objectMode ? 1 : chunk.length;
|
||||
}
|
||||
}
|
||||
state.ended = true;
|
||||
|
||||
// if we've ended and we have some data left, then emit
|
||||
// 'readable' now to make sure it gets picked up.
|
||||
if (state.length > 0)
|
||||
emitReadable(stream);
|
||||
else
|
||||
endReadable(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)
|
||||
return;
|
||||
|
||||
state.emittedReadable = true;
|
||||
if (state.sync)
|
||||
process.nextTick(function() {
|
||||
emitReadable_(stream);
|
||||
});
|
||||
else
|
||||
emitReadable_(stream);
|
||||
}
|
||||
|
||||
function emitReadable_(stream) {
|
||||
stream.emit('readable');
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
process.nextTick(function() {
|
||||
maybeReadMore_(stream, state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function maybeReadMore_(stream, state) {
|
||||
var len = state.length;
|
||||
while (!state.reading && !state.flowing && !state.ended &&
|
||||
state.length < state.highWaterMark) {
|
||||
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;
|
||||
|
||||
var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
|
||||
dest !== process.stdout &&
|
||||
dest !== process.stderr;
|
||||
|
||||
var endFn = doEnd ? onend : cleanup;
|
||||
if (state.endEmitted)
|
||||
process.nextTick(endFn);
|
||||
else
|
||||
src.once('end', endFn);
|
||||
|
||||
dest.on('unpipe', onunpipe);
|
||||
function onunpipe(readable) {
|
||||
if (readable !== src) return;
|
||||
cleanup();
|
||||
}
|
||||
|
||||
function 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);
|
||||
|
||||
function 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);
|
||||
|
||||
// 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 (!dest._writableState || dest._writableState.needDrain)
|
||||
ondrain();
|
||||
}
|
||||
|
||||
// if the dest has an error, then stop piping into it.
|
||||
// however, don't suppress the throwing behavior for this.
|
||||
function onerror(er) {
|
||||
unpipe();
|
||||
dest.removeListener('error', onerror);
|
||||
if (EE.listenerCount(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() {
|
||||
dest.removeListener('close', onclose);
|
||||
unpipe();
|
||||
}
|
||||
dest.once('finish', onfinish);
|
||||
|
||||
function 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) {
|
||||
// the handler that waits for readable events after all
|
||||
// the data gets sucked out in flow.
|
||||
// This would be easier to follow with a .once() handler
|
||||
// in flow(), but that is too slow.
|
||||
this.on('readable', pipeOnReadable);
|
||||
|
||||
state.flowing = true;
|
||||
process.nextTick(function() {
|
||||
flow(src);
|
||||
});
|
||||
}
|
||||
|
||||
return dest;
|
||||
};
|
||||
|
||||
function pipeOnDrain(src) {
|
||||
return function() {
|
||||
var dest = this;
|
||||
var state = src._readableState;
|
||||
state.awaitDrain--;
|
||||
if (state.awaitDrain === 0)
|
||||
flow(src);
|
||||
};
|
||||
}
|
||||
|
||||
function flow(src) {
|
||||
var state = src._readableState;
|
||||
var chunk;
|
||||
state.awaitDrain = 0;
|
||||
|
||||
function write(dest, i, list) {
|
||||
var written = dest.write(chunk);
|
||||
if (false === written) {
|
||||
state.awaitDrain++;
|
||||
}
|
||||
}
|
||||
|
||||
while (state.pipesCount && null !== (chunk = src.read())) {
|
||||
|
||||
if (state.pipesCount === 1)
|
||||
write(state.pipes, 0, null);
|
||||
else
|
||||
forEach(state.pipes, write);
|
||||
|
||||
src.emit('data', chunk);
|
||||
|
||||
// if anyone needs a drain, then we have to wait for that.
|
||||
if (state.awaitDrain > 0)
|
||||
return;
|
||||
}
|
||||
|
||||
// if every destination was unpiped, either before entering this
|
||||
// function, or in the while loop, then stop flowing.
|
||||
//
|
||||
// NB: This is a pretty rare edge case.
|
||||
if (state.pipesCount === 0) {
|
||||
state.flowing = false;
|
||||
|
||||
// if there were data event listeners added, then switch to old mode.
|
||||
if (EE.listenerCount(src, 'data') > 0)
|
||||
emitDataEvents(src);
|
||||
return;
|
||||
}
|
||||
|
||||
// at this point, no one needed a drain, so we just ran out of data
|
||||
// on the next readable event, start it over again.
|
||||
state.ranOut = true;
|
||||
}
|
||||
|
||||
function pipeOnReadable() {
|
||||
if (this._readableState.ranOut) {
|
||||
this._readableState.ranOut = false;
|
||||
flow(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
this.removeListener('readable', pipeOnReadable);
|
||||
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;
|
||||
this.removeListener('readable', pipeOnReadable);
|
||||
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 (ev === 'data' && !this._readableState.flowing)
|
||||
emitDataEvents(this);
|
||||
|
||||
if (ev === 'readable' && this.readable) {
|
||||
var state = this._readableState;
|
||||
if (!state.readableListening) {
|
||||
state.readableListening = true;
|
||||
state.emittedReadable = false;
|
||||
state.needReadable = true;
|
||||
if (!state.reading) {
|
||||
this.read(0);
|
||||
} else if (state.length) {
|
||||
emitReadable(this, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
Readable.prototype.addListener = Readable.prototype.on;
|
||||
|
||||
// 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() {
|
||||
emitDataEvents(this);
|
||||
this.read(0);
|
||||
this.emit('resume');
|
||||
};
|
||||
|
||||
Readable.prototype.pause = function() {
|
||||
emitDataEvents(this, true);
|
||||
this.emit('pause');
|
||||
};
|
||||
|
||||
function emitDataEvents(stream, startPaused) {
|
||||
var state = stream._readableState;
|
||||
|
||||
if (state.flowing) {
|
||||
// https://github.com/isaacs/readable-stream/issues/16
|
||||
throw new Error('Cannot switch to old mode now.');
|
||||
}
|
||||
|
||||
var paused = startPaused || false;
|
||||
var readable = false;
|
||||
|
||||
// convert to an old-style stream.
|
||||
stream.readable = true;
|
||||
stream.pipe = Stream.prototype.pipe;
|
||||
stream.on = stream.addListener = Stream.prototype.on;
|
||||
|
||||
stream.on('readable', function() {
|
||||
readable = true;
|
||||
|
||||
var c;
|
||||
while (!paused && (null !== (c = stream.read())))
|
||||
stream.emit('data', c);
|
||||
|
||||
if (c === null) {
|
||||
readable = false;
|
||||
stream._readableState.needReadable = true;
|
||||
}
|
||||
});
|
||||
|
||||
stream.pause = function() {
|
||||
paused = true;
|
||||
this.emit('pause');
|
||||
};
|
||||
|
||||
stream.resume = function() {
|
||||
paused = false;
|
||||
if (readable)
|
||||
process.nextTick(function() {
|
||||
stream.emit('readable');
|
||||
});
|
||||
else
|
||||
this.read(0);
|
||||
this.emit('resume');
|
||||
};
|
||||
|
||||
// now make it start, just in case it hadn't already.
|
||||
stream.emit('readable');
|
||||
}
|
||||
|
||||
// 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() {
|
||||
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) {
|
||||
if (state.decoder)
|
||||
chunk = state.decoder.write(chunk);
|
||||
|
||||
// don't skip over falsy values in objectMode
|
||||
//if (state.objectMode && util.isNullOrUndefined(chunk))
|
||||
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 (typeof stream[i] === 'function' &&
|
||||
typeof this[i] === 'undefined') {
|
||||
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) {
|
||||
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
|
||||
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.calledRead) {
|
||||
state.ended = true;
|
||||
process.nextTick(function() {
|
||||
// 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;
|
||||
}
|
||||
210
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
210
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
@@ -1,210 +0,0 @@
|
||||
// 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.
|
||||
|
||||
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(options, stream) {
|
||||
this.afterTransform = function(er, data) {
|
||||
return afterTransform(stream, er, data);
|
||||
};
|
||||
|
||||
this.needTransform = false;
|
||||
this.transforming = false;
|
||||
this.writecb = null;
|
||||
this.writechunk = 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);
|
||||
|
||||
if (cb)
|
||||
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);
|
||||
|
||||
var ts = this._transformState = new TransformState(options, 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;
|
||||
|
||||
this.once('finish', function() {
|
||||
if ('function' === typeof this._flush)
|
||||
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 rs = stream._readableState;
|
||||
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);
|
||||
}
|
||||
386
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
386
node_modules/decompress-targz/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
@@ -1,386 +0,0 @@
|
||||
// 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, cb), and it'll handle all
|
||||
// the drain event emission and buffering.
|
||||
|
||||
module.exports = Writable;
|
||||
|
||||
/*<replacement>*/
|
||||
var Buffer = require('buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Stream = require('stream');
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
|
||||
function WriteReq(chunk, encoding, cb) {
|
||||
this.chunk = chunk;
|
||||
this.encoding = encoding;
|
||||
this.callback = cb;
|
||||
}
|
||||
|
||||
function WritableState(options, stream) {
|
||||
options = options || {};
|
||||
|
||||
// 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;
|
||||
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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, becuase 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.buffer = [];
|
||||
|
||||
// True if the error was already emitted and should not be thrown again
|
||||
this.errorEmitted = false;
|
||||
}
|
||||
|
||||
function Writable(options) {
|
||||
var 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;
|
||||
|
||||
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, state, cb) {
|
||||
var er = new Error('write after end');
|
||||
// TODO: defer error events consistently everywhere, not just the cb
|
||||
stream.emit('error', er);
|
||||
process.nextTick(function() {
|
||||
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) &&
|
||||
'string' !== typeof chunk &&
|
||||
chunk !== null &&
|
||||
chunk !== undefined &&
|
||||
!state.objectMode) {
|
||||
var er = new TypeError('Invalid non-string/buffer chunk');
|
||||
stream.emit('error', er);
|
||||
process.nextTick(function() {
|
||||
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 = function() {};
|
||||
|
||||
if (state.ended)
|
||||
writeAfterEnd(this, state, cb);
|
||||
else if (validChunk(this, state, chunk, cb))
|
||||
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
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.buffer.push(new WriteReq(chunk, encoding, cb));
|
||||
else
|
||||
doWrite(stream, state, len, chunk, encoding, cb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function doWrite(stream, state, len, chunk, encoding, cb) {
|
||||
state.writelen = len;
|
||||
state.writecb = cb;
|
||||
state.writing = true;
|
||||
state.sync = true;
|
||||
stream._write(chunk, encoding, state.onwrite);
|
||||
state.sync = false;
|
||||
}
|
||||
|
||||
function onwriteError(stream, state, sync, er, cb) {
|
||||
if (sync)
|
||||
process.nextTick(function() {
|
||||
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(stream, state);
|
||||
|
||||
if (!finished && !state.bufferProcessing && state.buffer.length)
|
||||
clearBuffer(stream, state);
|
||||
|
||||
if (sync) {
|
||||
process.nextTick(function() {
|
||||
afterWrite(stream, state, finished, cb);
|
||||
});
|
||||
} else {
|
||||
afterWrite(stream, state, finished, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterWrite(stream, state, finished, cb) {
|
||||
if (!finished)
|
||||
onwriteDrain(stream, state);
|
||||
cb();
|
||||
if (finished)
|
||||
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;
|
||||
|
||||
for (var c = 0; c < state.buffer.length; c++) {
|
||||
var entry = state.buffer[c];
|
||||
var chunk = entry.chunk;
|
||||
var encoding = entry.encoding;
|
||||
var cb = entry.callback;
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
doWrite(stream, state, len, chunk, encoding, cb);
|
||||
|
||||
// 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) {
|
||||
c++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
state.bufferProcessing = false;
|
||||
if (c < state.buffer.length)
|
||||
state.buffer = state.buffer.slice(c);
|
||||
else
|
||||
state.buffer.length = 0;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function(chunk, encoding, cb) {
|
||||
cb(new Error('not implemented'));
|
||||
};
|
||||
|
||||
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 (typeof chunk !== 'undefined' && chunk !== null)
|
||||
this.write(chunk, encoding);
|
||||
|
||||
// ignore unnecessary end() calls.
|
||||
if (!state.ending && !state.finished)
|
||||
endWritable(this, state, cb);
|
||||
};
|
||||
|
||||
|
||||
function needFinish(stream, state) {
|
||||
return (state.ending &&
|
||||
state.length === 0 &&
|
||||
!state.finished &&
|
||||
!state.writing);
|
||||
}
|
||||
|
||||
function finishMaybe(stream, state) {
|
||||
var need = needFinish(stream, state);
|
||||
if (need) {
|
||||
state.finished = true;
|
||||
stream.emit('finish');
|
||||
}
|
||||
return need;
|
||||
}
|
||||
|
||||
function endWritable(stream, state, cb) {
|
||||
state.ending = true;
|
||||
finishMaybe(stream, state);
|
||||
if (cb) {
|
||||
if (state.finished)
|
||||
process.nextTick(cb);
|
||||
else
|
||||
stream.once('finish', cb);
|
||||
}
|
||||
state.ended = true;
|
||||
}
|
||||
32
node_modules/decompress-targz/node_modules/readable-stream/package.json
generated
vendored
32
node_modules/decompress-targz/node_modules/readable-stream/package.json
generated
vendored
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"name": "readable-stream",
|
||||
"version": "1.0.34",
|
||||
"description": "Streams2, a user-land copy of the stream library from Node.js v0.10.x",
|
||||
"main": "readable.js",
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "~0.10.x",
|
||||
"inherits": "~2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "~0.2.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/simple/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/readable-stream"
|
||||
},
|
||||
"keywords": [
|
||||
"readable",
|
||||
"stream",
|
||||
"pipe"
|
||||
],
|
||||
"browser": {
|
||||
"util": false
|
||||
},
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"license": "MIT"
|
||||
}
|
||||
1
node_modules/decompress-targz/node_modules/readable-stream/passthrough.js
generated
vendored
1
node_modules/decompress-targz/node_modules/readable-stream/passthrough.js
generated
vendored
@@ -1 +0,0 @@
|
||||
module.exports = require("./lib/_stream_passthrough.js")
|
||||
11
node_modules/decompress-targz/node_modules/readable-stream/readable.js
generated
vendored
11
node_modules/decompress-targz/node_modules/readable-stream/readable.js
generated
vendored
@@ -1,11 +0,0 @@
|
||||
var Stream = require('stream'); // hack to fix a circular dependency issue when used with browserify
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = Stream;
|
||||
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');
|
||||
if (!process.browser && process.env.READABLE_STREAM === 'disable') {
|
||||
module.exports = require('stream');
|
||||
}
|
||||
1
node_modules/decompress-targz/node_modules/readable-stream/transform.js
generated
vendored
1
node_modules/decompress-targz/node_modules/readable-stream/transform.js
generated
vendored
@@ -1 +0,0 @@
|
||||
module.exports = require("./lib/_stream_transform.js")
|
||||
1
node_modules/decompress-targz/node_modules/readable-stream/writable.js
generated
vendored
1
node_modules/decompress-targz/node_modules/readable-stream/writable.js
generated
vendored
@@ -1 +0,0 @@
|
||||
module.exports = require("./lib/_stream_writable.js")
|
||||
2
node_modules/decompress-targz/node_modules/string_decoder/.npmignore
generated
vendored
2
node_modules/decompress-targz/node_modules/string_decoder/.npmignore
generated
vendored
@@ -1,2 +0,0 @@
|
||||
build
|
||||
test
|
||||
20
node_modules/decompress-targz/node_modules/string_decoder/LICENSE
generated
vendored
20
node_modules/decompress-targz/node_modules/string_decoder/LICENSE
generated
vendored
@@ -1,20 +0,0 @@
|
||||
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
node_modules/decompress-targz/node_modules/string_decoder/README.md
generated
vendored
7
node_modules/decompress-targz/node_modules/string_decoder/README.md
generated
vendored
@@ -1,7 +0,0 @@
|
||||
**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
node_modules/decompress-targz/node_modules/string_decoder/index.js
generated
vendored
221
node_modules/decompress-targz/node_modules/string_decoder/index.js
generated
vendored
@@ -1,221 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
25
node_modules/decompress-targz/node_modules/string_decoder/package.json
generated
vendored
25
node_modules/decompress-targz/node_modules/string_decoder/package.json
generated
vendored
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "string_decoder",
|
||||
"version": "0.10.31",
|
||||
"description": "The string_decoder module from Node core",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tap": "~0.4.8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/simple/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/rvagg/string_decoder.git"
|
||||
},
|
||||
"homepage": "https://github.com/rvagg/string_decoder",
|
||||
"keywords": [
|
||||
"string",
|
||||
"decoder",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
3
node_modules/decompress-targz/node_modules/through2/.npmignore
generated
vendored
3
node_modules/decompress-targz/node_modules/through2/.npmignore
generated
vendored
@@ -1,3 +0,0 @@
|
||||
test
|
||||
.jshintrc
|
||||
.travis.yml
|
||||
39
node_modules/decompress-targz/node_modules/through2/LICENSE
generated
vendored
39
node_modules/decompress-targz/node_modules/through2/LICENSE
generated
vendored
@@ -1,39 +0,0 @@
|
||||
Copyright 2013, Rod Vagg (the "Original Author")
|
||||
All rights reserved.
|
||||
|
||||
MIT +no-false-attribs 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.
|
||||
|
||||
Distributions of all or part of the Software intended to be used
|
||||
by the recipients as they would use the unmodified Software,
|
||||
containing modifications that substantially alter, remove, or
|
||||
disable functionality of the Software, outside of the documented
|
||||
configuration mechanisms provided by the Software, shall be
|
||||
modified such that the Original Author's bug reporting email
|
||||
addresses and urls are either replaced with the contact information
|
||||
of the parties responsible for the changes, or removed entirely.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Except where noted, this license applies to any and all software
|
||||
programs and associated documentation files created by the
|
||||
Original Author, when distributed with the Software.
|
||||
132
node_modules/decompress-targz/node_modules/through2/README.md
generated
vendored
132
node_modules/decompress-targz/node_modules/through2/README.md
generated
vendored
@@ -1,132 +0,0 @@
|
||||
# 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: A **Streams3** version of through2 is available in npm with the tag `"1.0"` rather than `"latest"` so an `npm install through2` will get you the current Streams2 version (version number is 0.x.x). To use a Streams3 version use `npm install through2@1` to fetch the latest version 1.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'))
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
## License
|
||||
|
||||
**through2** is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
||||
31
node_modules/decompress-targz/node_modules/through2/package.json
generated
vendored
31
node_modules/decompress-targz/node_modules/through2/package.json
generated
vendored
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "through2",
|
||||
"version": "0.6.5",
|
||||
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
|
||||
"main": "through2.js",
|
||||
"scripts": {
|
||||
"test": "node test/test.js",
|
||||
"test-local": "brtapsauce-local test/basic-test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rvagg/through2.git"
|
||||
},
|
||||
"keywords": [
|
||||
"stream",
|
||||
"streams2",
|
||||
"through",
|
||||
"transform"
|
||||
],
|
||||
"author": "Rod Vagg <r@va.gg> (https://github.com/rvagg)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"readable-stream": ">=1.0.33-1 <1.1.0-0",
|
||||
"xtend": ">=4.0.0 <4.1.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bl": ">=0.9.0 <0.10.0-0",
|
||||
"stream-spigot": ">=3.0.4 <3.1.0-0",
|
||||
"tape": ">=2.14.0 <2.15.0-0"
|
||||
}
|
||||
}
|
||||
96
node_modules/decompress-targz/node_modules/through2/through2.js
generated
vendored
96
node_modules/decompress-targz/node_modules/through2/through2.js
generated
vendored
@@ -1,96 +0,0 @@
|
||||
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
|
||||
})
|
||||
20
node_modules/decompress-targz/node_modules/vinyl/LICENSE
generated
vendored
20
node_modules/decompress-targz/node_modules/vinyl/LICENSE
generated
vendored
@@ -1,20 +0,0 @@
|
||||
Copyright (c) 2013 Fractal <contact@wearefractal.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.
|
||||
127
node_modules/decompress-targz/node_modules/vinyl/README.md
generated
vendored
127
node_modules/decompress-targz/node_modules/vinyl/README.md
generated
vendored
@@ -1,127 +0,0 @@
|
||||
# vinyl [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [](https://david-dm.org/wearefractal/vinyl)
|
||||
|
||||
|
||||
## Information
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Package</td><td>vinyl</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td>A virtual file format</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Node Version</td>
|
||||
<td>>= 0.9</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## What is this?
|
||||
|
||||
Read this for more info about how this plays into the grand scheme of things https://medium.com/@eschoff/3828e8126466
|
||||
|
||||
## File
|
||||
|
||||
```javascript
|
||||
var File = require('vinyl');
|
||||
|
||||
var coffeeFile = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/file.coffee",
|
||||
contents: new Buffer("test = 123")
|
||||
});
|
||||
```
|
||||
|
||||
### constructor(options)
|
||||
|
||||
#### options.cwd
|
||||
|
||||
Type: `String`
|
||||
Default: `process.cwd()`
|
||||
|
||||
#### options.base
|
||||
|
||||
Used for relative pathing. Typically where a glob starts.
|
||||
|
||||
Type: `String`
|
||||
Default: `options.cwd`
|
||||
|
||||
#### options.path
|
||||
|
||||
Full path to the file.
|
||||
|
||||
Type: `String`
|
||||
Default: `null`
|
||||
|
||||
#### options.stat
|
||||
|
||||
The result of an fs.stat call. See [fs.Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats) for more information.
|
||||
|
||||
Type: `fs.Stats`
|
||||
Default: `null`
|
||||
|
||||
#### options.contents
|
||||
|
||||
File contents.
|
||||
|
||||
Type: `Buffer, Stream, or null`
|
||||
Default: `null`
|
||||
|
||||
### isBuffer()
|
||||
|
||||
Returns true if file.contents is a Buffer.
|
||||
|
||||
### isStream()
|
||||
|
||||
Returns true if file.contents is a Stream.
|
||||
|
||||
### isNull()
|
||||
|
||||
Returns true if file.contents is null.
|
||||
|
||||
### clone()
|
||||
|
||||
Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
|
||||
|
||||
### pipe(stream[, opt])
|
||||
|
||||
If file.contents is a Buffer, it will write it to the stream.
|
||||
|
||||
If file.contents is a Stream, it will pipe it to the stream.
|
||||
|
||||
If file.contents is null, it will do nothing.
|
||||
|
||||
If opt.end is false, the destination stream will not be ended (same as node core).
|
||||
|
||||
Returns the stream.
|
||||
|
||||
### inspect()
|
||||
|
||||
Returns a pretty String interpretation of the File. Useful for console.log.
|
||||
|
||||
### relative
|
||||
|
||||
Returns path.relative for the file base and file path.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/file.coffee"
|
||||
});
|
||||
|
||||
console.log(file.relative); // file.coffee
|
||||
```
|
||||
|
||||
[npm-url]: https://npmjs.org/package/vinyl
|
||||
[npm-image]: https://badge.fury.io/js/vinyl.png
|
||||
[travis-url]: https://travis-ci.org/wearefractal/vinyl
|
||||
[travis-image]: https://travis-ci.org/wearefractal/vinyl.png?branch=master
|
||||
[coveralls-url]: https://coveralls.io/r/wearefractal/vinyl
|
||||
[coveralls-image]: https://coveralls.io/repos/wearefractal/vinyl/badge.png
|
||||
[depstat-url]: https://david-dm.org/wearefractal/vinyl
|
||||
[depstat-image]: https://david-dm.org/wearefractal/vinyl.png
|
||||
175
node_modules/decompress-targz/node_modules/vinyl/index.js
generated
vendored
175
node_modules/decompress-targz/node_modules/vinyl/index.js
generated
vendored
@@ -1,175 +0,0 @@
|
||||
var path = require('path');
|
||||
var clone = require('clone');
|
||||
var cloneStats = require('clone-stats');
|
||||
var cloneBuffer = require('./lib/cloneBuffer');
|
||||
var isBuffer = require('./lib/isBuffer');
|
||||
var isStream = require('./lib/isStream');
|
||||
var isNull = require('./lib/isNull');
|
||||
var inspectStream = require('./lib/inspectStream');
|
||||
var Stream = require('stream');
|
||||
|
||||
function File(file) {
|
||||
if (!file) file = {};
|
||||
|
||||
// record path change
|
||||
var history = file.path ? [file.path] : file.history;
|
||||
this.history = history || [];
|
||||
|
||||
// TODO: should this be moved to vinyl-fs?
|
||||
this.cwd = file.cwd || process.cwd();
|
||||
this.base = file.base || this.cwd;
|
||||
|
||||
// stat = fs stats object
|
||||
// TODO: should this be moved to vinyl-fs?
|
||||
this.stat = file.stat || null;
|
||||
|
||||
// contents = stream, buffer, or null if not read
|
||||
this.contents = file.contents || null;
|
||||
}
|
||||
|
||||
File.prototype.isBuffer = function() {
|
||||
return isBuffer(this.contents);
|
||||
};
|
||||
|
||||
File.prototype.isStream = function() {
|
||||
return isStream(this.contents);
|
||||
};
|
||||
|
||||
File.prototype.isNull = function() {
|
||||
return isNull(this.contents);
|
||||
};
|
||||
|
||||
// TODO: should this be moved to vinyl-fs?
|
||||
File.prototype.isDirectory = function() {
|
||||
return this.isNull() && this.stat && this.stat.isDirectory();
|
||||
};
|
||||
|
||||
File.prototype.clone = function(opt) {
|
||||
if (typeof opt === 'boolean') {
|
||||
opt = {
|
||||
deep: opt,
|
||||
contents: true
|
||||
};
|
||||
} else if (!opt) {
|
||||
opt = {
|
||||
deep: false,
|
||||
contents: true
|
||||
};
|
||||
} else {
|
||||
opt.deep = opt.deep === true;
|
||||
opt.contents = opt.contents !== false;
|
||||
}
|
||||
|
||||
// clone our file contents
|
||||
var contents;
|
||||
if (this.isStream()) {
|
||||
contents = this.contents.pipe(new Stream.PassThrough());
|
||||
this.contents = this.contents.pipe(new Stream.PassThrough());
|
||||
} else if (this.isBuffer()) {
|
||||
contents = opt.contents ? cloneBuffer(this.contents) : this.contents;
|
||||
}
|
||||
|
||||
var file = new File({
|
||||
cwd: this.cwd,
|
||||
base: this.base,
|
||||
stat: (this.stat ? cloneStats(this.stat) : null),
|
||||
history: this.history.slice(),
|
||||
contents: contents
|
||||
});
|
||||
|
||||
// clone our custom properties
|
||||
Object.keys(this).forEach(function(key) {
|
||||
// ignore built-in fields
|
||||
if (key === '_contents' || key === 'stat' ||
|
||||
key === 'history' || key === 'path' ||
|
||||
key === 'base' || key === 'cwd') {
|
||||
return;
|
||||
}
|
||||
file[key] = opt.deep ? clone(this[key], true) : this[key];
|
||||
}, this);
|
||||
return file;
|
||||
};
|
||||
|
||||
File.prototype.pipe = function(stream, opt) {
|
||||
if (!opt) opt = {};
|
||||
if (typeof opt.end === 'undefined') opt.end = true;
|
||||
|
||||
if (this.isStream()) {
|
||||
return this.contents.pipe(stream, opt);
|
||||
}
|
||||
if (this.isBuffer()) {
|
||||
if (opt.end) {
|
||||
stream.end(this.contents);
|
||||
} else {
|
||||
stream.write(this.contents);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
// isNull
|
||||
if (opt.end) stream.end();
|
||||
return stream;
|
||||
};
|
||||
|
||||
File.prototype.inspect = function() {
|
||||
var inspect = [];
|
||||
|
||||
// use relative path if possible
|
||||
var filePath = (this.base && this.path) ? this.relative : this.path;
|
||||
|
||||
if (filePath) {
|
||||
inspect.push('"'+filePath+'"');
|
||||
}
|
||||
|
||||
if (this.isBuffer()) {
|
||||
inspect.push(this.contents.inspect());
|
||||
}
|
||||
|
||||
if (this.isStream()) {
|
||||
inspect.push(inspectStream(this.contents));
|
||||
}
|
||||
|
||||
return '<File '+inspect.join(' ')+'>';
|
||||
};
|
||||
|
||||
// virtual attributes
|
||||
// or stuff with extra logic
|
||||
Object.defineProperty(File.prototype, 'contents', {
|
||||
get: function() {
|
||||
return this._contents;
|
||||
},
|
||||
set: function(val) {
|
||||
if (!isBuffer(val) && !isStream(val) && !isNull(val)) {
|
||||
throw new Error('File.contents can only be a Buffer, a Stream, or null.');
|
||||
}
|
||||
this._contents = val;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: should this be moved to vinyl-fs?
|
||||
Object.defineProperty(File.prototype, 'relative', {
|
||||
get: function() {
|
||||
if (!this.base) throw new Error('No base specified! Can not get relative.');
|
||||
if (!this.path) throw new Error('No path specified! Can not get relative.');
|
||||
return path.relative(this.base, this.path);
|
||||
},
|
||||
set: function() {
|
||||
throw new Error('File.relative is generated from the base and path attributes. Do not modify it.');
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(File.prototype, 'path', {
|
||||
get: function() {
|
||||
return this.history[this.history.length - 1];
|
||||
},
|
||||
set: function(path) {
|
||||
if (typeof path !== 'string') throw new Error('path should be string');
|
||||
|
||||
// record history only when path changed
|
||||
if (path && path !== this.path) {
|
||||
this.history.push(path);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = File;
|
||||
7
node_modules/decompress-targz/node_modules/vinyl/lib/cloneBuffer.js
generated
vendored
7
node_modules/decompress-targz/node_modules/vinyl/lib/cloneBuffer.js
generated
vendored
@@ -1,7 +0,0 @@
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
module.exports = function(buf) {
|
||||
var out = new Buffer(buf.length);
|
||||
buf.copy(out);
|
||||
return out;
|
||||
};
|
||||
11
node_modules/decompress-targz/node_modules/vinyl/lib/inspectStream.js
generated
vendored
11
node_modules/decompress-targz/node_modules/vinyl/lib/inspectStream.js
generated
vendored
@@ -1,11 +0,0 @@
|
||||
var isStream = require('./isStream');
|
||||
|
||||
module.exports = function(stream) {
|
||||
if (!isStream(stream)) return;
|
||||
|
||||
var streamType = stream.constructor.name;
|
||||
// avoid StreamStream
|
||||
if (streamType === 'Stream') streamType = '';
|
||||
|
||||
return '<'+streamType+'Stream>';
|
||||
};
|
||||
7
node_modules/decompress-targz/node_modules/vinyl/lib/isBuffer.js
generated
vendored
7
node_modules/decompress-targz/node_modules/vinyl/lib/isBuffer.js
generated
vendored
@@ -1,7 +0,0 @@
|
||||
var buf = require('buffer');
|
||||
var Buffer = buf.Buffer;
|
||||
|
||||
// could use Buffer.isBuffer but this is the same exact thing...
|
||||
module.exports = function(o) {
|
||||
return typeof o === 'object' && o instanceof Buffer;
|
||||
};
|
||||
3
node_modules/decompress-targz/node_modules/vinyl/lib/isNull.js
generated
vendored
3
node_modules/decompress-targz/node_modules/vinyl/lib/isNull.js
generated
vendored
@@ -1,3 +0,0 @@
|
||||
module.exports = function(v) {
|
||||
return v === null;
|
||||
};
|
||||
5
node_modules/decompress-targz/node_modules/vinyl/lib/isStream.js
generated
vendored
5
node_modules/decompress-targz/node_modules/vinyl/lib/isStream.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
var Stream = require('stream').Stream;
|
||||
|
||||
module.exports = function(o) {
|
||||
return !!o && o instanceof Stream;
|
||||
};
|
||||
42
node_modules/decompress-targz/node_modules/vinyl/package.json
generated
vendored
42
node_modules/decompress-targz/node_modules/vinyl/package.json
generated
vendored
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"name": "vinyl",
|
||||
"description": "A virtual file format",
|
||||
"version": "0.4.6",
|
||||
"homepage": "http://github.com/wearefractal/vinyl",
|
||||
"repository": "git://github.com/wearefractal/vinyl.git",
|
||||
"author": "Fractal <contact@wearefractal.com> (http://wearefractal.com/)",
|
||||
"main": "./index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"clone": "^0.2.0",
|
||||
"clone-stats": "^0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^2.0.0",
|
||||
"should": "^4.0.4",
|
||||
"mocha-lcov-reporter": "^0.0.1",
|
||||
"coveralls": "^2.6.1",
|
||||
"istanbul": "^0.3.0",
|
||||
"rimraf": "^2.2.5",
|
||||
"jshint": "^2.4.1",
|
||||
"buffer-equal": "0.0.1",
|
||||
"lodash.templatesettings": "^2.4.1",
|
||||
"event-stream": "^3.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec && jshint lib",
|
||||
"coveralls": "istanbul cover _mocha -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.9"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://github.com/wearefractal/vinyl/raw/master/LICENSE"
|
||||
}
|
||||
]
|
||||
}
|
||||
78
node_modules/decompress-targz/package.json
generated
vendored
78
node_modules/decompress-targz/package.json
generated
vendored
@@ -1,43 +1,39 @@
|
||||
{
|
||||
"name": "decompress-targz",
|
||||
"version": "3.1.0",
|
||||
"description": "decompress tar.gz plugin",
|
||||
"license": "MIT",
|
||||
"repository": "kevva/decompress-targz",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "https://github.com/kevva"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"decompress",
|
||||
"decompressplugin",
|
||||
"extract",
|
||||
"gulpplugin",
|
||||
"tar.gz",
|
||||
"targz"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-gzip": "^1.0.0",
|
||||
"object-assign": "^2.0.0",
|
||||
"strip-dirs": "^1.0.0",
|
||||
"tar-stream": "^1.1.1",
|
||||
"through2": "^0.6.1",
|
||||
"vinyl": "^0.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "0.0.4",
|
||||
"buffer-equal": "0.0.1",
|
||||
"is-jpg": "^1.0.0",
|
||||
"vinyl-file": "^1.1.0"
|
||||
}
|
||||
"name": "decompress-targz",
|
||||
"version": "4.1.1",
|
||||
"description": "decompress tar.gz plugin",
|
||||
"license": "MIT",
|
||||
"repository": "kevva/decompress-targz",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "https://github.com/kevva"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"decompress",
|
||||
"decompressplugin",
|
||||
"extract",
|
||||
"tar.gz",
|
||||
"targz"
|
||||
],
|
||||
"dependencies": {
|
||||
"decompress-tar": "^4.1.1",
|
||||
"file-type": "^5.2.0",
|
||||
"is-stream": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"is-jpg": "^1.0.0",
|
||||
"pify": "^3.0.0",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
|
||||
53
node_modules/decompress-targz/readme.md
generated
vendored
53
node_modules/decompress-targz/readme.md
generated
vendored
@@ -1,56 +1,43 @@
|
||||
# decompress-targz [](https://travis-ci.org/kevva/decompress-targz)
|
||||
# decompress-targz [](https://travis-ci.org/kevva/decompress-targz)
|
||||
|
||||
> tar.gz decompress plugin
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save decompress-targz
|
||||
```
|
||||
$ npm install decompress-targz
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var Decompress = require('decompress');
|
||||
var targz = require('decompress-targz');
|
||||
const decompress = require('decompress');
|
||||
const decompressTargz = require('decompress-targz');
|
||||
|
||||
var decompress = new Decompress()
|
||||
.src('foo.tar.gz')
|
||||
.dest('dest')
|
||||
.use(targz({strip: 1}));
|
||||
|
||||
decompress.run(function (err, files) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('Files extracted successfully!');
|
||||
decompress('unicorn.tar.gz', 'dist', {
|
||||
plugins: [
|
||||
decompressTargz()
|
||||
]
|
||||
}).then(() => {
|
||||
console.log('Files decompressed');
|
||||
});
|
||||
```
|
||||
|
||||
You can also use this plugin with [gulp](http://gulpjs.com):
|
||||
|
||||
```js
|
||||
var gulp = require('gulp');
|
||||
var targz = require('decompress-targz');
|
||||
var vinylAssign = require('vinyl-assign');
|
||||
## API
|
||||
|
||||
gulp.task('default', function () {
|
||||
return gulp.src('foo.tar.gz')
|
||||
.pipe(vinylAssign({extract: true}))
|
||||
.pipe(targz({strip: 1}))
|
||||
.pipe(gulp.dest('dest'));
|
||||
});
|
||||
```
|
||||
### decompressTargz()(input)
|
||||
|
||||
## Options
|
||||
Returns both a Promise for a Buffer and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
|
||||
|
||||
### strip
|
||||
#### input
|
||||
|
||||
Type: `Number`
|
||||
Default: `0`
|
||||
Type: `Buffer` `Stream`
|
||||
|
||||
Buffer or stream to decompress.
|
||||
|
||||
Equivalent to `--strip-components` for tar.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in New Issue
Block a user