mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2026-01-30 00:05:29 +08:00
add node_modules
This commit is contained in:
10
node_modules/ansi-regex/index.js
generated
vendored
Normal file
10
node_modules/ansi-regex/index.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = () => {
|
||||
const pattern = [
|
||||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)',
|
||||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'
|
||||
].join('|');
|
||||
|
||||
return new RegExp(pattern, 'g');
|
||||
};
|
||||
165
node_modules/ansi-styles/index.js
generated
vendored
Normal file
165
node_modules/ansi-styles/index.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
'use strict';
|
||||
const colorConvert = require('color-convert');
|
||||
|
||||
const wrapAnsi16 = (fn, offset) => function () {
|
||||
const code = fn.apply(colorConvert, arguments);
|
||||
return `\u001B[${code + offset}m`;
|
||||
};
|
||||
|
||||
const wrapAnsi256 = (fn, offset) => function () {
|
||||
const code = fn.apply(colorConvert, arguments);
|
||||
return `\u001B[${38 + offset};5;${code}m`;
|
||||
};
|
||||
|
||||
const wrapAnsi16m = (fn, offset) => function () {
|
||||
const rgb = fn.apply(colorConvert, arguments);
|
||||
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
||||
};
|
||||
|
||||
function assembleStyles() {
|
||||
const codes = new Map();
|
||||
const styles = {
|
||||
modifier: {
|
||||
reset: [0, 0],
|
||||
// 21 isn't widely supported and 22 does the same thing
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29]
|
||||
},
|
||||
color: {
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
gray: [90, 39],
|
||||
|
||||
// Bright color
|
||||
redBright: [91, 39],
|
||||
greenBright: [92, 39],
|
||||
yellowBright: [93, 39],
|
||||
blueBright: [94, 39],
|
||||
magentaBright: [95, 39],
|
||||
cyanBright: [96, 39],
|
||||
whiteBright: [97, 39]
|
||||
},
|
||||
bgColor: {
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
|
||||
// Bright color
|
||||
bgBlackBright: [100, 49],
|
||||
bgRedBright: [101, 49],
|
||||
bgGreenBright: [102, 49],
|
||||
bgYellowBright: [103, 49],
|
||||
bgBlueBright: [104, 49],
|
||||
bgMagentaBright: [105, 49],
|
||||
bgCyanBright: [106, 49],
|
||||
bgWhiteBright: [107, 49]
|
||||
}
|
||||
};
|
||||
|
||||
// Fix humans
|
||||
styles.color.grey = styles.color.gray;
|
||||
|
||||
for (const groupName of Object.keys(styles)) {
|
||||
const group = styles[groupName];
|
||||
|
||||
for (const styleName of Object.keys(group)) {
|
||||
const style = group[styleName];
|
||||
|
||||
styles[styleName] = {
|
||||
open: `\u001B[${style[0]}m`,
|
||||
close: `\u001B[${style[1]}m`
|
||||
};
|
||||
|
||||
group[styleName] = styles[styleName];
|
||||
|
||||
codes.set(style[0], style[1]);
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, groupName, {
|
||||
value: group,
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(styles, 'codes', {
|
||||
value: codes,
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
|
||||
const ansi2ansi = n => n;
|
||||
const rgb2rgb = (r, g, b) => [r, g, b];
|
||||
|
||||
styles.color.close = '\u001B[39m';
|
||||
styles.bgColor.close = '\u001B[49m';
|
||||
|
||||
styles.color.ansi = {
|
||||
ansi: wrapAnsi16(ansi2ansi, 0)
|
||||
};
|
||||
styles.color.ansi256 = {
|
||||
ansi256: wrapAnsi256(ansi2ansi, 0)
|
||||
};
|
||||
styles.color.ansi16m = {
|
||||
rgb: wrapAnsi16m(rgb2rgb, 0)
|
||||
};
|
||||
|
||||
styles.bgColor.ansi = {
|
||||
ansi: wrapAnsi16(ansi2ansi, 10)
|
||||
};
|
||||
styles.bgColor.ansi256 = {
|
||||
ansi256: wrapAnsi256(ansi2ansi, 10)
|
||||
};
|
||||
styles.bgColor.ansi16m = {
|
||||
rgb: wrapAnsi16m(rgb2rgb, 10)
|
||||
};
|
||||
|
||||
for (let key of Object.keys(colorConvert)) {
|
||||
if (typeof colorConvert[key] !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const suite = colorConvert[key];
|
||||
|
||||
if (key === 'ansi16') {
|
||||
key = 'ansi';
|
||||
}
|
||||
|
||||
if ('ansi16' in suite) {
|
||||
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
||||
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
||||
}
|
||||
|
||||
if ('ansi256' in suite) {
|
||||
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
||||
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
||||
}
|
||||
|
||||
if ('rgb' in suite) {
|
||||
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
||||
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
||||
}
|
||||
}
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
// Make the export immutable
|
||||
Object.defineProperty(module, 'exports', {
|
||||
enumerable: true,
|
||||
get: assembleStyles
|
||||
});
|
||||
59
node_modules/balanced-match/index.js
generated
vendored
Normal file
59
node_modules/balanced-match/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
module.exports = balanced;
|
||||
function balanced(a, b, str) {
|
||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
||||
if (b instanceof RegExp) b = maybeMatch(b, str);
|
||||
|
||||
var r = range(a, b, str);
|
||||
|
||||
return r && {
|
||||
start: r[0],
|
||||
end: r[1],
|
||||
pre: str.slice(0, r[0]),
|
||||
body: str.slice(r[0] + a.length, r[1]),
|
||||
post: str.slice(r[1] + b.length)
|
||||
};
|
||||
}
|
||||
|
||||
function maybeMatch(reg, str) {
|
||||
var m = str.match(reg);
|
||||
return m ? m[0] : null;
|
||||
}
|
||||
|
||||
balanced.range = range;
|
||||
function range(a, b, str) {
|
||||
var begs, beg, left, right, result;
|
||||
var ai = str.indexOf(a);
|
||||
var bi = str.indexOf(b, ai + 1);
|
||||
var i = ai;
|
||||
|
||||
if (ai >= 0 && bi > 0) {
|
||||
begs = [];
|
||||
left = str.length;
|
||||
|
||||
while (i >= 0 && !result) {
|
||||
if (i == ai) {
|
||||
begs.push(i);
|
||||
ai = str.indexOf(a, i + 1);
|
||||
} else if (begs.length == 1) {
|
||||
result = [ begs.pop(), bi ];
|
||||
} else {
|
||||
beg = begs.pop();
|
||||
if (beg < left) {
|
||||
left = beg;
|
||||
right = bi;
|
||||
}
|
||||
|
||||
bi = str.indexOf(b, i + 1);
|
||||
}
|
||||
|
||||
i = ai < bi && ai >= 0 ? ai : bi;
|
||||
}
|
||||
|
||||
if (begs.length) {
|
||||
result = [ left, right ];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
19
node_modules/base64-js/bench/bench.js
generated
vendored
Normal file
19
node_modules/base64-js/bench/bench.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var random = require('crypto').pseudoRandomBytes
|
||||
|
||||
var b64 = require('../')
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var data = random(1e6).toString('base64')
|
||||
//fs.readFileSync(path.join(__dirname, 'example.b64'), 'ascii').split('\n').join('')
|
||||
var start = Date.now()
|
||||
var raw = b64.toByteArray(data)
|
||||
var middle = Date.now()
|
||||
var data = b64.fromByteArray(raw)
|
||||
var end = Date.now()
|
||||
|
||||
console.log('decode ms, decode ops/ms, encode ms, encode ops/ms')
|
||||
console.log(
|
||||
middle - start, data.length / (middle - start),
|
||||
end - middle, data.length / (end - middle))
|
||||
//console.log(data)
|
||||
|
||||
124
node_modules/base64-js/lib/b64.js
generated
vendored
Normal file
124
node_modules/base64-js/lib/b64.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
|
||||
;(function (exports) {
|
||||
'use strict';
|
||||
|
||||
var Arr = (typeof Uint8Array !== 'undefined')
|
||||
? Uint8Array
|
||||
: Array
|
||||
|
||||
var PLUS = '+'.charCodeAt(0)
|
||||
var SLASH = '/'.charCodeAt(0)
|
||||
var NUMBER = '0'.charCodeAt(0)
|
||||
var LOWER = 'a'.charCodeAt(0)
|
||||
var UPPER = 'A'.charCodeAt(0)
|
||||
var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
||||
var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
||||
|
||||
function decode (elt) {
|
||||
var code = elt.charCodeAt(0)
|
||||
if (code === PLUS ||
|
||||
code === PLUS_URL_SAFE)
|
||||
return 62 // '+'
|
||||
if (code === SLASH ||
|
||||
code === SLASH_URL_SAFE)
|
||||
return 63 // '/'
|
||||
if (code < NUMBER)
|
||||
return -1 //no match
|
||||
if (code < NUMBER + 10)
|
||||
return code - NUMBER + 26 + 26
|
||||
if (code < UPPER + 26)
|
||||
return code - UPPER
|
||||
if (code < LOWER + 26)
|
||||
return code - LOWER + 26
|
||||
}
|
||||
|
||||
function b64ToByteArray (b64) {
|
||||
var i, j, l, tmp, placeHolders, arr
|
||||
|
||||
if (b64.length % 4 > 0) {
|
||||
throw new Error('Invalid string. Length must be a multiple of 4')
|
||||
}
|
||||
|
||||
// the number of equal signs (place holders)
|
||||
// if there are two placeholders, than the two characters before it
|
||||
// represent one byte
|
||||
// if there is only one, then the three characters before it represent 2 bytes
|
||||
// this is just a cheap hack to not do indexOf twice
|
||||
var len = b64.length
|
||||
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
||||
|
||||
// base64 is 4/3 + up to two characters of the original data
|
||||
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
||||
|
||||
// if there are placeholders, only get up to the last complete 4 chars
|
||||
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
||||
|
||||
var L = 0
|
||||
|
||||
function push (v) {
|
||||
arr[L++] = v
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
||||
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
||||
push((tmp & 0xFF0000) >> 16)
|
||||
push((tmp & 0xFF00) >> 8)
|
||||
push(tmp & 0xFF)
|
||||
}
|
||||
|
||||
if (placeHolders === 2) {
|
||||
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
||||
push(tmp & 0xFF)
|
||||
} else if (placeHolders === 1) {
|
||||
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
||||
push((tmp >> 8) & 0xFF)
|
||||
push(tmp & 0xFF)
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
function uint8ToBase64 (uint8) {
|
||||
var i,
|
||||
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
||||
output = "",
|
||||
temp, length
|
||||
|
||||
function encode (num) {
|
||||
return lookup.charAt(num)
|
||||
}
|
||||
|
||||
function tripletToBase64 (num) {
|
||||
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
||||
}
|
||||
|
||||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||||
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
||||
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
||||
output += tripletToBase64(temp)
|
||||
}
|
||||
|
||||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||||
switch (extraBytes) {
|
||||
case 1:
|
||||
temp = uint8[uint8.length - 1]
|
||||
output += encode(temp >> 2)
|
||||
output += encode((temp << 4) & 0x3F)
|
||||
output += '=='
|
||||
break
|
||||
case 2:
|
||||
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
||||
output += encode(temp >> 10)
|
||||
output += encode((temp >> 4) & 0x3F)
|
||||
output += encode((temp << 2) & 0x3F)
|
||||
output += '='
|
||||
break
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
exports.toByteArray = b64ToByteArray
|
||||
exports.fromByteArray = uint8ToBase64
|
||||
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
||||
281
node_modules/bl/bl.js
generated
vendored
Normal file
281
node_modules/bl/bl.js
generated
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
var DuplexStream = require('readable-stream/duplex')
|
||||
, util = require('util')
|
||||
, Buffer = require('safe-buffer').Buffer
|
||||
|
||||
|
||||
function BufferList (callback) {
|
||||
if (!(this instanceof BufferList))
|
||||
return new BufferList(callback)
|
||||
|
||||
this._bufs = []
|
||||
this.length = 0
|
||||
|
||||
if (typeof callback == 'function') {
|
||||
this._callback = callback
|
||||
|
||||
var piper = function piper (err) {
|
||||
if (this._callback) {
|
||||
this._callback(err)
|
||||
this._callback = null
|
||||
}
|
||||
}.bind(this)
|
||||
|
||||
this.on('pipe', function onPipe (src) {
|
||||
src.on('error', piper)
|
||||
})
|
||||
this.on('unpipe', function onUnpipe (src) {
|
||||
src.removeListener('error', piper)
|
||||
})
|
||||
} else {
|
||||
this.append(callback)
|
||||
}
|
||||
|
||||
DuplexStream.call(this)
|
||||
}
|
||||
|
||||
|
||||
util.inherits(BufferList, DuplexStream)
|
||||
|
||||
|
||||
BufferList.prototype._offset = function _offset (offset) {
|
||||
var tot = 0, i = 0, _t
|
||||
if (offset === 0) return [ 0, 0 ]
|
||||
for (; i < this._bufs.length; i++) {
|
||||
_t = tot + this._bufs[i].length
|
||||
if (offset < _t || i == this._bufs.length - 1)
|
||||
return [ i, offset - tot ]
|
||||
tot = _t
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype.append = function append (buf) {
|
||||
var i = 0
|
||||
|
||||
if (Buffer.isBuffer(buf)) {
|
||||
this._appendBuffer(buf);
|
||||
} else if (Array.isArray(buf)) {
|
||||
for (; i < buf.length; i++)
|
||||
this.append(buf[i])
|
||||
} else if (buf instanceof BufferList) {
|
||||
// unwrap argument into individual BufferLists
|
||||
for (; i < buf._bufs.length; i++)
|
||||
this.append(buf._bufs[i])
|
||||
} else if (buf != null) {
|
||||
// coerce number arguments to strings, since Buffer(number) does
|
||||
// uninitialized memory allocation
|
||||
if (typeof buf == 'number')
|
||||
buf = buf.toString()
|
||||
|
||||
this._appendBuffer(Buffer.from(buf));
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype._appendBuffer = function appendBuffer (buf) {
|
||||
this._bufs.push(buf)
|
||||
this.length += buf.length
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype._write = function _write (buf, encoding, callback) {
|
||||
this._appendBuffer(buf)
|
||||
|
||||
if (typeof callback == 'function')
|
||||
callback()
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype._read = function _read (size) {
|
||||
if (!this.length)
|
||||
return this.push(null)
|
||||
|
||||
size = Math.min(size, this.length)
|
||||
this.push(this.slice(0, size))
|
||||
this.consume(size)
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype.end = function end (chunk) {
|
||||
DuplexStream.prototype.end.call(this, chunk)
|
||||
|
||||
if (this._callback) {
|
||||
this._callback(null, this.slice())
|
||||
this._callback = null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype.get = function get (index) {
|
||||
return this.slice(index, index + 1)[0]
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype.slice = function slice (start, end) {
|
||||
if (typeof start == 'number' && start < 0)
|
||||
start += this.length
|
||||
if (typeof end == 'number' && end < 0)
|
||||
end += this.length
|
||||
return this.copy(null, 0, start, end)
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
|
||||
if (typeof srcStart != 'number' || srcStart < 0)
|
||||
srcStart = 0
|
||||
if (typeof srcEnd != 'number' || srcEnd > this.length)
|
||||
srcEnd = this.length
|
||||
if (srcStart >= this.length)
|
||||
return dst || Buffer.alloc(0)
|
||||
if (srcEnd <= 0)
|
||||
return dst || Buffer.alloc(0)
|
||||
|
||||
var copy = !!dst
|
||||
, off = this._offset(srcStart)
|
||||
, len = srcEnd - srcStart
|
||||
, bytes = len
|
||||
, bufoff = (copy && dstStart) || 0
|
||||
, start = off[1]
|
||||
, l
|
||||
, i
|
||||
|
||||
// copy/slice everything
|
||||
if (srcStart === 0 && srcEnd == this.length) {
|
||||
if (!copy) { // slice, but full concat if multiple buffers
|
||||
return this._bufs.length === 1
|
||||
? this._bufs[0]
|
||||
: Buffer.concat(this._bufs, this.length)
|
||||
}
|
||||
|
||||
// copy, need to copy individual buffers
|
||||
for (i = 0; i < this._bufs.length; i++) {
|
||||
this._bufs[i].copy(dst, bufoff)
|
||||
bufoff += this._bufs[i].length
|
||||
}
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
// easy, cheap case where it's a subset of one of the buffers
|
||||
if (bytes <= this._bufs[off[0]].length - start) {
|
||||
return copy
|
||||
? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
|
||||
: this._bufs[off[0]].slice(start, start + bytes)
|
||||
}
|
||||
|
||||
if (!copy) // a slice, we need something to copy in to
|
||||
dst = Buffer.allocUnsafe(len)
|
||||
|
||||
for (i = off[0]; i < this._bufs.length; i++) {
|
||||
l = this._bufs[i].length - start
|
||||
|
||||
if (bytes > l) {
|
||||
this._bufs[i].copy(dst, bufoff, start)
|
||||
} else {
|
||||
this._bufs[i].copy(dst, bufoff, start, start + bytes)
|
||||
break
|
||||
}
|
||||
|
||||
bufoff += l
|
||||
bytes -= l
|
||||
|
||||
if (start)
|
||||
start = 0
|
||||
}
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
|
||||
start = start || 0
|
||||
end = end || this.length
|
||||
|
||||
if (start < 0)
|
||||
start += this.length
|
||||
if (end < 0)
|
||||
end += this.length
|
||||
|
||||
var startOffset = this._offset(start)
|
||||
, endOffset = this._offset(end)
|
||||
, buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
|
||||
|
||||
if (endOffset[1] == 0)
|
||||
buffers.pop()
|
||||
else
|
||||
buffers[buffers.length-1] = buffers[buffers.length-1].slice(0, endOffset[1])
|
||||
|
||||
if (startOffset[1] != 0)
|
||||
buffers[0] = buffers[0].slice(startOffset[1])
|
||||
|
||||
return new BufferList(buffers)
|
||||
}
|
||||
|
||||
BufferList.prototype.toString = function toString (encoding, start, end) {
|
||||
return this.slice(start, end).toString(encoding)
|
||||
}
|
||||
|
||||
BufferList.prototype.consume = function consume (bytes) {
|
||||
while (this._bufs.length) {
|
||||
if (bytes >= this._bufs[0].length) {
|
||||
bytes -= this._bufs[0].length
|
||||
this.length -= this._bufs[0].length
|
||||
this._bufs.shift()
|
||||
} else {
|
||||
this._bufs[0] = this._bufs[0].slice(bytes)
|
||||
this.length -= bytes
|
||||
break
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype.duplicate = function duplicate () {
|
||||
var i = 0
|
||||
, copy = new BufferList()
|
||||
|
||||
for (; i < this._bufs.length; i++)
|
||||
copy.append(this._bufs[i])
|
||||
|
||||
return copy
|
||||
}
|
||||
|
||||
|
||||
BufferList.prototype.destroy = function destroy () {
|
||||
this._bufs.length = 0
|
||||
this.length = 0
|
||||
this.push(null)
|
||||
}
|
||||
|
||||
|
||||
;(function () {
|
||||
var methods = {
|
||||
'readDoubleBE' : 8
|
||||
, 'readDoubleLE' : 8
|
||||
, 'readFloatBE' : 4
|
||||
, 'readFloatLE' : 4
|
||||
, 'readInt32BE' : 4
|
||||
, 'readInt32LE' : 4
|
||||
, 'readUInt32BE' : 4
|
||||
, 'readUInt32LE' : 4
|
||||
, 'readInt16BE' : 2
|
||||
, 'readInt16LE' : 2
|
||||
, 'readUInt16BE' : 2
|
||||
, 'readUInt16LE' : 2
|
||||
, 'readInt8' : 1
|
||||
, 'readUInt8' : 1
|
||||
}
|
||||
|
||||
for (var m in methods) {
|
||||
(function (m) {
|
||||
BufferList.prototype[m] = function (offset) {
|
||||
return this.slice(offset, offset + methods[m])[m](0)
|
||||
}
|
||||
}(m))
|
||||
}
|
||||
}())
|
||||
|
||||
|
||||
module.exports = BufferList
|
||||
201
node_modules/brace-expansion/index.js
generated
vendored
Normal file
201
node_modules/brace-expansion/index.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
var concatMap = require('concat-map');
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
module.exports = expandTop;
|
||||
|
||||
var escSlash = '\0SLASH'+Math.random()+'\0';
|
||||
var escOpen = '\0OPEN'+Math.random()+'\0';
|
||||
var escClose = '\0CLOSE'+Math.random()+'\0';
|
||||
var escComma = '\0COMMA'+Math.random()+'\0';
|
||||
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
||||
|
||||
function numeric(str) {
|
||||
return parseInt(str, 10) == str
|
||||
? parseInt(str, 10)
|
||||
: str.charCodeAt(0);
|
||||
}
|
||||
|
||||
function escapeBraces(str) {
|
||||
return str.split('\\\\').join(escSlash)
|
||||
.split('\\{').join(escOpen)
|
||||
.split('\\}').join(escClose)
|
||||
.split('\\,').join(escComma)
|
||||
.split('\\.').join(escPeriod);
|
||||
}
|
||||
|
||||
function unescapeBraces(str) {
|
||||
return str.split(escSlash).join('\\')
|
||||
.split(escOpen).join('{')
|
||||
.split(escClose).join('}')
|
||||
.split(escComma).join(',')
|
||||
.split(escPeriod).join('.');
|
||||
}
|
||||
|
||||
|
||||
// Basically just str.split(","), but handling cases
|
||||
// where we have nested braced sections, which should be
|
||||
// treated as individual members, like {a,{b,c},d}
|
||||
function parseCommaParts(str) {
|
||||
if (!str)
|
||||
return [''];
|
||||
|
||||
var parts = [];
|
||||
var m = balanced('{', '}', str);
|
||||
|
||||
if (!m)
|
||||
return str.split(',');
|
||||
|
||||
var pre = m.pre;
|
||||
var body = m.body;
|
||||
var post = m.post;
|
||||
var p = pre.split(',');
|
||||
|
||||
p[p.length-1] += '{' + body + '}';
|
||||
var postParts = parseCommaParts(post);
|
||||
if (post.length) {
|
||||
p[p.length-1] += postParts.shift();
|
||||
p.push.apply(p, postParts);
|
||||
}
|
||||
|
||||
parts.push.apply(parts, p);
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
function expandTop(str) {
|
||||
if (!str)
|
||||
return [];
|
||||
|
||||
// I don't know why Bash 4.3 does this, but it does.
|
||||
// Anything starting with {} will have the first two bytes preserved
|
||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||
// but a{},b}c will be expanded to [a}c,abc].
|
||||
// One could argue that this is a bug in Bash, but since the goal of
|
||||
// this module is to match Bash's rules, we escape a leading {}
|
||||
if (str.substr(0, 2) === '{}') {
|
||||
str = '\\{\\}' + str.substr(2);
|
||||
}
|
||||
|
||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
||||
}
|
||||
|
||||
function identity(e) {
|
||||
return e;
|
||||
}
|
||||
|
||||
function embrace(str) {
|
||||
return '{' + str + '}';
|
||||
}
|
||||
function isPadded(el) {
|
||||
return /^-?0\d/.test(el);
|
||||
}
|
||||
|
||||
function lte(i, y) {
|
||||
return i <= y;
|
||||
}
|
||||
function gte(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
|
||||
function expand(str, isTop) {
|
||||
var expansions = [];
|
||||
|
||||
var m = balanced('{', '}', str);
|
||||
if (!m || /\$$/.test(m.pre)) return [str];
|
||||
|
||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isSequence = isNumericSequence || isAlphaSequence;
|
||||
var isOptions = m.body.indexOf(',') >= 0;
|
||||
if (!isSequence && !isOptions) {
|
||||
// {a},b}
|
||||
if (m.post.match(/,.*\}/)) {
|
||||
str = m.pre + '{' + m.body + escClose + m.post;
|
||||
return expand(str);
|
||||
}
|
||||
return [str];
|
||||
}
|
||||
|
||||
var n;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
} else {
|
||||
n = parseCommaParts(m.body);
|
||||
if (n.length === 1) {
|
||||
// x{{a,b}}y ==> x{a}y x{b}y
|
||||
n = expand(n[0], false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// at this point, n is the parts, and we know it's not a comma set
|
||||
// with a single entry.
|
||||
|
||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
||||
var pre = m.pre;
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
|
||||
var N;
|
||||
|
||||
if (isSequence) {
|
||||
var x = numeric(n[0]);
|
||||
var y = numeric(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length)
|
||||
var incr = n.length == 3
|
||||
? Math.abs(numeric(n[2]))
|
||||
: 1;
|
||||
var test = lte;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte;
|
||||
}
|
||||
var pad = n.some(isPadded);
|
||||
|
||||
N = [];
|
||||
|
||||
for (var i = x; test(i, y); i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === '\\')
|
||||
c = '';
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join('0');
|
||||
if (i < 0)
|
||||
c = '-' + z + c.slice(1);
|
||||
else
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = concatMap(n, function(el) { return expand(el, false) });
|
||||
}
|
||||
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
}
|
||||
}
|
||||
|
||||
return expansions;
|
||||
}
|
||||
|
||||
17
node_modules/buffer-alloc-unsafe/index.js
generated
vendored
Normal file
17
node_modules/buffer-alloc-unsafe/index.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
function allocUnsafe (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('"size" argument must be a number')
|
||||
}
|
||||
|
||||
if (size < 0) {
|
||||
throw new RangeError('"size" argument must not be negative')
|
||||
}
|
||||
|
||||
if (Buffer.allocUnsafe) {
|
||||
return Buffer.allocUnsafe(size)
|
||||
} else {
|
||||
return new Buffer(size)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = allocUnsafe
|
||||
32
node_modules/buffer-alloc/index.js
generated
vendored
Normal file
32
node_modules/buffer-alloc/index.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var bufferFill = require('buffer-fill')
|
||||
var allocUnsafe = require('buffer-alloc-unsafe')
|
||||
|
||||
module.exports = function alloc (size, fill, encoding) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('"size" argument must be a number')
|
||||
}
|
||||
|
||||
if (size < 0) {
|
||||
throw new RangeError('"size" argument must not be negative')
|
||||
}
|
||||
|
||||
if (Buffer.alloc) {
|
||||
return Buffer.alloc(size, fill, encoding)
|
||||
}
|
||||
|
||||
var buffer = allocUnsafe(size)
|
||||
|
||||
if (size === 0) {
|
||||
return buffer
|
||||
}
|
||||
|
||||
if (fill === undefined) {
|
||||
return bufferFill(buffer, 0)
|
||||
}
|
||||
|
||||
if (typeof encoding !== 'string') {
|
||||
encoding = undefined
|
||||
}
|
||||
|
||||
return bufferFill(buffer, fill, encoding)
|
||||
}
|
||||
111
node_modules/buffer-crc32/index.js
generated
vendored
Normal file
111
node_modules/buffer-crc32/index.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
var CRC_TABLE = [
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
||||
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
||||
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
||||
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
||||
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
||||
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
||||
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
||||
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
||||
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
||||
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
||||
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
||||
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
||||
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
||||
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
||||
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
||||
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
||||
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
||||
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
||||
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
||||
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
||||
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
||||
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
||||
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
||||
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
||||
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
||||
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
||||
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
||||
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
||||
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
||||
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
||||
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
||||
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
||||
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
||||
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
||||
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
||||
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
||||
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
||||
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
||||
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
||||
0x2d02ef8d
|
||||
];
|
||||
|
||||
if (typeof Int32Array !== 'undefined') {
|
||||
CRC_TABLE = new Int32Array(CRC_TABLE);
|
||||
}
|
||||
|
||||
function ensureBuffer(input) {
|
||||
if (Buffer.isBuffer(input)) {
|
||||
return input;
|
||||
}
|
||||
|
||||
var hasNewBufferAPI =
|
||||
typeof Buffer.alloc === "function" &&
|
||||
typeof Buffer.from === "function";
|
||||
|
||||
if (typeof input === "number") {
|
||||
return hasNewBufferAPI ? Buffer.alloc(input) : new Buffer(input);
|
||||
}
|
||||
else if (typeof input === "string") {
|
||||
return hasNewBufferAPI ? Buffer.from(input) : new Buffer(input);
|
||||
}
|
||||
else {
|
||||
throw new Error("input must be buffer, number, or string, received " +
|
||||
typeof input);
|
||||
}
|
||||
}
|
||||
|
||||
function bufferizeInt(num) {
|
||||
var tmp = ensureBuffer(4);
|
||||
tmp.writeInt32BE(num, 0);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
function _crc32(buf, previous) {
|
||||
buf = ensureBuffer(buf);
|
||||
if (Buffer.isBuffer(previous)) {
|
||||
previous = previous.readUInt32BE(0);
|
||||
}
|
||||
var crc = ~~previous ^ -1;
|
||||
for (var n = 0; n < buf.length; n++) {
|
||||
crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
|
||||
}
|
||||
return (crc ^ -1);
|
||||
}
|
||||
|
||||
function crc32() {
|
||||
return bufferizeInt(_crc32.apply(null, arguments));
|
||||
}
|
||||
crc32.signed = function () {
|
||||
return _crc32.apply(null, arguments);
|
||||
};
|
||||
crc32.unsigned = function () {
|
||||
return _crc32.apply(null, arguments) >>> 0;
|
||||
};
|
||||
|
||||
module.exports = crc32;
|
||||
113
node_modules/buffer-fill/index.js
generated
vendored
Normal file
113
node_modules/buffer-fill/index.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/* Node.js 6.4.0 and up has full support */
|
||||
var hasFullSupport = (function () {
|
||||
try {
|
||||
if (!Buffer.isEncoding('latin1')) {
|
||||
return false
|
||||
}
|
||||
|
||||
var buf = Buffer.alloc ? Buffer.alloc(4) : new Buffer(4)
|
||||
|
||||
buf.fill('ab', 'ucs2')
|
||||
|
||||
return (buf.toString('hex') === '61006200')
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
}())
|
||||
|
||||
function isSingleByte (val) {
|
||||
return (val.length === 1 && val.charCodeAt(0) < 256)
|
||||
}
|
||||
|
||||
function fillWithNumber (buffer, val, start, end) {
|
||||
if (start < 0 || end > buffer.length) {
|
||||
throw new RangeError('Out of range index')
|
||||
}
|
||||
|
||||
start = start >>> 0
|
||||
end = end === undefined ? buffer.length : end >>> 0
|
||||
|
||||
if (end > start) {
|
||||
buffer.fill(val, start, end)
|
||||
}
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
function fillWithBuffer (buffer, val, start, end) {
|
||||
if (start < 0 || end > buffer.length) {
|
||||
throw new RangeError('Out of range index')
|
||||
}
|
||||
|
||||
if (end <= start) {
|
||||
return buffer
|
||||
}
|
||||
|
||||
start = start >>> 0
|
||||
end = end === undefined ? buffer.length : end >>> 0
|
||||
|
||||
var pos = start
|
||||
var len = val.length
|
||||
while (pos <= (end - len)) {
|
||||
val.copy(buffer, pos)
|
||||
pos += len
|
||||
}
|
||||
|
||||
if (pos !== end) {
|
||||
val.copy(buffer, pos, 0, end - pos)
|
||||
}
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
function fill (buffer, val, start, end, encoding) {
|
||||
if (hasFullSupport) {
|
||||
return buffer.fill(val, start, end, encoding)
|
||||
}
|
||||
|
||||
if (typeof val === 'number') {
|
||||
return fillWithNumber(buffer, val, start, end)
|
||||
}
|
||||
|
||||
if (typeof val === 'string') {
|
||||
if (typeof start === 'string') {
|
||||
encoding = start
|
||||
start = 0
|
||||
end = buffer.length
|
||||
} else if (typeof end === 'string') {
|
||||
encoding = end
|
||||
end = buffer.length
|
||||
}
|
||||
|
||||
if (encoding !== undefined && typeof encoding !== 'string') {
|
||||
throw new TypeError('encoding must be a string')
|
||||
}
|
||||
|
||||
if (encoding === 'latin1') {
|
||||
encoding = 'binary'
|
||||
}
|
||||
|
||||
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
||||
throw new TypeError('Unknown encoding: ' + encoding)
|
||||
}
|
||||
|
||||
if (val === '') {
|
||||
return fillWithNumber(buffer, 0, start, end)
|
||||
}
|
||||
|
||||
if (isSingleByte(val)) {
|
||||
return fillWithNumber(buffer, val.charCodeAt(0), start, end)
|
||||
}
|
||||
|
||||
val = new Buffer(val, encoding)
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(val)) {
|
||||
return fillWithBuffer(buffer, val, start, end)
|
||||
}
|
||||
|
||||
// Other values (e.g. undefined, boolean, object) results in zero-fill
|
||||
return fillWithNumber(buffer, 0, start, end)
|
||||
}
|
||||
|
||||
module.exports = fill
|
||||
126
node_modules/buffer/bin/download-node-tests.js
generated
vendored
Executable file
126
node_modules/buffer/bin/download-node-tests.js
generated
vendored
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var concat = require('concat-stream')
|
||||
var fs = require('fs')
|
||||
var hyperquest = require('hyperquest')
|
||||
var cp = require('child_process')
|
||||
var split = require('split')
|
||||
var through = require('through2')
|
||||
|
||||
var url = 'https://api.github.com/repos/nodejs/io.js/contents'
|
||||
var dirs = [
|
||||
'/test/parallel',
|
||||
'/test/pummel'
|
||||
]
|
||||
|
||||
cp.execSync('rm -rf node/*.js', { cwd: __dirname + '/../test' })
|
||||
cp.execSync('rm -rf node-es6/*.js', { cwd: __dirname + '/../test' })
|
||||
|
||||
var httpOpts = {
|
||||
headers: {
|
||||
'User-Agent': null
|
||||
// auth if github rate-limits you...
|
||||
// 'Authorization': 'Basic ' + Buffer('username:password').toString('base64'),
|
||||
}
|
||||
}
|
||||
|
||||
dirs.forEach(function (dir) {
|
||||
var req = hyperquest(url + dir, httpOpts)
|
||||
req.pipe(concat(function (data) {
|
||||
if (req.response.statusCode !== 200) {
|
||||
throw new Error(url + dir + ': ' + data.toString())
|
||||
}
|
||||
downloadBufferTests(dir, JSON.parse(data))
|
||||
}))
|
||||
})
|
||||
|
||||
function downloadBufferTests (dir, files) {
|
||||
files.forEach(function (file) {
|
||||
if (!/test-buffer.*/.test(file.name)) return
|
||||
|
||||
var path
|
||||
if (file.name === 'test-buffer-iterator.js' ||
|
||||
file.name === 'test-buffer-arraybuffer.js') {
|
||||
path = __dirname + '/../test/node-es6/' + file.name
|
||||
} else if (file.name === 'test-buffer-fakes.js') {
|
||||
// These teses only apply to node, where they're calling into C++ and need to
|
||||
// ensure the prototype can't be faked, or else there will be a segfault.
|
||||
return
|
||||
} else {
|
||||
path = __dirname + '/../test/node/' + file.name
|
||||
}
|
||||
|
||||
console.log(file.download_url)
|
||||
hyperquest(file.download_url, httpOpts)
|
||||
.pipe(split())
|
||||
.pipe(testfixer(file.name))
|
||||
.pipe(fs.createWriteStream(path))
|
||||
.on('finish', function () {
|
||||
console.log('wrote ' + file.name)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function testfixer (filename) {
|
||||
var firstline = true
|
||||
|
||||
return through(function (line, enc, cb) {
|
||||
line = line.toString()
|
||||
|
||||
if (firstline) {
|
||||
// require buffer explicitly
|
||||
var preamble = 'if (process.env.OBJECT_IMPL) global.TYPED_ARRAY_SUPPORT = false;\n' +
|
||||
'var Buffer = require(\'../../\').Buffer;'
|
||||
if (/use strict/.test(line)) line += '\n' + preamble
|
||||
else line + preamble + '\n' + line
|
||||
firstline = false
|
||||
}
|
||||
|
||||
// use `var` instead of `const`/`let`
|
||||
line = line.replace(/(const|let) /g, 'var ')
|
||||
|
||||
// make `require('common')` work
|
||||
line = line.replace(/(var common = require.*)/g, 'var common = {};')
|
||||
|
||||
// use `Buffer.isBuffer` instead of `instanceof Buffer`
|
||||
line = line.replace(/buf instanceof Buffer/g, 'Buffer.isBuffer(buf)')
|
||||
|
||||
// require browser buffer
|
||||
line = line.replace(/(.*)require\('buffer'\)(.*)/g, '$1require(\'../../\')$2')
|
||||
|
||||
// smalloc is only used for kMaxLength
|
||||
line = line.replace(
|
||||
/require\('smalloc'\)/g,
|
||||
'{ kMaxLength: process.env.OBJECT_IMPL ? 0x3fffffff : 0x7fffffff }'
|
||||
)
|
||||
|
||||
// comment out console logs
|
||||
line = line.replace(/(.*console\..*)/g, '// $1')
|
||||
|
||||
// we can't reliably test typed array max-sizes in the browser
|
||||
if (filename === 'test-buffer-big.js') {
|
||||
line = line.replace(/(.*new Int8Array.*RangeError.*)/, '// $1')
|
||||
line = line.replace(/(.*new ArrayBuffer.*RangeError.*)/, '// $1')
|
||||
line = line.replace(/(.*new Float64Array.*RangeError.*)/, '// $1')
|
||||
}
|
||||
|
||||
// https://github.com/iojs/io.js/blob/v0.12/test/parallel/test-buffer.js#L38
|
||||
// we can't run this because we need to support
|
||||
// browsers that don't have typed arrays
|
||||
if (filename === 'test-buffer.js') {
|
||||
line = line.replace(/b\[0\] = -1;/, 'b[0] = 255;')
|
||||
}
|
||||
|
||||
// https://github.com/iojs/io.js/blob/v0.12/test/parallel/test-buffer.js#L1138
|
||||
// unfortunately we can't run this as it touches
|
||||
// node streams which do an instanceof check
|
||||
// and crypto-browserify doesn't work in old
|
||||
// versions of ie
|
||||
if (filename === 'test-buffer.js') {
|
||||
line = line.replace(/^(\s*)(var crypto = require.*)/, '$1// $2')
|
||||
line = line.replace(/(crypto.createHash.*\))/, '1 /*$1*/')
|
||||
}
|
||||
|
||||
cb(null, line + '\n')
|
||||
})
|
||||
}
|
||||
18
node_modules/buffer/bin/test.js
generated
vendored
Normal file
18
node_modules/buffer/bin/test.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cp = require('child_process')
|
||||
|
||||
var runBrowserTests = !process.env.TRAVIS_PULL_REQUEST ||
|
||||
process.env.TRAVIS_PULL_REQUEST === 'false'
|
||||
|
||||
var node = cp.spawn('npm', ['run', 'test-node'], { stdio: 'inherit' })
|
||||
node.on('close', function (code) {
|
||||
if (code === 0 && runBrowserTests) {
|
||||
var browser = cp.spawn('npm', ['run', 'test-browser'], { stdio: 'inherit' })
|
||||
browser.on('close', function (code) {
|
||||
process.exit(code)
|
||||
})
|
||||
} else {
|
||||
process.exit(code)
|
||||
}
|
||||
})
|
||||
1548
node_modules/buffer/index.js
generated
vendored
Normal file
1548
node_modules/buffer/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18
node_modules/capture-stack-trace/index.js
generated
vendored
Normal file
18
node_modules/capture-stack-trace/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = Error.captureStackTrace || function (error) {
|
||||
var container = new Error();
|
||||
|
||||
Object.defineProperty(error, 'stack', {
|
||||
configurable: true,
|
||||
get: function getStack() {
|
||||
var stack = container.stack;
|
||||
|
||||
Object.defineProperty(this, 'stack', {
|
||||
value: stack
|
||||
});
|
||||
|
||||
return stack;
|
||||
}
|
||||
});
|
||||
};
|
||||
37
node_modules/caw/index.js
generated
vendored
Normal file
37
node_modules/caw/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
const url = require('url');
|
||||
const getProxy = require('get-proxy');
|
||||
const isurl = require('isurl');
|
||||
const tunnelAgent = require('tunnel-agent');
|
||||
const urlToOptions = require('url-to-options');
|
||||
|
||||
module.exports = (proxy, opts) => {
|
||||
proxy = proxy || getProxy();
|
||||
opts = Object.assign({}, opts);
|
||||
|
||||
if (typeof proxy === 'object') {
|
||||
opts = proxy;
|
||||
proxy = getProxy();
|
||||
}
|
||||
|
||||
if (!proxy) {
|
||||
return null;
|
||||
}
|
||||
|
||||
proxy = isurl.lenient(proxy) ? urlToOptions(proxy) : url.parse(proxy);
|
||||
|
||||
const uriProtocol = opts.protocol === 'https' ? 'https' : 'http';
|
||||
const proxyProtocol = proxy.protocol === 'https:' ? 'Https' : 'Http';
|
||||
const port = proxy.port || (proxyProtocol === 'Https' ? 443 : 80);
|
||||
const method = `${uriProtocol}Over${proxyProtocol}`;
|
||||
|
||||
delete opts.protocol;
|
||||
|
||||
return tunnelAgent[method](Object.assign({
|
||||
proxy: {
|
||||
port,
|
||||
host: proxy.hostname,
|
||||
proxyAuth: proxy.auth
|
||||
}
|
||||
}, opts));
|
||||
};
|
||||
228
node_modules/chalk/index.js
generated
vendored
Normal file
228
node_modules/chalk/index.js
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
'use strict';
|
||||
const escapeStringRegexp = require('escape-string-regexp');
|
||||
const ansiStyles = require('ansi-styles');
|
||||
const stdoutColor = require('supports-color').stdout;
|
||||
|
||||
const template = require('./templates.js');
|
||||
|
||||
const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
|
||||
|
||||
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
||||
const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
|
||||
|
||||
// `color-convert` models to exclude from the Chalk API due to conflicts and such
|
||||
const skipModels = new Set(['gray']);
|
||||
|
||||
const styles = Object.create(null);
|
||||
|
||||
function applyOptions(obj, options) {
|
||||
options = options || {};
|
||||
|
||||
// Detect level if not set manually
|
||||
const scLevel = stdoutColor ? stdoutColor.level : 0;
|
||||
obj.level = options.level === undefined ? scLevel : options.level;
|
||||
obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
|
||||
}
|
||||
|
||||
function Chalk(options) {
|
||||
// We check for this.template here since calling `chalk.constructor()`
|
||||
// by itself will have a `this` of a previously constructed chalk object
|
||||
if (!this || !(this instanceof Chalk) || this.template) {
|
||||
const chalk = {};
|
||||
applyOptions(chalk, options);
|
||||
|
||||
chalk.template = function () {
|
||||
const args = [].slice.call(arguments);
|
||||
return chalkTag.apply(null, [chalk.template].concat(args));
|
||||
};
|
||||
|
||||
Object.setPrototypeOf(chalk, Chalk.prototype);
|
||||
Object.setPrototypeOf(chalk.template, chalk);
|
||||
|
||||
chalk.template.constructor = Chalk;
|
||||
|
||||
return chalk.template;
|
||||
}
|
||||
|
||||
applyOptions(this, options);
|
||||
}
|
||||
|
||||
// Use bright blue on Windows as the normal blue color is illegible
|
||||
if (isSimpleWindowsTerm) {
|
||||
ansiStyles.blue.open = '\u001B[94m';
|
||||
}
|
||||
|
||||
for (const key of Object.keys(ansiStyles)) {
|
||||
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
|
||||
|
||||
styles[key] = {
|
||||
get() {
|
||||
const codes = ansiStyles[key];
|
||||
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
styles.visible = {
|
||||
get() {
|
||||
return build.call(this, this._styles || [], true, 'visible');
|
||||
}
|
||||
};
|
||||
|
||||
ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
|
||||
for (const model of Object.keys(ansiStyles.color.ansi)) {
|
||||
if (skipModels.has(model)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
styles[model] = {
|
||||
get() {
|
||||
const level = this.level;
|
||||
return function () {
|
||||
const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
|
||||
const codes = {
|
||||
open,
|
||||
close: ansiStyles.color.close,
|
||||
closeRe: ansiStyles.color.closeRe
|
||||
};
|
||||
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
|
||||
for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
|
||||
if (skipModels.has(model)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
||||
styles[bgModel] = {
|
||||
get() {
|
||||
const level = this.level;
|
||||
return function () {
|
||||
const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
|
||||
const codes = {
|
||||
open,
|
||||
close: ansiStyles.bgColor.close,
|
||||
closeRe: ansiStyles.bgColor.closeRe
|
||||
};
|
||||
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const proto = Object.defineProperties(() => {}, styles);
|
||||
|
||||
function build(_styles, _empty, key) {
|
||||
const builder = function () {
|
||||
return applyStyle.apply(builder, arguments);
|
||||
};
|
||||
|
||||
builder._styles = _styles;
|
||||
builder._empty = _empty;
|
||||
|
||||
const self = this;
|
||||
|
||||
Object.defineProperty(builder, 'level', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return self.level;
|
||||
},
|
||||
set(level) {
|
||||
self.level = level;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(builder, 'enabled', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return self.enabled;
|
||||
},
|
||||
set(enabled) {
|
||||
self.enabled = enabled;
|
||||
}
|
||||
});
|
||||
|
||||
// See below for fix regarding invisible grey/dim combination on Windows
|
||||
builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
|
||||
|
||||
// `__proto__` is used because we must return a function, but there is
|
||||
// no way to create a function with a different prototype
|
||||
builder.__proto__ = proto; // eslint-disable-line no-proto
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
function applyStyle() {
|
||||
// Support varags, but simply cast to string in case there's only one arg
|
||||
const args = arguments;
|
||||
const argsLen = args.length;
|
||||
let str = String(arguments[0]);
|
||||
|
||||
if (argsLen === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (argsLen > 1) {
|
||||
// Don't slice `arguments`, it prevents V8 optimizations
|
||||
for (let a = 1; a < argsLen; a++) {
|
||||
str += ' ' + args[a];
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.enabled || this.level <= 0 || !str) {
|
||||
return this._empty ? '' : str;
|
||||
}
|
||||
|
||||
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
|
||||
// see https://github.com/chalk/chalk/issues/58
|
||||
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
|
||||
const originalDim = ansiStyles.dim.open;
|
||||
if (isSimpleWindowsTerm && this.hasGrey) {
|
||||
ansiStyles.dim.open = '';
|
||||
}
|
||||
|
||||
for (const code of this._styles.slice().reverse()) {
|
||||
// Replace any instances already present with a re-opening code
|
||||
// otherwise only the part of the string until said closing code
|
||||
// will be colored, and the rest will simply be 'plain'.
|
||||
str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
||||
|
||||
// Close the styling before a linebreak and reopen
|
||||
// after next line to fix a bleed issue on macOS
|
||||
// https://github.com/chalk/chalk/pull/92
|
||||
str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
|
||||
}
|
||||
|
||||
// Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
|
||||
ansiStyles.dim.open = originalDim;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function chalkTag(chalk, strings) {
|
||||
if (!Array.isArray(strings)) {
|
||||
// If chalk() was called by itself or with a string,
|
||||
// return the string itself as a string.
|
||||
return [].slice.call(arguments, 1).join(' ');
|
||||
}
|
||||
|
||||
const args = [].slice.call(arguments, 2);
|
||||
const parts = [strings.raw[0]];
|
||||
|
||||
for (let i = 1; i < strings.length; i++) {
|
||||
parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
|
||||
parts.push(String(strings.raw[i]));
|
||||
}
|
||||
|
||||
return template(chalk, parts.join(''));
|
||||
}
|
||||
|
||||
Object.defineProperties(Chalk.prototype, styles);
|
||||
|
||||
module.exports = Chalk(); // eslint-disable-line new-cap
|
||||
module.exports.supportsColor = stdoutColor;
|
||||
module.exports.default = module.exports; // For TypeScript
|
||||
93
node_modules/chalk/index.js.flow
generated
vendored
Normal file
93
node_modules/chalk/index.js.flow
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// @flow
|
||||
|
||||
type TemplateStringsArray = $ReadOnlyArray<string>;
|
||||
|
||||
export type Level = $Values<{
|
||||
None: 0,
|
||||
Basic: 1,
|
||||
Ansi256: 2,
|
||||
TrueColor: 3
|
||||
}>;
|
||||
|
||||
export type ChalkOptions = {|
|
||||
enabled?: boolean,
|
||||
level?: Level
|
||||
|};
|
||||
|
||||
export type ColorSupport = {|
|
||||
level: Level,
|
||||
hasBasic: boolean,
|
||||
has256: boolean,
|
||||
has16m: boolean
|
||||
|};
|
||||
|
||||
export interface Chalk {
|
||||
(...text: string[]): string,
|
||||
(text: TemplateStringsArray, ...placeholders: string[]): string,
|
||||
constructor(options?: ChalkOptions): Chalk,
|
||||
enabled: boolean,
|
||||
level: Level,
|
||||
rgb(r: number, g: number, b: number): Chalk,
|
||||
hsl(h: number, s: number, l: number): Chalk,
|
||||
hsv(h: number, s: number, v: number): Chalk,
|
||||
hwb(h: number, w: number, b: number): Chalk,
|
||||
bgHex(color: string): Chalk,
|
||||
bgKeyword(color: string): Chalk,
|
||||
bgRgb(r: number, g: number, b: number): Chalk,
|
||||
bgHsl(h: number, s: number, l: number): Chalk,
|
||||
bgHsv(h: number, s: number, v: number): Chalk,
|
||||
bgHwb(h: number, w: number, b: number): Chalk,
|
||||
hex(color: string): Chalk,
|
||||
keyword(color: string): Chalk,
|
||||
|
||||
+reset: Chalk,
|
||||
+bold: Chalk,
|
||||
+dim: Chalk,
|
||||
+italic: Chalk,
|
||||
+underline: Chalk,
|
||||
+inverse: Chalk,
|
||||
+hidden: Chalk,
|
||||
+strikethrough: Chalk,
|
||||
|
||||
+visible: Chalk,
|
||||
|
||||
+black: Chalk,
|
||||
+red: Chalk,
|
||||
+green: Chalk,
|
||||
+yellow: Chalk,
|
||||
+blue: Chalk,
|
||||
+magenta: Chalk,
|
||||
+cyan: Chalk,
|
||||
+white: Chalk,
|
||||
+gray: Chalk,
|
||||
+grey: Chalk,
|
||||
+blackBright: Chalk,
|
||||
+redBright: Chalk,
|
||||
+greenBright: Chalk,
|
||||
+yellowBright: Chalk,
|
||||
+blueBright: Chalk,
|
||||
+magentaBright: Chalk,
|
||||
+cyanBright: Chalk,
|
||||
+whiteBright: Chalk,
|
||||
|
||||
+bgBlack: Chalk,
|
||||
+bgRed: Chalk,
|
||||
+bgGreen: Chalk,
|
||||
+bgYellow: Chalk,
|
||||
+bgBlue: Chalk,
|
||||
+bgMagenta: Chalk,
|
||||
+bgCyan: Chalk,
|
||||
+bgWhite: Chalk,
|
||||
+bgBlackBright: Chalk,
|
||||
+bgRedBright: Chalk,
|
||||
+bgGreenBright: Chalk,
|
||||
+bgYellowBright: Chalk,
|
||||
+bgBlueBright: Chalk,
|
||||
+bgMagentaBright: Chalk,
|
||||
+bgCyanBright: Chalk,
|
||||
+bgWhiteBrigh: Chalk,
|
||||
|
||||
supportsColor: ColorSupport
|
||||
};
|
||||
|
||||
declare module.exports: Chalk;
|
||||
128
node_modules/chalk/templates.js
generated
vendored
Normal file
128
node_modules/chalk/templates.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
'use strict';
|
||||
const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
||||
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
||||
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
||||
const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
|
||||
|
||||
const ESCAPES = new Map([
|
||||
['n', '\n'],
|
||||
['r', '\r'],
|
||||
['t', '\t'],
|
||||
['b', '\b'],
|
||||
['f', '\f'],
|
||||
['v', '\v'],
|
||||
['0', '\0'],
|
||||
['\\', '\\'],
|
||||
['e', '\u001B'],
|
||||
['a', '\u0007']
|
||||
]);
|
||||
|
||||
function unescape(c) {
|
||||
if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
||||
return String.fromCharCode(parseInt(c.slice(1), 16));
|
||||
}
|
||||
|
||||
return ESCAPES.get(c) || c;
|
||||
}
|
||||
|
||||
function parseArguments(name, args) {
|
||||
const results = [];
|
||||
const chunks = args.trim().split(/\s*,\s*/g);
|
||||
let matches;
|
||||
|
||||
for (const chunk of chunks) {
|
||||
if (!isNaN(chunk)) {
|
||||
results.push(Number(chunk));
|
||||
} else if ((matches = chunk.match(STRING_REGEX))) {
|
||||
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
|
||||
} else {
|
||||
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function parseStyle(style) {
|
||||
STYLE_REGEX.lastIndex = 0;
|
||||
|
||||
const results = [];
|
||||
let matches;
|
||||
|
||||
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
||||
const name = matches[1];
|
||||
|
||||
if (matches[2]) {
|
||||
const args = parseArguments(name, matches[2]);
|
||||
results.push([name].concat(args));
|
||||
} else {
|
||||
results.push([name]);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function buildStyle(chalk, styles) {
|
||||
const enabled = {};
|
||||
|
||||
for (const layer of styles) {
|
||||
for (const style of layer.styles) {
|
||||
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
let current = chalk;
|
||||
for (const styleName of Object.keys(enabled)) {
|
||||
if (Array.isArray(enabled[styleName])) {
|
||||
if (!(styleName in current)) {
|
||||
throw new Error(`Unknown Chalk style: ${styleName}`);
|
||||
}
|
||||
|
||||
if (enabled[styleName].length > 0) {
|
||||
current = current[styleName].apply(current, enabled[styleName]);
|
||||
} else {
|
||||
current = current[styleName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
module.exports = (chalk, tmp) => {
|
||||
const styles = [];
|
||||
const chunks = [];
|
||||
let chunk = [];
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
|
||||
if (escapeChar) {
|
||||
chunk.push(unescape(escapeChar));
|
||||
} else if (style) {
|
||||
const str = chunk.join('');
|
||||
chunk = [];
|
||||
chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
|
||||
styles.push({inverse, styles: parseStyle(style)});
|
||||
} else if (close) {
|
||||
if (styles.length === 0) {
|
||||
throw new Error('Found extraneous } in Chalk template literal');
|
||||
}
|
||||
|
||||
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
||||
chunk = [];
|
||||
styles.pop();
|
||||
} else {
|
||||
chunk.push(chr);
|
||||
}
|
||||
});
|
||||
|
||||
chunks.push(chunk.join(''));
|
||||
|
||||
if (styles.length > 0) {
|
||||
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
return chunks.join('');
|
||||
};
|
||||
97
node_modules/chalk/types/index.d.ts
generated
vendored
Normal file
97
node_modules/chalk/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// Type definitions for Chalk
|
||||
// Definitions by: Thomas Sauer <https://github.com/t-sauer>
|
||||
|
||||
export const enum Level {
|
||||
None = 0,
|
||||
Basic = 1,
|
||||
Ansi256 = 2,
|
||||
TrueColor = 3
|
||||
}
|
||||
|
||||
export interface ChalkOptions {
|
||||
enabled?: boolean;
|
||||
level?: Level;
|
||||
}
|
||||
|
||||
export interface ChalkConstructor {
|
||||
new (options?: ChalkOptions): Chalk;
|
||||
(options?: ChalkOptions): Chalk;
|
||||
}
|
||||
|
||||
export interface ColorSupport {
|
||||
level: Level;
|
||||
hasBasic: boolean;
|
||||
has256: boolean;
|
||||
has16m: boolean;
|
||||
}
|
||||
|
||||
export interface Chalk {
|
||||
(...text: string[]): string;
|
||||
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
||||
constructor: ChalkConstructor;
|
||||
enabled: boolean;
|
||||
level: Level;
|
||||
rgb(r: number, g: number, b: number): this;
|
||||
hsl(h: number, s: number, l: number): this;
|
||||
hsv(h: number, s: number, v: number): this;
|
||||
hwb(h: number, w: number, b: number): this;
|
||||
bgHex(color: string): this;
|
||||
bgKeyword(color: string): this;
|
||||
bgRgb(r: number, g: number, b: number): this;
|
||||
bgHsl(h: number, s: number, l: number): this;
|
||||
bgHsv(h: number, s: number, v: number): this;
|
||||
bgHwb(h: number, w: number, b: number): this;
|
||||
hex(color: string): this;
|
||||
keyword(color: string): this;
|
||||
|
||||
readonly reset: this;
|
||||
readonly bold: this;
|
||||
readonly dim: this;
|
||||
readonly italic: this;
|
||||
readonly underline: this;
|
||||
readonly inverse: this;
|
||||
readonly hidden: this;
|
||||
readonly strikethrough: this;
|
||||
|
||||
readonly visible: this;
|
||||
|
||||
readonly black: this;
|
||||
readonly red: this;
|
||||
readonly green: this;
|
||||
readonly yellow: this;
|
||||
readonly blue: this;
|
||||
readonly magenta: this;
|
||||
readonly cyan: this;
|
||||
readonly white: this;
|
||||
readonly gray: this;
|
||||
readonly grey: this;
|
||||
readonly blackBright: this;
|
||||
readonly redBright: this;
|
||||
readonly greenBright: this;
|
||||
readonly yellowBright: this;
|
||||
readonly blueBright: this;
|
||||
readonly magentaBright: this;
|
||||
readonly cyanBright: this;
|
||||
readonly whiteBright: this;
|
||||
|
||||
readonly bgBlack: this;
|
||||
readonly bgRed: this;
|
||||
readonly bgGreen: this;
|
||||
readonly bgYellow: this;
|
||||
readonly bgBlue: this;
|
||||
readonly bgMagenta: this;
|
||||
readonly bgCyan: this;
|
||||
readonly bgWhite: this;
|
||||
readonly bgBlackBright: this;
|
||||
readonly bgRedBright: this;
|
||||
readonly bgGreenBright: this;
|
||||
readonly bgYellowBright: this;
|
||||
readonly bgBlueBright: this;
|
||||
readonly bgMagentaBright: this;
|
||||
readonly bgCyanBright: this;
|
||||
readonly bgWhiteBright: this;
|
||||
}
|
||||
|
||||
declare const chalk: Chalk & { supportsColor: ColorSupport };
|
||||
|
||||
export default chalk
|
||||
39
node_modules/cli-cursor/index.js
generated
vendored
Normal file
39
node_modules/cli-cursor/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
const restoreCursor = require('restore-cursor');
|
||||
|
||||
let hidden = false;
|
||||
|
||||
exports.show = stream => {
|
||||
const s = stream || process.stderr;
|
||||
|
||||
if (!s.isTTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
hidden = false;
|
||||
s.write('\u001b[?25h');
|
||||
};
|
||||
|
||||
exports.hide = stream => {
|
||||
const s = stream || process.stderr;
|
||||
|
||||
if (!s.isTTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
restoreCursor();
|
||||
hidden = true;
|
||||
s.write('\u001b[?25l');
|
||||
};
|
||||
|
||||
exports.toggle = (force, stream) => {
|
||||
if (force !== undefined) {
|
||||
hidden = force;
|
||||
}
|
||||
|
||||
if (hidden) {
|
||||
exports.show(stream);
|
||||
} else {
|
||||
exports.hide(stream);
|
||||
}
|
||||
};
|
||||
2
node_modules/cli-spinners/index.js
generated
vendored
Normal file
2
node_modules/cli-spinners/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
module.exports = require('./spinners.json');
|
||||
912
node_modules/cli-spinners/spinners.json
generated
vendored
Normal file
912
node_modules/cli-spinners/spinners.json
generated
vendored
Normal file
@@ -0,0 +1,912 @@
|
||||
{
|
||||
"dots": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠹",
|
||||
"⠸",
|
||||
"⠼",
|
||||
"⠴",
|
||||
"⠦",
|
||||
"⠧",
|
||||
"⠇",
|
||||
"⠏"
|
||||
]
|
||||
},
|
||||
"dots2": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⣾",
|
||||
"⣽",
|
||||
"⣻",
|
||||
"⢿",
|
||||
"⡿",
|
||||
"⣟",
|
||||
"⣯",
|
||||
"⣷"
|
||||
]
|
||||
},
|
||||
"dots3": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠞",
|
||||
"⠖",
|
||||
"⠦",
|
||||
"⠴",
|
||||
"⠲",
|
||||
"⠳",
|
||||
"⠓"
|
||||
]
|
||||
},
|
||||
"dots4": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⠄",
|
||||
"⠆",
|
||||
"⠇",
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠸",
|
||||
"⠰",
|
||||
"⠠",
|
||||
"⠰",
|
||||
"⠸",
|
||||
"⠙",
|
||||
"⠋",
|
||||
"⠇",
|
||||
"⠆"
|
||||
]
|
||||
},
|
||||
"dots5": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠲",
|
||||
"⠴",
|
||||
"⠦",
|
||||
"⠖",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠓",
|
||||
"⠋"
|
||||
]
|
||||
},
|
||||
"dots6": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⠁",
|
||||
"⠉",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠲",
|
||||
"⠴",
|
||||
"⠤",
|
||||
"⠄",
|
||||
"⠄",
|
||||
"⠤",
|
||||
"⠴",
|
||||
"⠲",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠚",
|
||||
"⠙",
|
||||
"⠉",
|
||||
"⠁"
|
||||
]
|
||||
},
|
||||
"dots7": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⠈",
|
||||
"⠉",
|
||||
"⠋",
|
||||
"⠓",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠖",
|
||||
"⠦",
|
||||
"⠤",
|
||||
"⠠",
|
||||
"⠠",
|
||||
"⠤",
|
||||
"⠦",
|
||||
"⠖",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠓",
|
||||
"⠋",
|
||||
"⠉",
|
||||
"⠈"
|
||||
]
|
||||
},
|
||||
"dots8": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⠁",
|
||||
"⠁",
|
||||
"⠉",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠲",
|
||||
"⠴",
|
||||
"⠤",
|
||||
"⠄",
|
||||
"⠄",
|
||||
"⠤",
|
||||
"⠠",
|
||||
"⠠",
|
||||
"⠤",
|
||||
"⠦",
|
||||
"⠖",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠓",
|
||||
"⠋",
|
||||
"⠉",
|
||||
"⠈",
|
||||
"⠈"
|
||||
]
|
||||
},
|
||||
"dots9": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⢹",
|
||||
"⢺",
|
||||
"⢼",
|
||||
"⣸",
|
||||
"⣇",
|
||||
"⡧",
|
||||
"⡗",
|
||||
"⡏"
|
||||
]
|
||||
},
|
||||
"dots10": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⢄",
|
||||
"⢂",
|
||||
"⢁",
|
||||
"⡁",
|
||||
"⡈",
|
||||
"⡐",
|
||||
"⡠"
|
||||
]
|
||||
},
|
||||
"dots11": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"⠁",
|
||||
"⠂",
|
||||
"⠄",
|
||||
"⡀",
|
||||
"⢀",
|
||||
"⠠",
|
||||
"⠐",
|
||||
"⠈"
|
||||
]
|
||||
},
|
||||
"dots12": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⢀⠀",
|
||||
"⡀⠀",
|
||||
"⠄⠀",
|
||||
"⢂⠀",
|
||||
"⡂⠀",
|
||||
"⠅⠀",
|
||||
"⢃⠀",
|
||||
"⡃⠀",
|
||||
"⠍⠀",
|
||||
"⢋⠀",
|
||||
"⡋⠀",
|
||||
"⠍⠁",
|
||||
"⢋⠁",
|
||||
"⡋⠁",
|
||||
"⠍⠉",
|
||||
"⠋⠉",
|
||||
"⠋⠉",
|
||||
"⠉⠙",
|
||||
"⠉⠙",
|
||||
"⠉⠩",
|
||||
"⠈⢙",
|
||||
"⠈⡙",
|
||||
"⢈⠩",
|
||||
"⡀⢙",
|
||||
"⠄⡙",
|
||||
"⢂⠩",
|
||||
"⡂⢘",
|
||||
"⠅⡘",
|
||||
"⢃⠨",
|
||||
"⡃⢐",
|
||||
"⠍⡐",
|
||||
"⢋⠠",
|
||||
"⡋⢀",
|
||||
"⠍⡁",
|
||||
"⢋⠁",
|
||||
"⡋⠁",
|
||||
"⠍⠉",
|
||||
"⠋⠉",
|
||||
"⠋⠉",
|
||||
"⠉⠙",
|
||||
"⠉⠙",
|
||||
"⠉⠩",
|
||||
"⠈⢙",
|
||||
"⠈⡙",
|
||||
"⠈⠩",
|
||||
"⠀⢙",
|
||||
"⠀⡙",
|
||||
"⠀⠩",
|
||||
"⠀⢘",
|
||||
"⠀⡘",
|
||||
"⠀⠨",
|
||||
"⠀⢐",
|
||||
"⠀⡐",
|
||||
"⠀⠠",
|
||||
"⠀⢀",
|
||||
"⠀⡀"
|
||||
]
|
||||
},
|
||||
"line": {
|
||||
"interval": 130,
|
||||
"frames": [
|
||||
"-",
|
||||
"\\",
|
||||
"|",
|
||||
"/"
|
||||
]
|
||||
},
|
||||
"line2": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"⠂",
|
||||
"-",
|
||||
"–",
|
||||
"—",
|
||||
"–",
|
||||
"-"
|
||||
]
|
||||
},
|
||||
"pipe": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"┤",
|
||||
"┘",
|
||||
"┴",
|
||||
"└",
|
||||
"├",
|
||||
"┌",
|
||||
"┬",
|
||||
"┐"
|
||||
]
|
||||
},
|
||||
"simpleDots": {
|
||||
"interval": 400,
|
||||
"frames": [
|
||||
". ",
|
||||
".. ",
|
||||
"...",
|
||||
" "
|
||||
]
|
||||
},
|
||||
"simpleDotsScrolling": {
|
||||
"interval": 200,
|
||||
"frames": [
|
||||
". ",
|
||||
".. ",
|
||||
"...",
|
||||
" ..",
|
||||
" .",
|
||||
" "
|
||||
]
|
||||
},
|
||||
"star": {
|
||||
"interval": 70,
|
||||
"frames": [
|
||||
"✶",
|
||||
"✸",
|
||||
"✹",
|
||||
"✺",
|
||||
"✹",
|
||||
"✷"
|
||||
]
|
||||
},
|
||||
"star2": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"+",
|
||||
"x",
|
||||
"*"
|
||||
]
|
||||
},
|
||||
"flip": {
|
||||
"interval": 70,
|
||||
"frames": [
|
||||
"_",
|
||||
"_",
|
||||
"_",
|
||||
"-",
|
||||
"`",
|
||||
"`",
|
||||
"'",
|
||||
"´",
|
||||
"-",
|
||||
"_",
|
||||
"_",
|
||||
"_"
|
||||
]
|
||||
},
|
||||
"hamburger": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"☱",
|
||||
"☲",
|
||||
"☴"
|
||||
]
|
||||
},
|
||||
"growVertical": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"▁",
|
||||
"▃",
|
||||
"▄",
|
||||
"▅",
|
||||
"▆",
|
||||
"▇",
|
||||
"▆",
|
||||
"▅",
|
||||
"▄",
|
||||
"▃"
|
||||
]
|
||||
},
|
||||
"growHorizontal": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"▏",
|
||||
"▎",
|
||||
"▍",
|
||||
"▌",
|
||||
"▋",
|
||||
"▊",
|
||||
"▉",
|
||||
"▊",
|
||||
"▋",
|
||||
"▌",
|
||||
"▍",
|
||||
"▎"
|
||||
]
|
||||
},
|
||||
"balloon": {
|
||||
"interval": 140,
|
||||
"frames": [
|
||||
" ",
|
||||
".",
|
||||
"o",
|
||||
"O",
|
||||
"@",
|
||||
"*",
|
||||
" "
|
||||
]
|
||||
},
|
||||
"balloon2": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
".",
|
||||
"o",
|
||||
"O",
|
||||
"°",
|
||||
"O",
|
||||
"o",
|
||||
"."
|
||||
]
|
||||
},
|
||||
"noise": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"▓",
|
||||
"▒",
|
||||
"░"
|
||||
]
|
||||
},
|
||||
"bounce": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"⠁",
|
||||
"⠂",
|
||||
"⠄",
|
||||
"⠂"
|
||||
]
|
||||
},
|
||||
"boxBounce": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"▖",
|
||||
"▘",
|
||||
"▝",
|
||||
"▗"
|
||||
]
|
||||
},
|
||||
"boxBounce2": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"▌",
|
||||
"▀",
|
||||
"▐",
|
||||
"▄"
|
||||
]
|
||||
},
|
||||
"triangle": {
|
||||
"interval": 50,
|
||||
"frames": [
|
||||
"◢",
|
||||
"◣",
|
||||
"◤",
|
||||
"◥"
|
||||
]
|
||||
},
|
||||
"arc": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"◜",
|
||||
"◠",
|
||||
"◝",
|
||||
"◞",
|
||||
"◡",
|
||||
"◟"
|
||||
]
|
||||
},
|
||||
"circle": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"◡",
|
||||
"⊙",
|
||||
"◠"
|
||||
]
|
||||
},
|
||||
"squareCorners": {
|
||||
"interval": 180,
|
||||
"frames": [
|
||||
"◰",
|
||||
"◳",
|
||||
"◲",
|
||||
"◱"
|
||||
]
|
||||
},
|
||||
"circleQuarters": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"◴",
|
||||
"◷",
|
||||
"◶",
|
||||
"◵"
|
||||
]
|
||||
},
|
||||
"circleHalves": {
|
||||
"interval": 50,
|
||||
"frames": [
|
||||
"◐",
|
||||
"◓",
|
||||
"◑",
|
||||
"◒"
|
||||
]
|
||||
},
|
||||
"squish": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"╫",
|
||||
"╪"
|
||||
]
|
||||
},
|
||||
"toggle": {
|
||||
"interval": 250,
|
||||
"frames": [
|
||||
"⊶",
|
||||
"⊷"
|
||||
]
|
||||
},
|
||||
"toggle2": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"▫",
|
||||
"▪"
|
||||
]
|
||||
},
|
||||
"toggle3": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"□",
|
||||
"■"
|
||||
]
|
||||
},
|
||||
"toggle4": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"■",
|
||||
"□",
|
||||
"▪",
|
||||
"▫"
|
||||
]
|
||||
},
|
||||
"toggle5": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"▮",
|
||||
"▯"
|
||||
]
|
||||
},
|
||||
"toggle6": {
|
||||
"interval": 300,
|
||||
"frames": [
|
||||
"ဝ",
|
||||
"၀"
|
||||
]
|
||||
},
|
||||
"toggle7": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⦾",
|
||||
"⦿"
|
||||
]
|
||||
},
|
||||
"toggle8": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"◍",
|
||||
"◌"
|
||||
]
|
||||
},
|
||||
"toggle9": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"◉",
|
||||
"◎"
|
||||
]
|
||||
},
|
||||
"toggle10": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"㊂",
|
||||
"㊀",
|
||||
"㊁"
|
||||
]
|
||||
},
|
||||
"toggle11": {
|
||||
"interval": 50,
|
||||
"frames": [
|
||||
"⧇",
|
||||
"⧆"
|
||||
]
|
||||
},
|
||||
"toggle12": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"☗",
|
||||
"☖"
|
||||
]
|
||||
},
|
||||
"toggle13": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"=",
|
||||
"*",
|
||||
"-"
|
||||
]
|
||||
},
|
||||
"arrow": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"←",
|
||||
"↖",
|
||||
"↑",
|
||||
"↗",
|
||||
"→",
|
||||
"↘",
|
||||
"↓",
|
||||
"↙"
|
||||
]
|
||||
},
|
||||
"arrow2": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"⬆️ ",
|
||||
"↗️ ",
|
||||
"➡️ ",
|
||||
"↘️ ",
|
||||
"⬇️ ",
|
||||
"↙️ ",
|
||||
"⬅️ ",
|
||||
"↖️ "
|
||||
]
|
||||
},
|
||||
"arrow3": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"▹▹▹▹▹",
|
||||
"▸▹▹▹▹",
|
||||
"▹▸▹▹▹",
|
||||
"▹▹▸▹▹",
|
||||
"▹▹▹▸▹",
|
||||
"▹▹▹▹▸"
|
||||
]
|
||||
},
|
||||
"bouncingBar": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"[ ]",
|
||||
"[= ]",
|
||||
"[== ]",
|
||||
"[=== ]",
|
||||
"[ ===]",
|
||||
"[ ==]",
|
||||
"[ =]",
|
||||
"[ ]",
|
||||
"[ =]",
|
||||
"[ ==]",
|
||||
"[ ===]",
|
||||
"[====]",
|
||||
"[=== ]",
|
||||
"[== ]",
|
||||
"[= ]"
|
||||
]
|
||||
},
|
||||
"bouncingBall": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"( ● )",
|
||||
"( ● )",
|
||||
"( ● )",
|
||||
"( ● )",
|
||||
"( ●)",
|
||||
"( ● )",
|
||||
"( ● )",
|
||||
"( ● )",
|
||||
"( ● )",
|
||||
"(● )"
|
||||
]
|
||||
},
|
||||
"smiley": {
|
||||
"interval": 200,
|
||||
"frames": [
|
||||
"😄 ",
|
||||
"😝 "
|
||||
]
|
||||
},
|
||||
"monkey": {
|
||||
"interval": 300,
|
||||
"frames": [
|
||||
"🙈 ",
|
||||
"🙈 ",
|
||||
"🙉 ",
|
||||
"🙊 "
|
||||
]
|
||||
},
|
||||
"hearts": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"💛 ",
|
||||
"💙 ",
|
||||
"💜 ",
|
||||
"💚 ",
|
||||
"❤️ "
|
||||
]
|
||||
},
|
||||
"clock": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"🕛 ",
|
||||
"🕐 ",
|
||||
"🕑 ",
|
||||
"🕒 ",
|
||||
"🕓 ",
|
||||
"🕔 ",
|
||||
"🕕 ",
|
||||
"🕖 ",
|
||||
"🕗 ",
|
||||
"🕘 ",
|
||||
"🕙 ",
|
||||
"🕚 "
|
||||
]
|
||||
},
|
||||
"earth": {
|
||||
"interval": 180,
|
||||
"frames": [
|
||||
"🌍 ",
|
||||
"🌎 ",
|
||||
"🌏 "
|
||||
]
|
||||
},
|
||||
"moon": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"🌑 ",
|
||||
"🌒 ",
|
||||
"🌓 ",
|
||||
"🌔 ",
|
||||
"🌕 ",
|
||||
"🌖 ",
|
||||
"🌗 ",
|
||||
"🌘 "
|
||||
]
|
||||
},
|
||||
"runner": {
|
||||
"interval": 140,
|
||||
"frames": [
|
||||
"🚶 ",
|
||||
"🏃 "
|
||||
]
|
||||
},
|
||||
"pong": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"▐⠂ ▌",
|
||||
"▐⠈ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⡀ ▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠈ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⡀ ▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠈ ▌",
|
||||
"▐ ⠂▌",
|
||||
"▐ ⠠▌",
|
||||
"▐ ⡀▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠈ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⡀ ▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠈ ▌",
|
||||
"▐ ⠂ ▌",
|
||||
"▐ ⠠ ▌",
|
||||
"▐ ⡀ ▌",
|
||||
"▐⠠ ▌"
|
||||
]
|
||||
},
|
||||
"shark": {
|
||||
"interval": 120,
|
||||
"frames": [
|
||||
"▐|\\____________▌",
|
||||
"▐_|\\___________▌",
|
||||
"▐__|\\__________▌",
|
||||
"▐___|\\_________▌",
|
||||
"▐____|\\________▌",
|
||||
"▐_____|\\_______▌",
|
||||
"▐______|\\______▌",
|
||||
"▐_______|\\_____▌",
|
||||
"▐________|\\____▌",
|
||||
"▐_________|\\___▌",
|
||||
"▐__________|\\__▌",
|
||||
"▐___________|\\_▌",
|
||||
"▐____________|\\▌",
|
||||
"▐____________/|▌",
|
||||
"▐___________/|_▌",
|
||||
"▐__________/|__▌",
|
||||
"▐_________/|___▌",
|
||||
"▐________/|____▌",
|
||||
"▐_______/|_____▌",
|
||||
"▐______/|______▌",
|
||||
"▐_____/|_______▌",
|
||||
"▐____/|________▌",
|
||||
"▐___/|_________▌",
|
||||
"▐__/|__________▌",
|
||||
"▐_/|___________▌",
|
||||
"▐/|____________▌"
|
||||
]
|
||||
},
|
||||
"dqpb": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"d",
|
||||
"q",
|
||||
"p",
|
||||
"b"
|
||||
]
|
||||
},
|
||||
"weather": {
|
||||
"interval": 100,
|
||||
"frames": [
|
||||
"☀️ ",
|
||||
"☀️ ",
|
||||
"☀️ ",
|
||||
"🌤 ",
|
||||
"⛅️ ",
|
||||
"🌥 ",
|
||||
"☁️ ",
|
||||
"🌧 ",
|
||||
"🌨 ",
|
||||
"🌧 ",
|
||||
"🌨 ",
|
||||
"🌧 ",
|
||||
"🌨 ",
|
||||
"⛈ ",
|
||||
"🌨 ",
|
||||
"🌧 ",
|
||||
"🌨 ",
|
||||
"☁️ ",
|
||||
"🌥 ",
|
||||
"⛅️ ",
|
||||
"🌤 ",
|
||||
"☀️ ",
|
||||
"☀️ "
|
||||
]
|
||||
},
|
||||
"christmas": {
|
||||
"interval": 400,
|
||||
"frames": [
|
||||
"🌲",
|
||||
"🎄"
|
||||
]
|
||||
},
|
||||
"grenade": {
|
||||
"interval": 80,
|
||||
"frames": [
|
||||
"، ",
|
||||
"′ ",
|
||||
" ´ ",
|
||||
" ‾ ",
|
||||
" ⸌",
|
||||
" ⸊",
|
||||
" |",
|
||||
" ⁎",
|
||||
" ⁕",
|
||||
" ෴ ",
|
||||
" ⁓",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
]
|
||||
},
|
||||
"point": {
|
||||
"interval": 125,
|
||||
"frames": [
|
||||
"∙∙∙",
|
||||
"●∙∙",
|
||||
"∙●∙",
|
||||
"∙∙●",
|
||||
"∙∙∙"
|
||||
]
|
||||
},
|
||||
"layer": {
|
||||
"interval": 150,
|
||||
"frames": [
|
||||
"-",
|
||||
"=",
|
||||
"≡"
|
||||
]
|
||||
}
|
||||
}
|
||||
10
node_modules/clone/clone.iml
generated
vendored
Normal file
10
node_modules/clone/clone.iml
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="clone node_modules" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
166
node_modules/clone/clone.js
generated
vendored
Normal file
166
node_modules/clone/clone.js
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
var clone = (function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
var filter;
|
||||
if (typeof circular === 'object') {
|
||||
depth = circular.depth;
|
||||
prototype = circular.prototype;
|
||||
filter = circular.filter;
|
||||
circular = circular.circular
|
||||
}
|
||||
// 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 (clone.__isArray(parent)) {
|
||||
child = [];
|
||||
} else if (clone.__isRegExp(parent)) {
|
||||
child = new RegExp(parent.source, __getRegExpFlags(parent));
|
||||
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
||||
} else if (clone.__isDate(parent)) {
|
||||
child = new Date(parent.getTime());
|
||||
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
||||
if (Buffer.allocUnsafe) {
|
||||
// Node.js >= 4.5.0
|
||||
child = Buffer.allocUnsafe(parent.length);
|
||||
} else {
|
||||
// Older Node.js versions
|
||||
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 clonePrototype(parent) {
|
||||
if (parent === null)
|
||||
return null;
|
||||
|
||||
var c = function () {};
|
||||
c.prototype = parent;
|
||||
return new c();
|
||||
};
|
||||
|
||||
// private utility functions
|
||||
|
||||
function __objToStr(o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
};
|
||||
clone.__objToStr = __objToStr;
|
||||
|
||||
function __isDate(o) {
|
||||
return typeof o === 'object' && __objToStr(o) === '[object Date]';
|
||||
};
|
||||
clone.__isDate = __isDate;
|
||||
|
||||
function __isArray(o) {
|
||||
return typeof o === 'object' && __objToStr(o) === '[object Array]';
|
||||
};
|
||||
clone.__isArray = __isArray;
|
||||
|
||||
function __isRegExp(o) {
|
||||
return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
|
||||
};
|
||||
clone.__isRegExp = __isRegExp;
|
||||
|
||||
function __getRegExpFlags(re) {
|
||||
var flags = '';
|
||||
if (re.global) flags += 'g';
|
||||
if (re.ignoreCase) flags += 'i';
|
||||
if (re.multiline) flags += 'm';
|
||||
return flags;
|
||||
};
|
||||
clone.__getRegExpFlags = __getRegExpFlags;
|
||||
|
||||
return clone;
|
||||
})();
|
||||
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
module.exports = clone;
|
||||
}
|
||||
868
node_modules/color-convert/conversions.js
generated
vendored
Normal file
868
node_modules/color-convert/conversions.js
generated
vendored
Normal file
@@ -0,0 +1,868 @@
|
||||
/* MIT license */
|
||||
var cssKeywords = require('color-name');
|
||||
|
||||
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
||||
// values that give correct `typeof` results).
|
||||
// do not use box values types (i.e. Number(), String(), etc.)
|
||||
|
||||
var reverseKeywords = {};
|
||||
for (var key in cssKeywords) {
|
||||
if (cssKeywords.hasOwnProperty(key)) {
|
||||
reverseKeywords[cssKeywords[key]] = key;
|
||||
}
|
||||
}
|
||||
|
||||
var convert = module.exports = {
|
||||
rgb: {channels: 3, labels: 'rgb'},
|
||||
hsl: {channels: 3, labels: 'hsl'},
|
||||
hsv: {channels: 3, labels: 'hsv'},
|
||||
hwb: {channels: 3, labels: 'hwb'},
|
||||
cmyk: {channels: 4, labels: 'cmyk'},
|
||||
xyz: {channels: 3, labels: 'xyz'},
|
||||
lab: {channels: 3, labels: 'lab'},
|
||||
lch: {channels: 3, labels: 'lch'},
|
||||
hex: {channels: 1, labels: ['hex']},
|
||||
keyword: {channels: 1, labels: ['keyword']},
|
||||
ansi16: {channels: 1, labels: ['ansi16']},
|
||||
ansi256: {channels: 1, labels: ['ansi256']},
|
||||
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
||||
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
||||
gray: {channels: 1, labels: ['gray']}
|
||||
};
|
||||
|
||||
// hide .channels and .labels properties
|
||||
for (var model in convert) {
|
||||
if (convert.hasOwnProperty(model)) {
|
||||
if (!('channels' in convert[model])) {
|
||||
throw new Error('missing channels property: ' + model);
|
||||
}
|
||||
|
||||
if (!('labels' in convert[model])) {
|
||||
throw new Error('missing channel labels property: ' + model);
|
||||
}
|
||||
|
||||
if (convert[model].labels.length !== convert[model].channels) {
|
||||
throw new Error('channel and label counts mismatch: ' + model);
|
||||
}
|
||||
|
||||
var channels = convert[model].channels;
|
||||
var labels = convert[model].labels;
|
||||
delete convert[model].channels;
|
||||
delete convert[model].labels;
|
||||
Object.defineProperty(convert[model], 'channels', {value: channels});
|
||||
Object.defineProperty(convert[model], 'labels', {value: labels});
|
||||
}
|
||||
}
|
||||
|
||||
convert.rgb.hsl = function (rgb) {
|
||||
var r = rgb[0] / 255;
|
||||
var g = rgb[1] / 255;
|
||||
var b = rgb[2] / 255;
|
||||
var min = Math.min(r, g, b);
|
||||
var max = Math.max(r, g, b);
|
||||
var delta = max - min;
|
||||
var h;
|
||||
var s;
|
||||
var l;
|
||||
|
||||
if (max === min) {
|
||||
h = 0;
|
||||
} else if (r === max) {
|
||||
h = (g - b) / delta;
|
||||
} else if (g === max) {
|
||||
h = 2 + (b - r) / delta;
|
||||
} else if (b === max) {
|
||||
h = 4 + (r - g) / delta;
|
||||
}
|
||||
|
||||
h = Math.min(h * 60, 360);
|
||||
|
||||
if (h < 0) {
|
||||
h += 360;
|
||||
}
|
||||
|
||||
l = (min + max) / 2;
|
||||
|
||||
if (max === min) {
|
||||
s = 0;
|
||||
} else if (l <= 0.5) {
|
||||
s = delta / (max + min);
|
||||
} else {
|
||||
s = delta / (2 - max - min);
|
||||
}
|
||||
|
||||
return [h, s * 100, l * 100];
|
||||
};
|
||||
|
||||
convert.rgb.hsv = function (rgb) {
|
||||
var rdif;
|
||||
var gdif;
|
||||
var bdif;
|
||||
var h;
|
||||
var s;
|
||||
|
||||
var r = rgb[0] / 255;
|
||||
var g = rgb[1] / 255;
|
||||
var b = rgb[2] / 255;
|
||||
var v = Math.max(r, g, b);
|
||||
var diff = v - Math.min(r, g, b);
|
||||
var diffc = function (c) {
|
||||
return (v - c) / 6 / diff + 1 / 2;
|
||||
};
|
||||
|
||||
if (diff === 0) {
|
||||
h = s = 0;
|
||||
} else {
|
||||
s = diff / v;
|
||||
rdif = diffc(r);
|
||||
gdif = diffc(g);
|
||||
bdif = diffc(b);
|
||||
|
||||
if (r === v) {
|
||||
h = bdif - gdif;
|
||||
} else if (g === v) {
|
||||
h = (1 / 3) + rdif - bdif;
|
||||
} else if (b === v) {
|
||||
h = (2 / 3) + gdif - rdif;
|
||||
}
|
||||
if (h < 0) {
|
||||
h += 1;
|
||||
} else if (h > 1) {
|
||||
h -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
h * 360,
|
||||
s * 100,
|
||||
v * 100
|
||||
];
|
||||
};
|
||||
|
||||
convert.rgb.hwb = function (rgb) {
|
||||
var r = rgb[0];
|
||||
var g = rgb[1];
|
||||
var b = rgb[2];
|
||||
var h = convert.rgb.hsl(rgb)[0];
|
||||
var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
||||
|
||||
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
||||
|
||||
return [h, w * 100, b * 100];
|
||||
};
|
||||
|
||||
convert.rgb.cmyk = function (rgb) {
|
||||
var r = rgb[0] / 255;
|
||||
var g = rgb[1] / 255;
|
||||
var b = rgb[2] / 255;
|
||||
var c;
|
||||
var m;
|
||||
var y;
|
||||
var k;
|
||||
|
||||
k = Math.min(1 - r, 1 - g, 1 - b);
|
||||
c = (1 - r - k) / (1 - k) || 0;
|
||||
m = (1 - g - k) / (1 - k) || 0;
|
||||
y = (1 - b - k) / (1 - k) || 0;
|
||||
|
||||
return [c * 100, m * 100, y * 100, k * 100];
|
||||
};
|
||||
|
||||
/**
|
||||
* See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
||||
* */
|
||||
function comparativeDistance(x, y) {
|
||||
return (
|
||||
Math.pow(x[0] - y[0], 2) +
|
||||
Math.pow(x[1] - y[1], 2) +
|
||||
Math.pow(x[2] - y[2], 2)
|
||||
);
|
||||
}
|
||||
|
||||
convert.rgb.keyword = function (rgb) {
|
||||
var reversed = reverseKeywords[rgb];
|
||||
if (reversed) {
|
||||
return reversed;
|
||||
}
|
||||
|
||||
var currentClosestDistance = Infinity;
|
||||
var currentClosestKeyword;
|
||||
|
||||
for (var keyword in cssKeywords) {
|
||||
if (cssKeywords.hasOwnProperty(keyword)) {
|
||||
var value = cssKeywords[keyword];
|
||||
|
||||
// Compute comparative distance
|
||||
var distance = comparativeDistance(rgb, value);
|
||||
|
||||
// Check if its less, if so set as closest
|
||||
if (distance < currentClosestDistance) {
|
||||
currentClosestDistance = distance;
|
||||
currentClosestKeyword = keyword;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return currentClosestKeyword;
|
||||
};
|
||||
|
||||
convert.keyword.rgb = function (keyword) {
|
||||
return cssKeywords[keyword];
|
||||
};
|
||||
|
||||
convert.rgb.xyz = function (rgb) {
|
||||
var r = rgb[0] / 255;
|
||||
var g = rgb[1] / 255;
|
||||
var b = rgb[2] / 255;
|
||||
|
||||
// assume sRGB
|
||||
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
|
||||
g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
|
||||
b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
|
||||
|
||||
var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
||||
var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
||||
var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
||||
|
||||
return [x * 100, y * 100, z * 100];
|
||||
};
|
||||
|
||||
convert.rgb.lab = function (rgb) {
|
||||
var xyz = convert.rgb.xyz(rgb);
|
||||
var x = xyz[0];
|
||||
var y = xyz[1];
|
||||
var z = xyz[2];
|
||||
var l;
|
||||
var a;
|
||||
var b;
|
||||
|
||||
x /= 95.047;
|
||||
y /= 100;
|
||||
z /= 108.883;
|
||||
|
||||
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
|
||||
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
|
||||
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
|
||||
|
||||
l = (116 * y) - 16;
|
||||
a = 500 * (x - y);
|
||||
b = 200 * (y - z);
|
||||
|
||||
return [l, a, b];
|
||||
};
|
||||
|
||||
convert.hsl.rgb = function (hsl) {
|
||||
var h = hsl[0] / 360;
|
||||
var s = hsl[1] / 100;
|
||||
var l = hsl[2] / 100;
|
||||
var t1;
|
||||
var t2;
|
||||
var t3;
|
||||
var rgb;
|
||||
var val;
|
||||
|
||||
if (s === 0) {
|
||||
val = l * 255;
|
||||
return [val, val, val];
|
||||
}
|
||||
|
||||
if (l < 0.5) {
|
||||
t2 = l * (1 + s);
|
||||
} else {
|
||||
t2 = l + s - l * s;
|
||||
}
|
||||
|
||||
t1 = 2 * l - t2;
|
||||
|
||||
rgb = [0, 0, 0];
|
||||
for (var i = 0; i < 3; i++) {
|
||||
t3 = h + 1 / 3 * -(i - 1);
|
||||
if (t3 < 0) {
|
||||
t3++;
|
||||
}
|
||||
if (t3 > 1) {
|
||||
t3--;
|
||||
}
|
||||
|
||||
if (6 * t3 < 1) {
|
||||
val = t1 + (t2 - t1) * 6 * t3;
|
||||
} else if (2 * t3 < 1) {
|
||||
val = t2;
|
||||
} else if (3 * t3 < 2) {
|
||||
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
||||
} else {
|
||||
val = t1;
|
||||
}
|
||||
|
||||
rgb[i] = val * 255;
|
||||
}
|
||||
|
||||
return rgb;
|
||||
};
|
||||
|
||||
convert.hsl.hsv = function (hsl) {
|
||||
var h = hsl[0];
|
||||
var s = hsl[1] / 100;
|
||||
var l = hsl[2] / 100;
|
||||
var smin = s;
|
||||
var lmin = Math.max(l, 0.01);
|
||||
var sv;
|
||||
var v;
|
||||
|
||||
l *= 2;
|
||||
s *= (l <= 1) ? l : 2 - l;
|
||||
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
||||
v = (l + s) / 2;
|
||||
sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
||||
|
||||
return [h, sv * 100, v * 100];
|
||||
};
|
||||
|
||||
convert.hsv.rgb = function (hsv) {
|
||||
var h = hsv[0] / 60;
|
||||
var s = hsv[1] / 100;
|
||||
var v = hsv[2] / 100;
|
||||
var hi = Math.floor(h) % 6;
|
||||
|
||||
var f = h - Math.floor(h);
|
||||
var p = 255 * v * (1 - s);
|
||||
var q = 255 * v * (1 - (s * f));
|
||||
var t = 255 * v * (1 - (s * (1 - f)));
|
||||
v *= 255;
|
||||
|
||||
switch (hi) {
|
||||
case 0:
|
||||
return [v, t, p];
|
||||
case 1:
|
||||
return [q, v, p];
|
||||
case 2:
|
||||
return [p, v, t];
|
||||
case 3:
|
||||
return [p, q, v];
|
||||
case 4:
|
||||
return [t, p, v];
|
||||
case 5:
|
||||
return [v, p, q];
|
||||
}
|
||||
};
|
||||
|
||||
convert.hsv.hsl = function (hsv) {
|
||||
var h = hsv[0];
|
||||
var s = hsv[1] / 100;
|
||||
var v = hsv[2] / 100;
|
||||
var vmin = Math.max(v, 0.01);
|
||||
var lmin;
|
||||
var sl;
|
||||
var l;
|
||||
|
||||
l = (2 - s) * v;
|
||||
lmin = (2 - s) * vmin;
|
||||
sl = s * vmin;
|
||||
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
||||
sl = sl || 0;
|
||||
l /= 2;
|
||||
|
||||
return [h, sl * 100, l * 100];
|
||||
};
|
||||
|
||||
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
||||
convert.hwb.rgb = function (hwb) {
|
||||
var h = hwb[0] / 360;
|
||||
var wh = hwb[1] / 100;
|
||||
var bl = hwb[2] / 100;
|
||||
var ratio = wh + bl;
|
||||
var i;
|
||||
var v;
|
||||
var f;
|
||||
var n;
|
||||
|
||||
// wh + bl cant be > 1
|
||||
if (ratio > 1) {
|
||||
wh /= ratio;
|
||||
bl /= ratio;
|
||||
}
|
||||
|
||||
i = Math.floor(6 * h);
|
||||
v = 1 - bl;
|
||||
f = 6 * h - i;
|
||||
|
||||
if ((i & 0x01) !== 0) {
|
||||
f = 1 - f;
|
||||
}
|
||||
|
||||
n = wh + f * (v - wh); // linear interpolation
|
||||
|
||||
var r;
|
||||
var g;
|
||||
var b;
|
||||
switch (i) {
|
||||
default:
|
||||
case 6:
|
||||
case 0: r = v; g = n; b = wh; break;
|
||||
case 1: r = n; g = v; b = wh; break;
|
||||
case 2: r = wh; g = v; b = n; break;
|
||||
case 3: r = wh; g = n; b = v; break;
|
||||
case 4: r = n; g = wh; b = v; break;
|
||||
case 5: r = v; g = wh; b = n; break;
|
||||
}
|
||||
|
||||
return [r * 255, g * 255, b * 255];
|
||||
};
|
||||
|
||||
convert.cmyk.rgb = function (cmyk) {
|
||||
var c = cmyk[0] / 100;
|
||||
var m = cmyk[1] / 100;
|
||||
var y = cmyk[2] / 100;
|
||||
var k = cmyk[3] / 100;
|
||||
var r;
|
||||
var g;
|
||||
var b;
|
||||
|
||||
r = 1 - Math.min(1, c * (1 - k) + k);
|
||||
g = 1 - Math.min(1, m * (1 - k) + k);
|
||||
b = 1 - Math.min(1, y * (1 - k) + k);
|
||||
|
||||
return [r * 255, g * 255, b * 255];
|
||||
};
|
||||
|
||||
convert.xyz.rgb = function (xyz) {
|
||||
var x = xyz[0] / 100;
|
||||
var y = xyz[1] / 100;
|
||||
var z = xyz[2] / 100;
|
||||
var r;
|
||||
var g;
|
||||
var b;
|
||||
|
||||
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
||||
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
||||
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
||||
|
||||
// assume sRGB
|
||||
r = r > 0.0031308
|
||||
? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
|
||||
: r * 12.92;
|
||||
|
||||
g = g > 0.0031308
|
||||
? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
|
||||
: g * 12.92;
|
||||
|
||||
b = b > 0.0031308
|
||||
? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
|
||||
: b * 12.92;
|
||||
|
||||
r = Math.min(Math.max(0, r), 1);
|
||||
g = Math.min(Math.max(0, g), 1);
|
||||
b = Math.min(Math.max(0, b), 1);
|
||||
|
||||
return [r * 255, g * 255, b * 255];
|
||||
};
|
||||
|
||||
convert.xyz.lab = function (xyz) {
|
||||
var x = xyz[0];
|
||||
var y = xyz[1];
|
||||
var z = xyz[2];
|
||||
var l;
|
||||
var a;
|
||||
var b;
|
||||
|
||||
x /= 95.047;
|
||||
y /= 100;
|
||||
z /= 108.883;
|
||||
|
||||
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
|
||||
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
|
||||
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
|
||||
|
||||
l = (116 * y) - 16;
|
||||
a = 500 * (x - y);
|
||||
b = 200 * (y - z);
|
||||
|
||||
return [l, a, b];
|
||||
};
|
||||
|
||||
convert.lab.xyz = function (lab) {
|
||||
var l = lab[0];
|
||||
var a = lab[1];
|
||||
var b = lab[2];
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
|
||||
y = (l + 16) / 116;
|
||||
x = a / 500 + y;
|
||||
z = y - b / 200;
|
||||
|
||||
var y2 = Math.pow(y, 3);
|
||||
var x2 = Math.pow(x, 3);
|
||||
var z2 = Math.pow(z, 3);
|
||||
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
||||
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
||||
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
||||
|
||||
x *= 95.047;
|
||||
y *= 100;
|
||||
z *= 108.883;
|
||||
|
||||
return [x, y, z];
|
||||
};
|
||||
|
||||
convert.lab.lch = function (lab) {
|
||||
var l = lab[0];
|
||||
var a = lab[1];
|
||||
var b = lab[2];
|
||||
var hr;
|
||||
var h;
|
||||
var c;
|
||||
|
||||
hr = Math.atan2(b, a);
|
||||
h = hr * 360 / 2 / Math.PI;
|
||||
|
||||
if (h < 0) {
|
||||
h += 360;
|
||||
}
|
||||
|
||||
c = Math.sqrt(a * a + b * b);
|
||||
|
||||
return [l, c, h];
|
||||
};
|
||||
|
||||
convert.lch.lab = function (lch) {
|
||||
var l = lch[0];
|
||||
var c = lch[1];
|
||||
var h = lch[2];
|
||||
var a;
|
||||
var b;
|
||||
var hr;
|
||||
|
||||
hr = h / 360 * 2 * Math.PI;
|
||||
a = c * Math.cos(hr);
|
||||
b = c * Math.sin(hr);
|
||||
|
||||
return [l, a, b];
|
||||
};
|
||||
|
||||
convert.rgb.ansi16 = function (args) {
|
||||
var r = args[0];
|
||||
var g = args[1];
|
||||
var b = args[2];
|
||||
var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
|
||||
|
||||
value = Math.round(value / 50);
|
||||
|
||||
if (value === 0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
var ansi = 30
|
||||
+ ((Math.round(b / 255) << 2)
|
||||
| (Math.round(g / 255) << 1)
|
||||
| Math.round(r / 255));
|
||||
|
||||
if (value === 2) {
|
||||
ansi += 60;
|
||||
}
|
||||
|
||||
return ansi;
|
||||
};
|
||||
|
||||
convert.hsv.ansi16 = function (args) {
|
||||
// optimization here; we already know the value and don't need to get
|
||||
// it converted for us.
|
||||
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
||||
};
|
||||
|
||||
convert.rgb.ansi256 = function (args) {
|
||||
var r = args[0];
|
||||
var g = args[1];
|
||||
var b = args[2];
|
||||
|
||||
// we use the extended greyscale palette here, with the exception of
|
||||
// black and white. normal palette only has 4 greyscale shades.
|
||||
if (r === g && g === b) {
|
||||
if (r < 8) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
if (r > 248) {
|
||||
return 231;
|
||||
}
|
||||
|
||||
return Math.round(((r - 8) / 247) * 24) + 232;
|
||||
}
|
||||
|
||||
var ansi = 16
|
||||
+ (36 * Math.round(r / 255 * 5))
|
||||
+ (6 * Math.round(g / 255 * 5))
|
||||
+ Math.round(b / 255 * 5);
|
||||
|
||||
return ansi;
|
||||
};
|
||||
|
||||
convert.ansi16.rgb = function (args) {
|
||||
var color = args % 10;
|
||||
|
||||
// handle greyscale
|
||||
if (color === 0 || color === 7) {
|
||||
if (args > 50) {
|
||||
color += 3.5;
|
||||
}
|
||||
|
||||
color = color / 10.5 * 255;
|
||||
|
||||
return [color, color, color];
|
||||
}
|
||||
|
||||
var mult = (~~(args > 50) + 1) * 0.5;
|
||||
var r = ((color & 1) * mult) * 255;
|
||||
var g = (((color >> 1) & 1) * mult) * 255;
|
||||
var b = (((color >> 2) & 1) * mult) * 255;
|
||||
|
||||
return [r, g, b];
|
||||
};
|
||||
|
||||
convert.ansi256.rgb = function (args) {
|
||||
// handle greyscale
|
||||
if (args >= 232) {
|
||||
var c = (args - 232) * 10 + 8;
|
||||
return [c, c, c];
|
||||
}
|
||||
|
||||
args -= 16;
|
||||
|
||||
var rem;
|
||||
var r = Math.floor(args / 36) / 5 * 255;
|
||||
var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
||||
var b = (rem % 6) / 5 * 255;
|
||||
|
||||
return [r, g, b];
|
||||
};
|
||||
|
||||
convert.rgb.hex = function (args) {
|
||||
var integer = ((Math.round(args[0]) & 0xFF) << 16)
|
||||
+ ((Math.round(args[1]) & 0xFF) << 8)
|
||||
+ (Math.round(args[2]) & 0xFF);
|
||||
|
||||
var string = integer.toString(16).toUpperCase();
|
||||
return '000000'.substring(string.length) + string;
|
||||
};
|
||||
|
||||
convert.hex.rgb = function (args) {
|
||||
var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
||||
if (!match) {
|
||||
return [0, 0, 0];
|
||||
}
|
||||
|
||||
var colorString = match[0];
|
||||
|
||||
if (match[0].length === 3) {
|
||||
colorString = colorString.split('').map(function (char) {
|
||||
return char + char;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
var integer = parseInt(colorString, 16);
|
||||
var r = (integer >> 16) & 0xFF;
|
||||
var g = (integer >> 8) & 0xFF;
|
||||
var b = integer & 0xFF;
|
||||
|
||||
return [r, g, b];
|
||||
};
|
||||
|
||||
convert.rgb.hcg = function (rgb) {
|
||||
var r = rgb[0] / 255;
|
||||
var g = rgb[1] / 255;
|
||||
var b = rgb[2] / 255;
|
||||
var max = Math.max(Math.max(r, g), b);
|
||||
var min = Math.min(Math.min(r, g), b);
|
||||
var chroma = (max - min);
|
||||
var grayscale;
|
||||
var hue;
|
||||
|
||||
if (chroma < 1) {
|
||||
grayscale = min / (1 - chroma);
|
||||
} else {
|
||||
grayscale = 0;
|
||||
}
|
||||
|
||||
if (chroma <= 0) {
|
||||
hue = 0;
|
||||
} else
|
||||
if (max === r) {
|
||||
hue = ((g - b) / chroma) % 6;
|
||||
} else
|
||||
if (max === g) {
|
||||
hue = 2 + (b - r) / chroma;
|
||||
} else {
|
||||
hue = 4 + (r - g) / chroma + 4;
|
||||
}
|
||||
|
||||
hue /= 6;
|
||||
hue %= 1;
|
||||
|
||||
return [hue * 360, chroma * 100, grayscale * 100];
|
||||
};
|
||||
|
||||
convert.hsl.hcg = function (hsl) {
|
||||
var s = hsl[1] / 100;
|
||||
var l = hsl[2] / 100;
|
||||
var c = 1;
|
||||
var f = 0;
|
||||
|
||||
if (l < 0.5) {
|
||||
c = 2.0 * s * l;
|
||||
} else {
|
||||
c = 2.0 * s * (1.0 - l);
|
||||
}
|
||||
|
||||
if (c < 1.0) {
|
||||
f = (l - 0.5 * c) / (1.0 - c);
|
||||
}
|
||||
|
||||
return [hsl[0], c * 100, f * 100];
|
||||
};
|
||||
|
||||
convert.hsv.hcg = function (hsv) {
|
||||
var s = hsv[1] / 100;
|
||||
var v = hsv[2] / 100;
|
||||
|
||||
var c = s * v;
|
||||
var f = 0;
|
||||
|
||||
if (c < 1.0) {
|
||||
f = (v - c) / (1 - c);
|
||||
}
|
||||
|
||||
return [hsv[0], c * 100, f * 100];
|
||||
};
|
||||
|
||||
convert.hcg.rgb = function (hcg) {
|
||||
var h = hcg[0] / 360;
|
||||
var c = hcg[1] / 100;
|
||||
var g = hcg[2] / 100;
|
||||
|
||||
if (c === 0.0) {
|
||||
return [g * 255, g * 255, g * 255];
|
||||
}
|
||||
|
||||
var pure = [0, 0, 0];
|
||||
var hi = (h % 1) * 6;
|
||||
var v = hi % 1;
|
||||
var w = 1 - v;
|
||||
var mg = 0;
|
||||
|
||||
switch (Math.floor(hi)) {
|
||||
case 0:
|
||||
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
||||
case 1:
|
||||
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
||||
case 2:
|
||||
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
||||
case 3:
|
||||
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
||||
case 4:
|
||||
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
||||
default:
|
||||
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
||||
}
|
||||
|
||||
mg = (1.0 - c) * g;
|
||||
|
||||
return [
|
||||
(c * pure[0] + mg) * 255,
|
||||
(c * pure[1] + mg) * 255,
|
||||
(c * pure[2] + mg) * 255
|
||||
];
|
||||
};
|
||||
|
||||
convert.hcg.hsv = function (hcg) {
|
||||
var c = hcg[1] / 100;
|
||||
var g = hcg[2] / 100;
|
||||
|
||||
var v = c + g * (1.0 - c);
|
||||
var f = 0;
|
||||
|
||||
if (v > 0.0) {
|
||||
f = c / v;
|
||||
}
|
||||
|
||||
return [hcg[0], f * 100, v * 100];
|
||||
};
|
||||
|
||||
convert.hcg.hsl = function (hcg) {
|
||||
var c = hcg[1] / 100;
|
||||
var g = hcg[2] / 100;
|
||||
|
||||
var l = g * (1.0 - c) + 0.5 * c;
|
||||
var s = 0;
|
||||
|
||||
if (l > 0.0 && l < 0.5) {
|
||||
s = c / (2 * l);
|
||||
} else
|
||||
if (l >= 0.5 && l < 1.0) {
|
||||
s = c / (2 * (1 - l));
|
||||
}
|
||||
|
||||
return [hcg[0], s * 100, l * 100];
|
||||
};
|
||||
|
||||
convert.hcg.hwb = function (hcg) {
|
||||
var c = hcg[1] / 100;
|
||||
var g = hcg[2] / 100;
|
||||
var v = c + g * (1.0 - c);
|
||||
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
||||
};
|
||||
|
||||
convert.hwb.hcg = function (hwb) {
|
||||
var w = hwb[1] / 100;
|
||||
var b = hwb[2] / 100;
|
||||
var v = 1 - b;
|
||||
var c = v - w;
|
||||
var g = 0;
|
||||
|
||||
if (c < 1) {
|
||||
g = (v - c) / (1 - c);
|
||||
}
|
||||
|
||||
return [hwb[0], c * 100, g * 100];
|
||||
};
|
||||
|
||||
convert.apple.rgb = function (apple) {
|
||||
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
||||
};
|
||||
|
||||
convert.rgb.apple = function (rgb) {
|
||||
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
||||
};
|
||||
|
||||
convert.gray.rgb = function (args) {
|
||||
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
||||
};
|
||||
|
||||
convert.gray.hsl = convert.gray.hsv = function (args) {
|
||||
return [0, 0, args[0]];
|
||||
};
|
||||
|
||||
convert.gray.hwb = function (gray) {
|
||||
return [0, 100, gray[0]];
|
||||
};
|
||||
|
||||
convert.gray.cmyk = function (gray) {
|
||||
return [0, 0, 0, gray[0]];
|
||||
};
|
||||
|
||||
convert.gray.lab = function (gray) {
|
||||
return [gray[0], 0, 0];
|
||||
};
|
||||
|
||||
convert.gray.hex = function (gray) {
|
||||
var val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
||||
var integer = (val << 16) + (val << 8) + val;
|
||||
|
||||
var string = integer.toString(16).toUpperCase();
|
||||
return '000000'.substring(string.length) + string;
|
||||
};
|
||||
|
||||
convert.rgb.gray = function (rgb) {
|
||||
var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
||||
return [val / 255 * 100];
|
||||
};
|
||||
78
node_modules/color-convert/index.js
generated
vendored
Normal file
78
node_modules/color-convert/index.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
var conversions = require('./conversions');
|
||||
var route = require('./route');
|
||||
|
||||
var convert = {};
|
||||
|
||||
var models = Object.keys(conversions);
|
||||
|
||||
function wrapRaw(fn) {
|
||||
var wrappedFn = function (args) {
|
||||
if (args === undefined || args === null) {
|
||||
return args;
|
||||
}
|
||||
|
||||
if (arguments.length > 1) {
|
||||
args = Array.prototype.slice.call(arguments);
|
||||
}
|
||||
|
||||
return fn(args);
|
||||
};
|
||||
|
||||
// preserve .conversion property if there is one
|
||||
if ('conversion' in fn) {
|
||||
wrappedFn.conversion = fn.conversion;
|
||||
}
|
||||
|
||||
return wrappedFn;
|
||||
}
|
||||
|
||||
function wrapRounded(fn) {
|
||||
var wrappedFn = function (args) {
|
||||
if (args === undefined || args === null) {
|
||||
return args;
|
||||
}
|
||||
|
||||
if (arguments.length > 1) {
|
||||
args = Array.prototype.slice.call(arguments);
|
||||
}
|
||||
|
||||
var result = fn(args);
|
||||
|
||||
// we're assuming the result is an array here.
|
||||
// see notice in conversions.js; don't use box types
|
||||
// in conversion functions.
|
||||
if (typeof result === 'object') {
|
||||
for (var len = result.length, i = 0; i < len; i++) {
|
||||
result[i] = Math.round(result[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// preserve .conversion property if there is one
|
||||
if ('conversion' in fn) {
|
||||
wrappedFn.conversion = fn.conversion;
|
||||
}
|
||||
|
||||
return wrappedFn;
|
||||
}
|
||||
|
||||
models.forEach(function (fromModel) {
|
||||
convert[fromModel] = {};
|
||||
|
||||
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
||||
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
||||
|
||||
var routes = route(fromModel);
|
||||
var routeModels = Object.keys(routes);
|
||||
|
||||
routeModels.forEach(function (toModel) {
|
||||
var fn = routes[toModel];
|
||||
|
||||
convert[fromModel][toModel] = wrapRounded(fn);
|
||||
convert[fromModel][toModel].raw = wrapRaw(fn);
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = convert;
|
||||
97
node_modules/color-convert/route.js
generated
vendored
Normal file
97
node_modules/color-convert/route.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
var conversions = require('./conversions');
|
||||
|
||||
/*
|
||||
this function routes a model to all other models.
|
||||
|
||||
all functions that are routed have a property `.conversion` attached
|
||||
to the returned synthetic function. This property is an array
|
||||
of strings, each with the steps in between the 'from' and 'to'
|
||||
color models (inclusive).
|
||||
|
||||
conversions that are not possible simply are not included.
|
||||
*/
|
||||
|
||||
function buildGraph() {
|
||||
var graph = {};
|
||||
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
||||
var models = Object.keys(conversions);
|
||||
|
||||
for (var len = models.length, i = 0; i < len; i++) {
|
||||
graph[models[i]] = {
|
||||
// http://jsperf.com/1-vs-infinity
|
||||
// micro-opt, but this is simple.
|
||||
distance: -1,
|
||||
parent: null
|
||||
};
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Breadth-first_search
|
||||
function deriveBFS(fromModel) {
|
||||
var graph = buildGraph();
|
||||
var queue = [fromModel]; // unshift -> queue -> pop
|
||||
|
||||
graph[fromModel].distance = 0;
|
||||
|
||||
while (queue.length) {
|
||||
var current = queue.pop();
|
||||
var adjacents = Object.keys(conversions[current]);
|
||||
|
||||
for (var len = adjacents.length, i = 0; i < len; i++) {
|
||||
var adjacent = adjacents[i];
|
||||
var node = graph[adjacent];
|
||||
|
||||
if (node.distance === -1) {
|
||||
node.distance = graph[current].distance + 1;
|
||||
node.parent = current;
|
||||
queue.unshift(adjacent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
function link(from, to) {
|
||||
return function (args) {
|
||||
return to(from(args));
|
||||
};
|
||||
}
|
||||
|
||||
function wrapConversion(toModel, graph) {
|
||||
var path = [graph[toModel].parent, toModel];
|
||||
var fn = conversions[graph[toModel].parent][toModel];
|
||||
|
||||
var cur = graph[toModel].parent;
|
||||
while (graph[cur].parent) {
|
||||
path.unshift(graph[cur].parent);
|
||||
fn = link(conversions[graph[cur].parent][cur], fn);
|
||||
cur = graph[cur].parent;
|
||||
}
|
||||
|
||||
fn.conversion = path;
|
||||
return fn;
|
||||
}
|
||||
|
||||
module.exports = function (fromModel) {
|
||||
var graph = deriveBFS(fromModel);
|
||||
var conversion = {};
|
||||
|
||||
var models = Object.keys(graph);
|
||||
for (var len = models.length, i = 0; i < len; i++) {
|
||||
var toModel = models[i];
|
||||
var node = graph[toModel];
|
||||
|
||||
if (node.parent === null) {
|
||||
// no possible conversion, or this node is the source model.
|
||||
continue;
|
||||
}
|
||||
|
||||
conversion[toModel] = wrapConversion(toModel, graph);
|
||||
}
|
||||
|
||||
return conversion;
|
||||
};
|
||||
|
||||
152
node_modules/color-name/index.js
generated
vendored
Normal file
152
node_modules/color-name/index.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
"aliceblue": [240, 248, 255],
|
||||
"antiquewhite": [250, 235, 215],
|
||||
"aqua": [0, 255, 255],
|
||||
"aquamarine": [127, 255, 212],
|
||||
"azure": [240, 255, 255],
|
||||
"beige": [245, 245, 220],
|
||||
"bisque": [255, 228, 196],
|
||||
"black": [0, 0, 0],
|
||||
"blanchedalmond": [255, 235, 205],
|
||||
"blue": [0, 0, 255],
|
||||
"blueviolet": [138, 43, 226],
|
||||
"brown": [165, 42, 42],
|
||||
"burlywood": [222, 184, 135],
|
||||
"cadetblue": [95, 158, 160],
|
||||
"chartreuse": [127, 255, 0],
|
||||
"chocolate": [210, 105, 30],
|
||||
"coral": [255, 127, 80],
|
||||
"cornflowerblue": [100, 149, 237],
|
||||
"cornsilk": [255, 248, 220],
|
||||
"crimson": [220, 20, 60],
|
||||
"cyan": [0, 255, 255],
|
||||
"darkblue": [0, 0, 139],
|
||||
"darkcyan": [0, 139, 139],
|
||||
"darkgoldenrod": [184, 134, 11],
|
||||
"darkgray": [169, 169, 169],
|
||||
"darkgreen": [0, 100, 0],
|
||||
"darkgrey": [169, 169, 169],
|
||||
"darkkhaki": [189, 183, 107],
|
||||
"darkmagenta": [139, 0, 139],
|
||||
"darkolivegreen": [85, 107, 47],
|
||||
"darkorange": [255, 140, 0],
|
||||
"darkorchid": [153, 50, 204],
|
||||
"darkred": [139, 0, 0],
|
||||
"darksalmon": [233, 150, 122],
|
||||
"darkseagreen": [143, 188, 143],
|
||||
"darkslateblue": [72, 61, 139],
|
||||
"darkslategray": [47, 79, 79],
|
||||
"darkslategrey": [47, 79, 79],
|
||||
"darkturquoise": [0, 206, 209],
|
||||
"darkviolet": [148, 0, 211],
|
||||
"deeppink": [255, 20, 147],
|
||||
"deepskyblue": [0, 191, 255],
|
||||
"dimgray": [105, 105, 105],
|
||||
"dimgrey": [105, 105, 105],
|
||||
"dodgerblue": [30, 144, 255],
|
||||
"firebrick": [178, 34, 34],
|
||||
"floralwhite": [255, 250, 240],
|
||||
"forestgreen": [34, 139, 34],
|
||||
"fuchsia": [255, 0, 255],
|
||||
"gainsboro": [220, 220, 220],
|
||||
"ghostwhite": [248, 248, 255],
|
||||
"gold": [255, 215, 0],
|
||||
"goldenrod": [218, 165, 32],
|
||||
"gray": [128, 128, 128],
|
||||
"green": [0, 128, 0],
|
||||
"greenyellow": [173, 255, 47],
|
||||
"grey": [128, 128, 128],
|
||||
"honeydew": [240, 255, 240],
|
||||
"hotpink": [255, 105, 180],
|
||||
"indianred": [205, 92, 92],
|
||||
"indigo": [75, 0, 130],
|
||||
"ivory": [255, 255, 240],
|
||||
"khaki": [240, 230, 140],
|
||||
"lavender": [230, 230, 250],
|
||||
"lavenderblush": [255, 240, 245],
|
||||
"lawngreen": [124, 252, 0],
|
||||
"lemonchiffon": [255, 250, 205],
|
||||
"lightblue": [173, 216, 230],
|
||||
"lightcoral": [240, 128, 128],
|
||||
"lightcyan": [224, 255, 255],
|
||||
"lightgoldenrodyellow": [250, 250, 210],
|
||||
"lightgray": [211, 211, 211],
|
||||
"lightgreen": [144, 238, 144],
|
||||
"lightgrey": [211, 211, 211],
|
||||
"lightpink": [255, 182, 193],
|
||||
"lightsalmon": [255, 160, 122],
|
||||
"lightseagreen": [32, 178, 170],
|
||||
"lightskyblue": [135, 206, 250],
|
||||
"lightslategray": [119, 136, 153],
|
||||
"lightslategrey": [119, 136, 153],
|
||||
"lightsteelblue": [176, 196, 222],
|
||||
"lightyellow": [255, 255, 224],
|
||||
"lime": [0, 255, 0],
|
||||
"limegreen": [50, 205, 50],
|
||||
"linen": [250, 240, 230],
|
||||
"magenta": [255, 0, 255],
|
||||
"maroon": [128, 0, 0],
|
||||
"mediumaquamarine": [102, 205, 170],
|
||||
"mediumblue": [0, 0, 205],
|
||||
"mediumorchid": [186, 85, 211],
|
||||
"mediumpurple": [147, 112, 219],
|
||||
"mediumseagreen": [60, 179, 113],
|
||||
"mediumslateblue": [123, 104, 238],
|
||||
"mediumspringgreen": [0, 250, 154],
|
||||
"mediumturquoise": [72, 209, 204],
|
||||
"mediumvioletred": [199, 21, 133],
|
||||
"midnightblue": [25, 25, 112],
|
||||
"mintcream": [245, 255, 250],
|
||||
"mistyrose": [255, 228, 225],
|
||||
"moccasin": [255, 228, 181],
|
||||
"navajowhite": [255, 222, 173],
|
||||
"navy": [0, 0, 128],
|
||||
"oldlace": [253, 245, 230],
|
||||
"olive": [128, 128, 0],
|
||||
"olivedrab": [107, 142, 35],
|
||||
"orange": [255, 165, 0],
|
||||
"orangered": [255, 69, 0],
|
||||
"orchid": [218, 112, 214],
|
||||
"palegoldenrod": [238, 232, 170],
|
||||
"palegreen": [152, 251, 152],
|
||||
"paleturquoise": [175, 238, 238],
|
||||
"palevioletred": [219, 112, 147],
|
||||
"papayawhip": [255, 239, 213],
|
||||
"peachpuff": [255, 218, 185],
|
||||
"peru": [205, 133, 63],
|
||||
"pink": [255, 192, 203],
|
||||
"plum": [221, 160, 221],
|
||||
"powderblue": [176, 224, 230],
|
||||
"purple": [128, 0, 128],
|
||||
"rebeccapurple": [102, 51, 153],
|
||||
"red": [255, 0, 0],
|
||||
"rosybrown": [188, 143, 143],
|
||||
"royalblue": [65, 105, 225],
|
||||
"saddlebrown": [139, 69, 19],
|
||||
"salmon": [250, 128, 114],
|
||||
"sandybrown": [244, 164, 96],
|
||||
"seagreen": [46, 139, 87],
|
||||
"seashell": [255, 245, 238],
|
||||
"sienna": [160, 82, 45],
|
||||
"silver": [192, 192, 192],
|
||||
"skyblue": [135, 206, 235],
|
||||
"slateblue": [106, 90, 205],
|
||||
"slategray": [112, 128, 144],
|
||||
"slategrey": [112, 128, 144],
|
||||
"snow": [255, 250, 250],
|
||||
"springgreen": [0, 255, 127],
|
||||
"steelblue": [70, 130, 180],
|
||||
"tan": [210, 180, 140],
|
||||
"teal": [0, 128, 128],
|
||||
"thistle": [216, 191, 216],
|
||||
"tomato": [255, 99, 71],
|
||||
"turquoise": [64, 224, 208],
|
||||
"violet": [238, 130, 238],
|
||||
"wheat": [245, 222, 179],
|
||||
"white": [255, 255, 255],
|
||||
"whitesmoke": [245, 245, 245],
|
||||
"yellow": [255, 255, 0],
|
||||
"yellowgreen": [154, 205, 50]
|
||||
};
|
||||
7
node_modules/color-name/test.js
generated
vendored
Normal file
7
node_modules/color-name/test.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
var names = require('./');
|
||||
var assert = require('assert');
|
||||
|
||||
assert.deepEqual(names.red, [255,0,0]);
|
||||
assert.deepEqual(names.aliceblue, [240,248,255]);
|
||||
1103
node_modules/commander/index.js
generated
vendored
Normal file
1103
node_modules/commander/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13
node_modules/concat-map/index.js
generated
vendored
Normal file
13
node_modules/concat-map/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = function (xs, fn) {
|
||||
var res = [];
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
var x = fn(xs[i], i);
|
||||
if (isArray(x)) res.push.apply(res, x);
|
||||
else res.push(x);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
var isArray = Array.isArray || function (xs) {
|
||||
return Object.prototype.toString.call(xs) === '[object Array]';
|
||||
};
|
||||
22
node_modules/config-chain/LICENCE
generated
vendored
Normal file
22
node_modules/config-chain/LICENCE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2011 Dominic Tarr
|
||||
|
||||
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.
|
||||
282
node_modules/config-chain/index.js
generated
vendored
Executable file
282
node_modules/config-chain/index.js
generated
vendored
Executable file
@@ -0,0 +1,282 @@
|
||||
var ProtoList = require('proto-list')
|
||||
, path = require('path')
|
||||
, fs = require('fs')
|
||||
, ini = require('ini')
|
||||
, EE = require('events').EventEmitter
|
||||
, url = require('url')
|
||||
, http = require('http')
|
||||
|
||||
var exports = module.exports = function () {
|
||||
var args = [].slice.call(arguments)
|
||||
, conf = new ConfigChain()
|
||||
|
||||
while(args.length) {
|
||||
var a = args.shift()
|
||||
if(a) conf.push
|
||||
( 'string' === typeof a
|
||||
? json(a)
|
||||
: a )
|
||||
}
|
||||
|
||||
return conf
|
||||
}
|
||||
|
||||
//recursively find a file...
|
||||
|
||||
var find = exports.find = function () {
|
||||
var rel = path.join.apply(null, [].slice.call(arguments))
|
||||
|
||||
function find(start, rel) {
|
||||
var file = path.join(start, rel)
|
||||
try {
|
||||
fs.statSync(file)
|
||||
return file
|
||||
} catch (err) {
|
||||
if(path.dirname(start) !== start) // root
|
||||
return find(path.dirname(start), rel)
|
||||
}
|
||||
}
|
||||
return find(__dirname, rel)
|
||||
}
|
||||
|
||||
var parse = exports.parse = function (content, file, type) {
|
||||
content = '' + content
|
||||
// if we don't know what it is, try json and fall back to ini
|
||||
// if we know what it is, then it must be that.
|
||||
if (!type) {
|
||||
try { return JSON.parse(content) }
|
||||
catch (er) { return ini.parse(content) }
|
||||
} else if (type === 'json') {
|
||||
if (this.emit) {
|
||||
try { return JSON.parse(content) }
|
||||
catch (er) { this.emit('error', er) }
|
||||
} else {
|
||||
return JSON.parse(content)
|
||||
}
|
||||
} else {
|
||||
return ini.parse(content)
|
||||
}
|
||||
}
|
||||
|
||||
var json = exports.json = function () {
|
||||
var args = [].slice.call(arguments).filter(function (arg) { return arg != null })
|
||||
var file = path.join.apply(null, args)
|
||||
var content
|
||||
try {
|
||||
content = fs.readFileSync(file,'utf-8')
|
||||
} catch (err) {
|
||||
return
|
||||
}
|
||||
return parse(content, file, 'json')
|
||||
}
|
||||
|
||||
var env = exports.env = function (prefix, env) {
|
||||
env = env || process.env
|
||||
var obj = {}
|
||||
var l = prefix.length
|
||||
for(var k in env) {
|
||||
if(k.indexOf(prefix) === 0)
|
||||
obj[k.substring(l)] = env[k]
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
exports.ConfigChain = ConfigChain
|
||||
function ConfigChain () {
|
||||
EE.apply(this)
|
||||
ProtoList.apply(this, arguments)
|
||||
this._awaiting = 0
|
||||
this._saving = 0
|
||||
this.sources = {}
|
||||
}
|
||||
|
||||
// multi-inheritance-ish
|
||||
var extras = {
|
||||
constructor: { value: ConfigChain }
|
||||
}
|
||||
Object.keys(EE.prototype).forEach(function (k) {
|
||||
extras[k] = Object.getOwnPropertyDescriptor(EE.prototype, k)
|
||||
})
|
||||
ConfigChain.prototype = Object.create(ProtoList.prototype, extras)
|
||||
|
||||
ConfigChain.prototype.del = function (key, where) {
|
||||
// if not specified where, then delete from the whole chain, scorched
|
||||
// earth style
|
||||
if (where) {
|
||||
var target = this.sources[where]
|
||||
target = target && target.data
|
||||
if (!target) {
|
||||
return this.emit('error', new Error('not found '+where))
|
||||
}
|
||||
delete target[key]
|
||||
} else {
|
||||
for (var i = 0, l = this.list.length; i < l; i ++) {
|
||||
delete this.list[i][key]
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigChain.prototype.set = function (key, value, where) {
|
||||
var target
|
||||
|
||||
if (where) {
|
||||
target = this.sources[where]
|
||||
target = target && target.data
|
||||
if (!target) {
|
||||
return this.emit('error', new Error('not found '+where))
|
||||
}
|
||||
} else {
|
||||
target = this.list[0]
|
||||
if (!target) {
|
||||
return this.emit('error', new Error('cannot set, no confs!'))
|
||||
}
|
||||
}
|
||||
target[key] = value
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigChain.prototype.get = function (key, where) {
|
||||
if (where) {
|
||||
where = this.sources[where]
|
||||
if (where) where = where.data
|
||||
if (where && Object.hasOwnProperty.call(where, key)) return where[key]
|
||||
return undefined
|
||||
}
|
||||
return this.list[0][key]
|
||||
}
|
||||
|
||||
ConfigChain.prototype.save = function (where, type, cb) {
|
||||
if (typeof type === 'function') cb = type, type = null
|
||||
var target = this.sources[where]
|
||||
if (!target || !(target.path || target.source) || !target.data) {
|
||||
// TODO: maybe save() to a url target could be a PUT or something?
|
||||
// would be easy to swap out with a reddis type thing, too
|
||||
return this.emit('error', new Error('bad save target: '+where))
|
||||
}
|
||||
|
||||
if (target.source) {
|
||||
var pref = target.prefix || ''
|
||||
Object.keys(target.data).forEach(function (k) {
|
||||
target.source[pref + k] = target.data[k]
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
var type = type || target.type
|
||||
var data = target.data
|
||||
if (target.type === 'json') {
|
||||
data = JSON.stringify(data)
|
||||
} else {
|
||||
data = ini.stringify(data)
|
||||
}
|
||||
|
||||
this._saving ++
|
||||
fs.writeFile(target.path, data, 'utf8', function (er) {
|
||||
this._saving --
|
||||
if (er) {
|
||||
if (cb) return cb(er)
|
||||
else return this.emit('error', er)
|
||||
}
|
||||
if (this._saving === 0) {
|
||||
if (cb) cb()
|
||||
this.emit('save')
|
||||
}
|
||||
}.bind(this))
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigChain.prototype.addFile = function (file, type, name) {
|
||||
name = name || file
|
||||
var marker = {__source__:name}
|
||||
this.sources[name] = { path: file, type: type }
|
||||
this.push(marker)
|
||||
this._await()
|
||||
fs.readFile(file, 'utf8', function (er, data) {
|
||||
if (er) this.emit('error', er)
|
||||
this.addString(data, file, type, marker)
|
||||
}.bind(this))
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigChain.prototype.addEnv = function (prefix, env, name) {
|
||||
name = name || 'env'
|
||||
var data = exports.env(prefix, env)
|
||||
this.sources[name] = { data: data, source: env, prefix: prefix }
|
||||
return this.add(data, name)
|
||||
}
|
||||
|
||||
ConfigChain.prototype.addUrl = function (req, type, name) {
|
||||
this._await()
|
||||
var href = url.format(req)
|
||||
name = name || href
|
||||
var marker = {__source__:name}
|
||||
this.sources[name] = { href: href, type: type }
|
||||
this.push(marker)
|
||||
http.request(req, function (res) {
|
||||
var c = []
|
||||
var ct = res.headers['content-type']
|
||||
if (!type) {
|
||||
type = ct.indexOf('json') !== -1 ? 'json'
|
||||
: ct.indexOf('ini') !== -1 ? 'ini'
|
||||
: href.match(/\.json$/) ? 'json'
|
||||
: href.match(/\.ini$/) ? 'ini'
|
||||
: null
|
||||
marker.type = type
|
||||
}
|
||||
|
||||
res.on('data', c.push.bind(c))
|
||||
.on('end', function () {
|
||||
this.addString(Buffer.concat(c), href, type, marker)
|
||||
}.bind(this))
|
||||
.on('error', this.emit.bind(this, 'error'))
|
||||
|
||||
}.bind(this))
|
||||
.on('error', this.emit.bind(this, 'error'))
|
||||
.end()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigChain.prototype.addString = function (data, file, type, marker) {
|
||||
data = this.parse(data, file, type)
|
||||
this.add(data, marker)
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigChain.prototype.add = function (data, marker) {
|
||||
if (marker && typeof marker === 'object') {
|
||||
var i = this.list.indexOf(marker)
|
||||
if (i === -1) {
|
||||
return this.emit('error', new Error('bad marker'))
|
||||
}
|
||||
this.splice(i, 1, data)
|
||||
marker = marker.__source__
|
||||
this.sources[marker] = this.sources[marker] || {}
|
||||
this.sources[marker].data = data
|
||||
// we were waiting for this. maybe emit 'load'
|
||||
this._resolve()
|
||||
} else {
|
||||
if (typeof marker === 'string') {
|
||||
this.sources[marker] = this.sources[marker] || {}
|
||||
this.sources[marker].data = data
|
||||
}
|
||||
// trigger the load event if nothing was already going to do so.
|
||||
this._await()
|
||||
this.push(data)
|
||||
process.nextTick(this._resolve.bind(this))
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
ConfigChain.prototype.parse = exports.parse
|
||||
|
||||
ConfigChain.prototype._await = function () {
|
||||
this._awaiting++
|
||||
}
|
||||
|
||||
ConfigChain.prototype._resolve = function () {
|
||||
this._awaiting--
|
||||
if (this._awaiting === 0) this.emit('load', this)
|
||||
}
|
||||
107
node_modules/core-util-is/lib/util.js
generated
vendored
Normal file
107
node_modules/core-util-is/lib/util.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
// 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.
|
||||
|
||||
// NOTE: These type checking functions intentionally don't use `instanceof`
|
||||
// because it is fragile and can be easily faked with `Object.create()`.
|
||||
|
||||
function isArray(arg) {
|
||||
if (Array.isArray) {
|
||||
return Array.isArray(arg);
|
||||
}
|
||||
return objectToString(arg) === '[object Array]';
|
||||
}
|
||||
exports.isArray = isArray;
|
||||
|
||||
function isBoolean(arg) {
|
||||
return typeof arg === 'boolean';
|
||||
}
|
||||
exports.isBoolean = isBoolean;
|
||||
|
||||
function isNull(arg) {
|
||||
return arg === null;
|
||||
}
|
||||
exports.isNull = isNull;
|
||||
|
||||
function isNullOrUndefined(arg) {
|
||||
return arg == null;
|
||||
}
|
||||
exports.isNullOrUndefined = isNullOrUndefined;
|
||||
|
||||
function isNumber(arg) {
|
||||
return typeof arg === 'number';
|
||||
}
|
||||
exports.isNumber = isNumber;
|
||||
|
||||
function isString(arg) {
|
||||
return typeof arg === 'string';
|
||||
}
|
||||
exports.isString = isString;
|
||||
|
||||
function isSymbol(arg) {
|
||||
return typeof arg === 'symbol';
|
||||
}
|
||||
exports.isSymbol = isSymbol;
|
||||
|
||||
function isUndefined(arg) {
|
||||
return arg === void 0;
|
||||
}
|
||||
exports.isUndefined = isUndefined;
|
||||
|
||||
function isRegExp(re) {
|
||||
return objectToString(re) === '[object RegExp]';
|
||||
}
|
||||
exports.isRegExp = isRegExp;
|
||||
|
||||
function isObject(arg) {
|
||||
return typeof arg === 'object' && arg !== null;
|
||||
}
|
||||
exports.isObject = isObject;
|
||||
|
||||
function isDate(d) {
|
||||
return objectToString(d) === '[object Date]';
|
||||
}
|
||||
exports.isDate = isDate;
|
||||
|
||||
function isError(e) {
|
||||
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
||||
}
|
||||
exports.isError = isError;
|
||||
|
||||
function isFunction(arg) {
|
||||
return typeof arg === 'function';
|
||||
}
|
||||
exports.isFunction = isFunction;
|
||||
|
||||
function isPrimitive(arg) {
|
||||
return arg === null ||
|
||||
typeof arg === 'boolean' ||
|
||||
typeof arg === 'number' ||
|
||||
typeof arg === 'string' ||
|
||||
typeof arg === 'symbol' || // ES6 symbol
|
||||
typeof arg === 'undefined';
|
||||
}
|
||||
exports.isPrimitive = isPrimitive;
|
||||
|
||||
exports.isBuffer = Buffer.isBuffer;
|
||||
|
||||
function objectToString(o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
}
|
||||
68
node_modules/core-util-is/test.js
generated
vendored
Normal file
68
node_modules/core-util-is/test.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
var assert = require('tap');
|
||||
|
||||
var t = require('./lib/util');
|
||||
|
||||
assert.equal(t.isArray([]), true);
|
||||
assert.equal(t.isArray({}), false);
|
||||
|
||||
assert.equal(t.isBoolean(null), false);
|
||||
assert.equal(t.isBoolean(true), true);
|
||||
assert.equal(t.isBoolean(false), true);
|
||||
|
||||
assert.equal(t.isNull(null), true);
|
||||
assert.equal(t.isNull(undefined), false);
|
||||
assert.equal(t.isNull(false), false);
|
||||
assert.equal(t.isNull(), false);
|
||||
|
||||
assert.equal(t.isNullOrUndefined(null), true);
|
||||
assert.equal(t.isNullOrUndefined(undefined), true);
|
||||
assert.equal(t.isNullOrUndefined(false), false);
|
||||
assert.equal(t.isNullOrUndefined(), true);
|
||||
|
||||
assert.equal(t.isNumber(null), false);
|
||||
assert.equal(t.isNumber('1'), false);
|
||||
assert.equal(t.isNumber(1), true);
|
||||
|
||||
assert.equal(t.isString(null), false);
|
||||
assert.equal(t.isString('1'), true);
|
||||
assert.equal(t.isString(1), false);
|
||||
|
||||
assert.equal(t.isSymbol(null), false);
|
||||
assert.equal(t.isSymbol('1'), false);
|
||||
assert.equal(t.isSymbol(1), false);
|
||||
assert.equal(t.isSymbol(Symbol()), true);
|
||||
|
||||
assert.equal(t.isUndefined(null), false);
|
||||
assert.equal(t.isUndefined(undefined), true);
|
||||
assert.equal(t.isUndefined(false), false);
|
||||
assert.equal(t.isUndefined(), true);
|
||||
|
||||
assert.equal(t.isRegExp(null), false);
|
||||
assert.equal(t.isRegExp('1'), false);
|
||||
assert.equal(t.isRegExp(new RegExp()), true);
|
||||
|
||||
assert.equal(t.isObject({}), true);
|
||||
assert.equal(t.isObject([]), true);
|
||||
assert.equal(t.isObject(new RegExp()), true);
|
||||
assert.equal(t.isObject(new Date()), true);
|
||||
|
||||
assert.equal(t.isDate(null), false);
|
||||
assert.equal(t.isDate('1'), false);
|
||||
assert.equal(t.isDate(new Date()), true);
|
||||
|
||||
assert.equal(t.isError(null), false);
|
||||
assert.equal(t.isError({ err: true }), false);
|
||||
assert.equal(t.isError(new Error()), true);
|
||||
|
||||
assert.equal(t.isFunction(null), false);
|
||||
assert.equal(t.isFunction({ }), false);
|
||||
assert.equal(t.isFunction(function() {}), true);
|
||||
|
||||
assert.equal(t.isPrimitive(null), true);
|
||||
assert.equal(t.isPrimitive(''), true);
|
||||
assert.equal(t.isPrimitive(0), true);
|
||||
assert.equal(t.isPrimitive(new Date()), false);
|
||||
|
||||
assert.equal(t.isBuffer(null), false);
|
||||
assert.equal(t.isBuffer({}), false);
|
||||
assert.equal(t.isBuffer(new Buffer(0)), true);
|
||||
44
node_modules/create-error-class/index.js
generated
vendored
Normal file
44
node_modules/create-error-class/index.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
var captureStackTrace = require('capture-stack-trace');
|
||||
|
||||
function inherits(ctor, superCtor) {
|
||||
ctor.super_ = superCtor;
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function createErrorClass(className, setup) {
|
||||
if (typeof className !== 'string') {
|
||||
throw new TypeError('Expected className to be a string');
|
||||
}
|
||||
|
||||
if (/[^0-9a-zA-Z_$]/.test(className)) {
|
||||
throw new Error('className contains invalid characters');
|
||||
}
|
||||
|
||||
setup = setup || function (message) {
|
||||
this.message = message;
|
||||
};
|
||||
|
||||
var ErrorClass = function () {
|
||||
Object.defineProperty(this, 'name', {
|
||||
configurable: true,
|
||||
value: className,
|
||||
writable: true
|
||||
});
|
||||
|
||||
captureStackTrace(this, this.constructor);
|
||||
|
||||
setup.apply(this, arguments);
|
||||
};
|
||||
|
||||
inherits(ErrorClass, Error);
|
||||
|
||||
return ErrorClass;
|
||||
};
|
||||
59
node_modules/decompress-tar/index.js
generated
vendored
Normal file
59
node_modules/decompress-tar/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
const fileType = require('file-type');
|
||||
const isStream = require('is-stream');
|
||||
const tarStream = require('tar-stream');
|
||||
|
||||
module.exports = () => input => {
|
||||
if (!Buffer.isBuffer(input) && !isStream(input)) {
|
||||
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'tar')) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
const extract = tarStream.extract();
|
||||
const files = [];
|
||||
|
||||
extract.on('entry', (header, stream, cb) => {
|
||||
const chunk = [];
|
||||
|
||||
stream.on('data', data => chunk.push(data));
|
||||
stream.on('end', () => {
|
||||
const file = {
|
||||
data: Buffer.concat(chunk),
|
||||
mode: header.mode,
|
||||
mtime: header.mtime,
|
||||
path: header.name,
|
||||
type: header.type
|
||||
};
|
||||
|
||||
if (header.type === 'symlink' || header.type === 'link') {
|
||||
file.linkname = header.linkname;
|
||||
}
|
||||
|
||||
files.push(file);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
if (!Buffer.isBuffer(input)) {
|
||||
input.on('error', reject);
|
||||
}
|
||||
|
||||
extract.on('finish', () => resolve(files));
|
||||
extract.on('error', reject);
|
||||
});
|
||||
|
||||
extract.then = promise.then.bind(promise);
|
||||
extract.catch = promise.catch.bind(promise);
|
||||
|
||||
if (Buffer.isBuffer(input)) {
|
||||
extract.end(input);
|
||||
} else {
|
||||
input.pipe(extract);
|
||||
}
|
||||
|
||||
return extract;
|
||||
};
|
||||
22
node_modules/decompress-tarbz2/index.js
generated
vendored
Normal file
22
node_modules/decompress-tarbz2/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
const decompressTar = require('decompress-tar');
|
||||
const fileType = require('file-type');
|
||||
const isStream = require('is-stream');
|
||||
const seekBzip = require('seek-bzip');
|
||||
const unbzip2Stream = require('unbzip2-stream');
|
||||
|
||||
module.exports = () => input => {
|
||||
if (!Buffer.isBuffer(input) && !isStream(input)) {
|
||||
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'bz2')) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(input)) {
|
||||
return decompressTar()(seekBzip.decode(input));
|
||||
}
|
||||
|
||||
return decompressTar()(input.pipe(unbzip2Stream()));
|
||||
};
|
||||
599
node_modules/decompress-tarbz2/node_modules/file-type/index.js
generated
vendored
Normal file
599
node_modules/decompress-tarbz2/node_modules/file-type/index.js
generated
vendored
Normal file
@@ -0,0 +1,599 @@
|
||||
'use strict';
|
||||
const toBytes = s => Array.from(s).map(c => c.charCodeAt(0));
|
||||
const xpiZipFilename = toBytes('META-INF/mozilla.rsa');
|
||||
const oxmlContentTypes = toBytes('[Content_Types].xml');
|
||||
const oxmlRels = toBytes('_rels/.rels');
|
||||
|
||||
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 a bitmask is set
|
||||
if (opts.mask) {
|
||||
// If header doesn't equal `buf` with bits masked off
|
||||
if (header[i] !== (opts.mask[i] & buf[i + opts.offset])) {
|
||||
return false;
|
||||
}
|
||||
} else 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'
|
||||
};
|
||||
}
|
||||
|
||||
// Zip-based file formats
|
||||
// Need to be before the `zip` check
|
||||
if (check([0x50, 0x4B, 0x3, 0x4])) {
|
||||
if (
|
||||
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'
|
||||
};
|
||||
}
|
||||
|
||||
// Assumes signed `.xpi` from addons.mozilla.org
|
||||
if (check(xpiZipFilename, {offset: 30})) {
|
||||
return {
|
||||
ext: 'xpi',
|
||||
mime: 'application/x-xpinstall'
|
||||
};
|
||||
}
|
||||
|
||||
// https://github.com/file/file/blob/master/magic/Magdir/msooxml
|
||||
if (check(oxmlContentTypes, {offset: 30}) || check(oxmlRels, {offset: 30})) {
|
||||
const sliced = buf.subarray(4, 4 + 2000);
|
||||
const nextZipHeaderIndex = arr => arr.findIndex((el, i, arr) => arr[i] === 0x50 && arr[i + 1] === 0x4B && arr[i + 2] === 0x3 && arr[i + 3] === 0x4);
|
||||
const header2Pos = nextZipHeaderIndex(sliced);
|
||||
|
||||
if (header2Pos !== -1) {
|
||||
const slicedAgain = buf.subarray(header2Pos + 8, header2Pos + 8 + 1000);
|
||||
const header3Pos = nextZipHeaderIndex(slicedAgain);
|
||||
|
||||
if (header3Pos !== -1) {
|
||||
const offset = 8 + header2Pos + header3Pos + 30;
|
||||
|
||||
if (check(toBytes('word/'), {offset})) {
|
||||
return {
|
||||
ext: 'docx',
|
||||
mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||
};
|
||||
}
|
||||
|
||||
if (check(toBytes('ppt/'), {offset})) {
|
||||
return {
|
||||
ext: 'pptx',
|
||||
mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
||||
};
|
||||
}
|
||||
|
||||
if (check(toBytes('xl/'), {offset})) {
|
||||
return {
|
||||
ext: 'xlsx',
|
||||
mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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([0x33, 0x67, 0x70, 0x35]) || // 3gp5
|
||||
(
|
||||
check([0x0, 0x0, 0x0]) && check([0x66, 0x74, 0x79, 0x70], {offset: 4}) &&
|
||||
(
|
||||
check([0x6D, 0x70, 0x34, 0x31], {offset: 8}) || // MP41
|
||||
check([0x6D, 0x70, 0x34, 0x32], {offset: 8}) || // MP42
|
||||
check([0x69, 0x73, 0x6F, 0x6D], {offset: 8}) || // ISOM
|
||||
check([0x69, 0x73, 0x6F, 0x32], {offset: 8}) || // ISO2
|
||||
check([0x6D, 0x6D, 0x70, 0x34], {offset: 8}) || // MMP4
|
||||
check([0x4D, 0x34, 0x56], {offset: 8}) || // M4V
|
||||
check([0x64, 0x61, 0x73, 0x68], {offset: 8}) // DASH
|
||||
)
|
||||
)) {
|
||||
return {
|
||||
ext: 'mp4',
|
||||
mime: 'video/mp4'
|
||||
};
|
||||
}
|
||||
|
||||
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 !== -1) {
|
||||
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'
|
||||
};
|
||||
}
|
||||
|
||||
// Check for MP3 header at different starting offsets
|
||||
for (let start = 0; start < 2 && start < (buf.length - 16); start++) {
|
||||
if (
|
||||
check([0x49, 0x44, 0x33], {offset: start}) || // ID3 header
|
||||
check([0xFF, 0xE2], {offset: start, mask: [0xFF, 0xE2]}) // MPEG 1 or 2 Layer 3 header
|
||||
) {
|
||||
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;
|
||||
};
|
||||
26
node_modules/decompress-targz/index.js
generated
vendored
Normal file
26
node_modules/decompress-targz/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
const zlib = require('zlib');
|
||||
const decompressTar = require('decompress-tar');
|
||||
const fileType = require('file-type');
|
||||
const isStream = require('is-stream');
|
||||
|
||||
module.exports = () => input => {
|
||||
if (!Buffer.isBuffer(input) && !isStream(input)) {
|
||||
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'gz')) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
const unzip = zlib.createGunzip();
|
||||
const result = decompressTar()(unzip);
|
||||
|
||||
if (Buffer.isBuffer(input)) {
|
||||
unzip.end(input);
|
||||
} else {
|
||||
input.pipe(unzip);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
86
node_modules/decompress-unzip/index.js
generated
vendored
Normal file
86
node_modules/decompress-unzip/index.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
'use strict';
|
||||
const fileType = require('file-type');
|
||||
const getStream = require('get-stream');
|
||||
const pify = require('pify');
|
||||
const yauzl = require('yauzl');
|
||||
|
||||
const getType = (entry, mode) => {
|
||||
const IFMT = 61440;
|
||||
const IFDIR = 16384;
|
||||
const IFLNK = 40960;
|
||||
const madeBy = entry.versionMadeBy >> 8;
|
||||
|
||||
if ((mode & IFMT) === IFLNK) {
|
||||
return 'symlink';
|
||||
}
|
||||
|
||||
if ((mode & IFMT) === IFDIR || (madeBy === 0 && entry.externalFileAttributes === 16)) {
|
||||
return 'directory';
|
||||
}
|
||||
|
||||
return 'file';
|
||||
};
|
||||
|
||||
const extractEntry = (entry, zip) => {
|
||||
const file = {
|
||||
mode: (entry.externalFileAttributes >> 16) & 0xFFFF,
|
||||
mtime: entry.getLastModDate(),
|
||||
path: entry.fileName
|
||||
};
|
||||
|
||||
file.type = getType(entry, file.mode);
|
||||
|
||||
if (file.mode === 0 && file.type === 'directory') {
|
||||
file.mode = 493;
|
||||
}
|
||||
|
||||
if (file.mode === 0) {
|
||||
file.mode = 420;
|
||||
}
|
||||
|
||||
return pify(zip.openReadStream.bind(zip))(entry)
|
||||
.then(getStream.buffer)
|
||||
.then(buf => {
|
||||
file.data = buf;
|
||||
|
||||
if (file.type === 'symlink') {
|
||||
file.linkname = buf.toString();
|
||||
}
|
||||
|
||||
return file;
|
||||
})
|
||||
.catch(err => {
|
||||
zip.close();
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
|
||||
const extractFile = zip => new Promise((resolve, reject) => {
|
||||
const files = [];
|
||||
|
||||
zip.readEntry();
|
||||
|
||||
zip.on('entry', entry => {
|
||||
extractEntry(entry, zip)
|
||||
.catch(reject)
|
||||
.then(file => {
|
||||
files.push(file);
|
||||
zip.readEntry();
|
||||
});
|
||||
});
|
||||
|
||||
zip.on('error', reject);
|
||||
zip.on('end', () => resolve(files));
|
||||
});
|
||||
|
||||
module.exports = () => buf => {
|
||||
if (!Buffer.isBuffer(buf)) {
|
||||
return Promise.reject(new TypeError(`Expected a Buffer, got ${typeof buf}`));
|
||||
}
|
||||
|
||||
if (!fileType(buf) || fileType(buf).ext !== 'zip') {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
return pify(yauzl.fromBuffer)(buf, {lazyEntries: true}).then(extractFile);
|
||||
};
|
||||
452
node_modules/decompress-unzip/node_modules/file-type/index.js
generated
vendored
Normal file
452
node_modules/decompress-unzip/node_modules/file-type/index.js
generated
vendored
Normal file
@@ -0,0 +1,452 @@
|
||||
'use strict';
|
||||
module.exports = function (buf) {
|
||||
if (!(buf && buf.length > 1)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) {
|
||||
return {
|
||||
ext: 'jpg',
|
||||
mime: 'image/jpeg'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) {
|
||||
return {
|
||||
ext: 'png',
|
||||
mime: 'image/png'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) {
|
||||
return {
|
||||
ext: 'gif',
|
||||
mime: 'image/gif'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
|
||||
return {
|
||||
ext: 'webp',
|
||||
mime: 'image/webp'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x49 && buf[3] === 0x46) {
|
||||
return {
|
||||
ext: 'flif',
|
||||
mime: 'image/flif'
|
||||
};
|
||||
}
|
||||
|
||||
// needs to be before `tif` check
|
||||
if (((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) && buf[8] === 0x43 && buf[9] === 0x52) {
|
||||
return {
|
||||
ext: 'cr2',
|
||||
mime: 'image/x-canon-cr2'
|
||||
};
|
||||
}
|
||||
|
||||
if ((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) {
|
||||
return {
|
||||
ext: 'tif',
|
||||
mime: 'image/tiff'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x42 && buf[1] === 0x4D) {
|
||||
return {
|
||||
ext: 'bmp',
|
||||
mime: 'image/bmp'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) {
|
||||
return {
|
||||
ext: 'jxr',
|
||||
mime: 'image/vnd.ms-photo'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) {
|
||||
return {
|
||||
ext: 'psd',
|
||||
mime: 'image/vnd.adobe.photoshop'
|
||||
};
|
||||
}
|
||||
|
||||
// needs to be before `zip` check
|
||||
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x6D && buf[31] === 0x69 && buf[32] === 0x6D && buf[33] === 0x65 && buf[34] === 0x74 && buf[35] === 0x79 && buf[36] === 0x70 && buf[37] === 0x65 && buf[38] === 0x61 && buf[39] === 0x70 && buf[40] === 0x70 && buf[41] === 0x6C && buf[42] === 0x69 && buf[43] === 0x63 && buf[44] === 0x61 && buf[45] === 0x74 && buf[46] === 0x69 && buf[47] === 0x6F && buf[48] === 0x6E && buf[49] === 0x2F && buf[50] === 0x65 && buf[51] === 0x70 && buf[52] === 0x75 && buf[53] === 0x62 && buf[54] === 0x2B && buf[55] === 0x7A && buf[56] === 0x69 && buf[57] === 0x70) {
|
||||
return {
|
||||
ext: 'epub',
|
||||
mime: 'application/epub+zip'
|
||||
};
|
||||
}
|
||||
|
||||
// needs to be before `zip` check
|
||||
// assumes signed .xpi from addons.mozilla.org
|
||||
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x4D && buf[31] === 0x45 && buf[32] === 0x54 && buf[33] === 0x41 && buf[34] === 0x2D && buf[35] === 0x49 && buf[36] === 0x4E && buf[37] === 0x46 && buf[38] === 0x2F && buf[39] === 0x6D && buf[40] === 0x6F && buf[41] === 0x7A && buf[42] === 0x69 && buf[43] === 0x6C && buf[44] === 0x6C && buf[45] === 0x61 && buf[46] === 0x2E && buf[47] === 0x72 && buf[48] === 0x73 && buf[49] === 0x61) {
|
||||
return {
|
||||
ext: 'xpi',
|
||||
mime: 'application/x-xpinstall'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x50 && buf[1] === 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 (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) {
|
||||
return {
|
||||
ext: 'tar',
|
||||
mime: 'application/x-tar'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x52 && buf[1] === 0x61 && buf[2] === 0x72 && buf[3] === 0x21 && buf[4] === 0x1A && buf[5] === 0x7 && (buf[6] === 0x0 || buf[6] === 0x1)) {
|
||||
return {
|
||||
ext: 'rar',
|
||||
mime: 'application/x-rar-compressed'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) {
|
||||
return {
|
||||
ext: 'gz',
|
||||
mime: 'application/gzip'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) {
|
||||
return {
|
||||
ext: 'bz2',
|
||||
mime: 'application/x-bzip2'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) {
|
||||
return {
|
||||
ext: '7z',
|
||||
mime: 'application/x-7z-compressed'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x78 && buf[1] === 0x01) {
|
||||
return {
|
||||
ext: 'dmg',
|
||||
mime: 'application/x-apple-diskimage'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && (buf[3] === 0x18 || buf[3] === 0x20) && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) ||
|
||||
(buf[0] === 0x33 && buf[1] === 0x67 && buf[2] === 0x70 && buf[3] === 0x35) ||
|
||||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[16] === 0x6D && buf[17] === 0x70 && buf[18] === 0x34 && buf[19] === 0x31 && buf[20] === 0x6D && buf[21] === 0x70 && buf[22] === 0x34 && buf[23] === 0x32 && buf[24] === 0x69 && buf[25] === 0x73 && buf[26] === 0x6F && buf[27] === 0x6D) ||
|
||||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x69 && buf[9] === 0x73 && buf[10] === 0x6F && buf[11] === 0x6D) ||
|
||||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1c && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[12] === 0x0 && buf[13] === 0x0 && buf[14] === 0x0 && buf[15] === 0x0)
|
||||
) {
|
||||
return {
|
||||
ext: 'mp4',
|
||||
mime: 'video/mp4'
|
||||
};
|
||||
}
|
||||
|
||||
if ((buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x56)) {
|
||||
return {
|
||||
ext: 'm4v',
|
||||
mime: 'video/x-m4v'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) {
|
||||
return {
|
||||
ext: 'mid',
|
||||
mime: 'audio/midi'
|
||||
};
|
||||
}
|
||||
|
||||
// needs to be before the `webm` check
|
||||
if (buf[31] === 0x6D && buf[32] === 0x61 && buf[33] === 0x74 && buf[34] === 0x72 && buf[35] === 0x6f && buf[36] === 0x73 && buf[37] === 0x6B && buf[38] === 0x61) {
|
||||
return {
|
||||
ext: 'mkv',
|
||||
mime: 'video/x-matroska'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) {
|
||||
return {
|
||||
ext: 'webm',
|
||||
mime: 'video/webm'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x14 && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) {
|
||||
return {
|
||||
ext: 'mov',
|
||||
mime: 'video/quicktime'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x41 && buf[9] === 0x56 && buf[10] === 0x49) {
|
||||
return {
|
||||
ext: 'avi',
|
||||
mime: 'video/x-msvideo'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x30 && buf[1] === 0x26 && buf[2] === 0xB2 && buf[3] === 0x75 && buf[4] === 0x8E && buf[5] === 0x66 && buf[6] === 0xCF && buf[7] === 0x11 && buf[8] === 0xA6 && buf[9] === 0xD9) {
|
||||
return {
|
||||
ext: 'wmv',
|
||||
mime: 'video/x-ms-wmv'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x1 && buf[3].toString(16)[0] === 'b') {
|
||||
return {
|
||||
ext: 'mpg',
|
||||
mime: 'video/mpeg'
|
||||
};
|
||||
}
|
||||
|
||||
if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) {
|
||||
return {
|
||||
ext: 'mp3',
|
||||
mime: 'audio/mpeg'
|
||||
};
|
||||
}
|
||||
|
||||
if ((buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x41) || (buf[0] === 0x4D && buf[1] === 0x34 && buf[2] === 0x41 && buf[3] === 0x20)) {
|
||||
return {
|
||||
ext: 'm4a',
|
||||
mime: 'audio/m4a'
|
||||
};
|
||||
}
|
||||
|
||||
// needs to be before `ogg` check
|
||||
if (buf[28] === 0x4F && buf[29] === 0x70 && buf[30] === 0x75 && buf[31] === 0x73 && buf[32] === 0x48 && buf[33] === 0x65 && buf[34] === 0x61 && buf[35] === 0x64) {
|
||||
return {
|
||||
ext: 'opus',
|
||||
mime: 'audio/opus'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
|
||||
return {
|
||||
ext: 'ogg',
|
||||
mime: 'audio/ogg'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) {
|
||||
return {
|
||||
ext: 'flac',
|
||||
mime: 'audio/x-flac'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x41 && buf[10] === 0x56 && buf[11] === 0x45) {
|
||||
return {
|
||||
ext: 'wav',
|
||||
mime: 'audio/x-wav'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) {
|
||||
return {
|
||||
ext: 'amr',
|
||||
mime: 'audio/amr'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
|
||||
return {
|
||||
ext: 'pdf',
|
||||
mime: 'application/pdf'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x4D && buf[1] === 0x5A) {
|
||||
return {
|
||||
ext: 'exe',
|
||||
mime: 'application/x-msdownload'
|
||||
};
|
||||
}
|
||||
|
||||
if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) {
|
||||
return {
|
||||
ext: 'swf',
|
||||
mime: 'application/x-shockwave-flash'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) {
|
||||
return {
|
||||
ext: 'rtf',
|
||||
mime: 'application/rtf'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46) &&
|
||||
(
|
||||
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
|
||||
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
|
||||
)
|
||||
) {
|
||||
return {
|
||||
ext: 'woff',
|
||||
mime: 'application/font-woff'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32) &&
|
||||
(
|
||||
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
|
||||
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
|
||||
)
|
||||
) {
|
||||
return {
|
||||
ext: 'woff2',
|
||||
mime: 'application/font-woff'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(buf[34] === 0x4C && buf[35] === 0x50) &&
|
||||
(
|
||||
(buf[8] === 0x00 && buf[9] === 0x00 && buf[10] === 0x01) ||
|
||||
(buf[8] === 0x01 && buf[9] === 0x00 && buf[10] === 0x02) ||
|
||||
(buf[8] === 0x02 && buf[9] === 0x00 && buf[10] === 0x02)
|
||||
)
|
||||
) {
|
||||
return {
|
||||
ext: 'eot',
|
||||
mime: 'application/octet-stream'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) {
|
||||
return {
|
||||
ext: 'ttf',
|
||||
mime: 'application/font-sfnt'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) {
|
||||
return {
|
||||
ext: 'otf',
|
||||
mime: 'application/font-sfnt'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
|
||||
return {
|
||||
ext: 'ico',
|
||||
mime: 'image/x-icon'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) {
|
||||
return {
|
||||
ext: 'flv',
|
||||
mime: 'video/x-flv'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x25 && buf[1] === 0x21) {
|
||||
return {
|
||||
ext: 'ps',
|
||||
mime: 'application/postscript'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) {
|
||||
return {
|
||||
ext: 'xz',
|
||||
mime: 'application/x-xz'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) {
|
||||
return {
|
||||
ext: 'sqlite',
|
||||
mime: 'application/x-sqlite3'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x4E && buf[1] === 0x45 && buf[2] === 0x53 && buf[3] === 0x1A) {
|
||||
return {
|
||||
ext: 'nes',
|
||||
mime: 'application/x-nintendo-nes-rom'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x43 && buf[1] === 0x72 && buf[2] === 0x32 && buf[3] === 0x34) {
|
||||
return {
|
||||
ext: 'crx',
|
||||
mime: 'application/x-google-chrome-extension'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(buf[0] === 0x4D && buf[1] === 0x53 && buf[2] === 0x43 && buf[3] === 0x46) ||
|
||||
(buf[0] === 0x49 && buf[1] === 0x53 && buf[2] === 0x63 && buf[3] === 0x28)
|
||||
) {
|
||||
return {
|
||||
ext: 'cab',
|
||||
mime: 'application/vnd.ms-cab-compressed'
|
||||
};
|
||||
}
|
||||
|
||||
// needs to be before `ar` check
|
||||
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E && buf[7] === 0x0A && buf[8] === 0x64 && buf[9] === 0x65 && buf[10] === 0x62 && buf[11] === 0x69 && buf[12] === 0x61 && buf[13] === 0x6E && buf[14] === 0x2D && buf[15] === 0x62 && buf[16] === 0x69 && buf[17] === 0x6E && buf[18] === 0x61 && buf[19] === 0x72 && buf[20] === 0x79) {
|
||||
return {
|
||||
ext: 'deb',
|
||||
mime: 'application/x-deb'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E) {
|
||||
return {
|
||||
ext: 'ar',
|
||||
mime: 'application/x-unix-archive'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0xED && buf[1] === 0xAB && buf[2] === 0xEE && buf[3] === 0xDB) {
|
||||
return {
|
||||
ext: 'rpm',
|
||||
mime: 'application/x-rpm'
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
(buf[0] === 0x1F && buf[1] === 0xA0) ||
|
||||
(buf[0] === 0x1F && buf[1] === 0x9D)
|
||||
) {
|
||||
return {
|
||||
ext: 'Z',
|
||||
mime: 'application/x-compress'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0x4C && buf[1] === 0x5A && buf[2] === 0x49 && buf[3] === 0x50) {
|
||||
return {
|
||||
ext: 'lz',
|
||||
mime: 'application/x-lzip'
|
||||
};
|
||||
}
|
||||
|
||||
if (buf[0] === 0xD0 && buf[1] === 0xCF && buf[2] === 0x11 && buf[3] === 0xE0 && buf[4] === 0xA1 && buf[5] === 0xB1 && buf[6] === 0x1A && buf[7] === 0xE1) {
|
||||
return {
|
||||
ext: 'msi',
|
||||
mime: 'application/x-msi'
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
54
node_modules/decompress-unzip/node_modules/get-stream/buffer-stream.js
generated
vendored
Normal file
54
node_modules/decompress-unzip/node_modules/get-stream/buffer-stream.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
var PassThrough = require('stream').PassThrough;
|
||||
var objectAssign = require('object-assign');
|
||||
|
||||
module.exports = function (opts) {
|
||||
opts = objectAssign({}, opts);
|
||||
|
||||
var array = opts.array;
|
||||
var encoding = opts.encoding;
|
||||
|
||||
var buffer = encoding === 'buffer';
|
||||
var objectMode = false;
|
||||
|
||||
if (array) {
|
||||
objectMode = !(encoding || buffer);
|
||||
} else {
|
||||
encoding = encoding || 'utf8';
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
var len = 0;
|
||||
var ret = [];
|
||||
|
||||
var stream = new PassThrough({objectMode: objectMode});
|
||||
|
||||
if (encoding) {
|
||||
stream.setEncoding(encoding);
|
||||
}
|
||||
|
||||
stream.on('data', function (chunk) {
|
||||
ret.push(chunk);
|
||||
|
||||
if (objectMode) {
|
||||
len = ret.length;
|
||||
} else {
|
||||
len += chunk.length;
|
||||
}
|
||||
});
|
||||
|
||||
stream.getBufferedValue = function () {
|
||||
if (array) {
|
||||
return ret;
|
||||
}
|
||||
return buffer ? Buffer.concat(ret, len) : ret.join('');
|
||||
};
|
||||
|
||||
stream.getBufferedLength = function () {
|
||||
return len;
|
||||
};
|
||||
|
||||
return stream;
|
||||
};
|
||||
59
node_modules/decompress-unzip/node_modules/get-stream/index.js
generated
vendored
Normal file
59
node_modules/decompress-unzip/node_modules/get-stream/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
var Promise = require('pinkie-promise');
|
||||
var objectAssign = require('object-assign');
|
||||
var bufferStream = require('./buffer-stream');
|
||||
|
||||
function getStream(inputStream, opts) {
|
||||
if (!inputStream) {
|
||||
return Promise.reject(new Error('Expected a stream'));
|
||||
}
|
||||
|
||||
opts = objectAssign({maxBuffer: Infinity}, opts);
|
||||
var maxBuffer = opts.maxBuffer;
|
||||
var stream;
|
||||
var clean;
|
||||
|
||||
var p = new Promise(function (resolve, reject) {
|
||||
stream = bufferStream(opts);
|
||||
inputStream.once('error', error);
|
||||
inputStream.pipe(stream);
|
||||
|
||||
stream.on('data', function () {
|
||||
if (stream.getBufferedLength() > maxBuffer) {
|
||||
reject(new Error('maxBuffer exceeded'));
|
||||
}
|
||||
});
|
||||
stream.once('error', error);
|
||||
stream.on('end', resolve);
|
||||
|
||||
clean = function () {
|
||||
// some streams doesn't implement the stream.Readable interface correctly
|
||||
if (inputStream.unpipe) {
|
||||
inputStream.unpipe(stream);
|
||||
}
|
||||
};
|
||||
|
||||
function error(err) {
|
||||
if (err) { // null check
|
||||
err.bufferedData = stream.getBufferedValue();
|
||||
}
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
p.then(clean, clean);
|
||||
|
||||
return p.then(function () {
|
||||
return stream.getBufferedValue();
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getStream;
|
||||
|
||||
module.exports.buffer = function (stream, opts) {
|
||||
return getStream(stream, objectAssign({}, opts, {encoding: 'buffer'}));
|
||||
};
|
||||
|
||||
module.exports.array = function (stream, opts) {
|
||||
return getStream(stream, objectAssign({}, opts, {array: true}));
|
||||
};
|
||||
96
node_modules/decompress/index.js
generated
vendored
Normal file
96
node_modules/decompress/index.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const fs = require('graceful-fs');
|
||||
const decompressTar = require('decompress-tar');
|
||||
const decompressTarbz2 = require('decompress-tarbz2');
|
||||
const decompressTargz = require('decompress-targz');
|
||||
const decompressUnzip = require('decompress-unzip');
|
||||
const makeDir = require('make-dir');
|
||||
const pify = require('pify');
|
||||
const stripDirs = require('strip-dirs');
|
||||
|
||||
const fsP = pify(fs);
|
||||
|
||||
const runPlugins = (input, opts) => {
|
||||
if (opts.plugins.length === 0) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
return Promise.all(opts.plugins.map(x => x(input, opts))).then(files => files.reduce((a, b) => a.concat(b)));
|
||||
};
|
||||
|
||||
const extractFile = (input, output, opts) => runPlugins(input, opts).then(files => {
|
||||
if (opts.strip > 0) {
|
||||
files = files
|
||||
.map(x => {
|
||||
x.path = stripDirs(x.path, opts.strip);
|
||||
return x;
|
||||
})
|
||||
.filter(x => x.path !== '.');
|
||||
}
|
||||
|
||||
if (typeof opts.filter === 'function') {
|
||||
files = files.filter(opts.filter);
|
||||
}
|
||||
|
||||
if (typeof opts.map === 'function') {
|
||||
files = files.map(opts.map);
|
||||
}
|
||||
|
||||
if (!output) {
|
||||
return files;
|
||||
}
|
||||
|
||||
return Promise.all(files.map(x => {
|
||||
const dest = path.join(output, x.path);
|
||||
const mode = x.mode & ~process.umask();
|
||||
const now = new Date();
|
||||
|
||||
if (x.type === 'directory') {
|
||||
return makeDir(dest)
|
||||
.then(() => fsP.utimes(dest, now, x.mtime))
|
||||
.then(() => x);
|
||||
}
|
||||
|
||||
return makeDir(path.dirname(dest))
|
||||
.then(() => {
|
||||
if (x.type === 'link') {
|
||||
return fsP.link(x.linkname, dest);
|
||||
}
|
||||
|
||||
if (x.type === 'symlink' && process.platform === 'win32') {
|
||||
return fsP.link(x.linkname, dest);
|
||||
}
|
||||
|
||||
if (x.type === 'symlink') {
|
||||
return fsP.symlink(x.linkname, dest);
|
||||
}
|
||||
|
||||
return fsP.writeFile(dest, x.data, {mode});
|
||||
})
|
||||
.then(() => x.type === 'file' && fsP.utimes(dest, now, x.mtime))
|
||||
.then(() => x);
|
||||
}));
|
||||
});
|
||||
|
||||
module.exports = (input, output, opts) => {
|
||||
if (typeof input !== 'string' && !Buffer.isBuffer(input)) {
|
||||
return Promise.reject(new TypeError('Input file required'));
|
||||
}
|
||||
|
||||
if (typeof output === 'object') {
|
||||
opts = output;
|
||||
output = null;
|
||||
}
|
||||
|
||||
opts = Object.assign({plugins: [
|
||||
decompressTar(),
|
||||
decompressTarbz2(),
|
||||
decompressTargz(),
|
||||
decompressUnzip()
|
||||
]}, opts);
|
||||
|
||||
const read = typeof input === 'string' ? fsP.readFile(input) : Promise.resolve(input);
|
||||
|
||||
return read.then(buf => extractFile(buf, output, opts));
|
||||
};
|
||||
13
node_modules/defaults/index.js
generated
vendored
Normal file
13
node_modules/defaults/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var clone = require('clone');
|
||||
|
||||
module.exports = function(options, defaults) {
|
||||
options = options || {};
|
||||
|
||||
Object.keys(defaults).forEach(function(key) {
|
||||
if (typeof options[key] === 'undefined') {
|
||||
options[key] = clone(defaults[key]);
|
||||
}
|
||||
});
|
||||
|
||||
return options;
|
||||
};
|
||||
34
node_modules/defaults/test.js
generated
vendored
Normal file
34
node_modules/defaults/test.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
var defaults = require('./'),
|
||||
test = require('tap').test;
|
||||
|
||||
test("ensure options is an object", function(t) {
|
||||
var options = defaults(false, { a : true });
|
||||
t.ok(options.a);
|
||||
t.end()
|
||||
});
|
||||
|
||||
test("ensure defaults override keys", function(t) {
|
||||
var result = defaults({}, { a: false, b: true });
|
||||
t.ok(result.b, 'b merges over undefined');
|
||||
t.equal(result.a, false, 'a merges over undefined');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("ensure defined keys are not overwritten", function(t) {
|
||||
var result = defaults({ b: false }, { a: false, b: true });
|
||||
t.equal(result.b, false, 'b not merged');
|
||||
t.equal(result.a, false, 'a merges over undefined');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("ensure defaults clone nested objects", function(t) {
|
||||
var d = { a: [1,2,3], b: { hello : 'world' } };
|
||||
var result = defaults({}, d);
|
||||
t.equal(result.a.length, 3, 'objects should be clones');
|
||||
t.ok(result.a !== d.a, 'objects should be clones');
|
||||
|
||||
t.equal(Object.keys(result.b).length, 1, 'objects should be clones');
|
||||
t.ok(result.b !== d.b, 'objects should be clones');
|
||||
t.end();
|
||||
});
|
||||
|
||||
147
node_modules/download-git-repo/index.js
generated
vendored
Normal file
147
node_modules/download-git-repo/index.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
var downloadUrl = require('download')
|
||||
var gitclone = require('git-clone')
|
||||
var rm = require('rimraf').sync
|
||||
|
||||
/**
|
||||
* Expose `download`.
|
||||
*/
|
||||
|
||||
module.exports = download
|
||||
|
||||
/**
|
||||
* Download `repo` to `dest` and callback `fn(err)`.
|
||||
*
|
||||
* @param {String} repo
|
||||
* @param {String} dest
|
||||
* @param {Object} opts
|
||||
* @param {Function} fn
|
||||
*/
|
||||
|
||||
function download (repo, dest, opts, fn) {
|
||||
if (typeof opts === 'function') {
|
||||
fn = opts
|
||||
opts = null
|
||||
}
|
||||
opts = opts || {}
|
||||
var clone = opts.clone || false
|
||||
|
||||
repo = normalize(repo)
|
||||
var url = repo.url || getUrl(repo, clone)
|
||||
|
||||
if (clone) {
|
||||
gitclone(url, dest, { checkout: repo.checkout, shallow: repo.checkout === 'master' }, function (err) {
|
||||
if (err === undefined) {
|
||||
rm(dest + '/.git')
|
||||
fn()
|
||||
} else {
|
||||
fn(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
downloadUrl(url, dest, { extract: true, strip: 1, mode: '666', headers: { accept: 'application/zip' } })
|
||||
.then(function (data) {
|
||||
fn()
|
||||
})
|
||||
.catch(function (err) {
|
||||
fn(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a repo string.
|
||||
*
|
||||
* @param {String} repo
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
function normalize (repo) {
|
||||
var regex = /^(?:(direct):([^#]+)(?:#(.+))?)$/
|
||||
var match = regex.exec(repo)
|
||||
|
||||
if (match) {
|
||||
var url = match[2]
|
||||
var checkout = match[3] || 'master'
|
||||
|
||||
return {
|
||||
type: 'direct',
|
||||
url: url,
|
||||
checkout: checkout
|
||||
}
|
||||
} else {
|
||||
regex = /^(?:(github|gitlab|bitbucket):)?(?:(.+):)?([^\/]+)\/([^#]+)(?:#(.+))?$/
|
||||
match = regex.exec(repo)
|
||||
var type = match[1] || 'github'
|
||||
var origin = match[2] || null
|
||||
var owner = match[3]
|
||||
var name = match[4]
|
||||
var checkout = match[5] || 'master'
|
||||
|
||||
if (origin == null) {
|
||||
if (type === 'github')
|
||||
origin = 'github.com'
|
||||
else if (type === 'gitlab')
|
||||
origin = 'gitlab.com'
|
||||
else if (type === 'bitbucket')
|
||||
origin = 'bitbucket.com'
|
||||
}
|
||||
|
||||
return {
|
||||
type: type,
|
||||
origin: origin,
|
||||
owner: owner,
|
||||
name: name,
|
||||
checkout: checkout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds protocol to url in none specified
|
||||
*
|
||||
* @param {String} url
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function addProtocol (origin, clone) {
|
||||
if (!/^(f|ht)tps?:\/\//i.test(origin)) {
|
||||
if (clone)
|
||||
origin = 'git@' + origin
|
||||
else
|
||||
origin = 'https://' + origin
|
||||
}
|
||||
|
||||
return origin
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a zip or git url for a given `repo`.
|
||||
*
|
||||
* @param {Object} repo
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function getUrl (repo, clone) {
|
||||
var url
|
||||
|
||||
// Get origin with protocol and add trailing slash or colon (for ssh)
|
||||
var origin = addProtocol(repo.origin, clone)
|
||||
if (/^git\@/i.test(origin))
|
||||
origin = origin + ':'
|
||||
else
|
||||
origin = origin + '/'
|
||||
|
||||
// Build url
|
||||
if (clone) {
|
||||
url = origin + repo.owner + '/' + repo.name + '.git'
|
||||
} else {
|
||||
if (repo.type === 'github')
|
||||
url = origin + repo.owner + '/' + repo.name + '/archive/' + repo.checkout + '.zip'
|
||||
else if (repo.type === 'gitlab')
|
||||
url = origin + repo.owner + '/' + repo.name + '/repository/archive.zip?ref=' + repo.checkout
|
||||
else if (repo.type === 'bitbucket')
|
||||
url = origin + repo.owner + '/' + repo.name + '/get/' + repo.checkout + '.zip'
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
63
node_modules/download/index.js
generated
vendored
Normal file
63
node_modules/download/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const caw = require('caw');
|
||||
const decompress = require('decompress');
|
||||
const filenamify = require('filenamify');
|
||||
const getStream = require('get-stream');
|
||||
const got = require('got');
|
||||
const mkdirp = require('mkdirp');
|
||||
const pify = require('pify');
|
||||
|
||||
const fsP = pify(fs);
|
||||
|
||||
const createPromise = (uri, output, stream, opts) => {
|
||||
const response = opts.encoding === null ? getStream.buffer(stream) : getStream(stream, opts);
|
||||
|
||||
return response.then(data => {
|
||||
if (!output && opts.extract) {
|
||||
return decompress(data, opts);
|
||||
}
|
||||
|
||||
if (!output) {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (opts.extract) {
|
||||
return decompress(data, path.dirname(output), opts);
|
||||
}
|
||||
|
||||
return pify(mkdirp)(path.dirname(output))
|
||||
.then(() => fsP.writeFile(output, data))
|
||||
.then(() => data);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = (uri, output, opts) => {
|
||||
if (typeof output === 'object') {
|
||||
opts = output;
|
||||
output = null;
|
||||
}
|
||||
|
||||
opts = Object.assign({
|
||||
encoding: null,
|
||||
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false'
|
||||
}, opts);
|
||||
|
||||
let protocol = url.parse(uri).protocol;
|
||||
|
||||
if (protocol) {
|
||||
protocol = protocol.slice(0, -1);
|
||||
}
|
||||
|
||||
const agent = caw(opts.proxy, {protocol});
|
||||
const stream = got.stream(uri, Object.assign(opts, {agent}));
|
||||
const dest = output ? path.join(output, filenamify(path.basename(uri))) : null;
|
||||
const promise = createPromise(uri, dest, stream, opts);
|
||||
|
||||
stream.then = promise.then.bind(promise);
|
||||
stream.catch = promise.catch.bind(promise);
|
||||
|
||||
return stream;
|
||||
};
|
||||
76
node_modules/duplexer3/index.js
generated
vendored
Normal file
76
node_modules/duplexer3/index.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
var stream = require("stream");
|
||||
|
||||
function DuplexWrapper(options, writable, readable) {
|
||||
if (typeof readable === "undefined") {
|
||||
readable = writable;
|
||||
writable = options;
|
||||
options = null;
|
||||
}
|
||||
|
||||
stream.Duplex.call(this, options);
|
||||
|
||||
if (typeof readable.read !== "function") {
|
||||
readable = (new stream.Readable(options)).wrap(readable);
|
||||
}
|
||||
|
||||
this._writable = writable;
|
||||
this._readable = readable;
|
||||
this._waiting = false;
|
||||
|
||||
var self = this;
|
||||
|
||||
writable.once("finish", function() {
|
||||
self.end();
|
||||
});
|
||||
|
||||
this.once("finish", function() {
|
||||
writable.end();
|
||||
});
|
||||
|
||||
readable.on("readable", function() {
|
||||
if (self._waiting) {
|
||||
self._waiting = false;
|
||||
self._read();
|
||||
}
|
||||
});
|
||||
|
||||
readable.once("end", function() {
|
||||
self.push(null);
|
||||
});
|
||||
|
||||
if (!options || typeof options.bubbleErrors === "undefined" || options.bubbleErrors) {
|
||||
writable.on("error", function(err) {
|
||||
self.emit("error", err);
|
||||
});
|
||||
|
||||
readable.on("error", function(err) {
|
||||
self.emit("error", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DuplexWrapper.prototype = Object.create(stream.Duplex.prototype, {constructor: {value: DuplexWrapper}});
|
||||
|
||||
DuplexWrapper.prototype._write = function _write(input, encoding, done) {
|
||||
this._writable.write(input, encoding, done);
|
||||
};
|
||||
|
||||
DuplexWrapper.prototype._read = function _read() {
|
||||
var buf;
|
||||
var reads = 0;
|
||||
while ((buf = this._readable.read()) !== null) {
|
||||
this.push(buf);
|
||||
reads++;
|
||||
}
|
||||
if (reads === 0) {
|
||||
this._waiting = true;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function duplex2(options, writable, readable) {
|
||||
return new DuplexWrapper(options, writable, readable);
|
||||
};
|
||||
|
||||
module.exports.DuplexWrapper = DuplexWrapper;
|
||||
87
node_modules/end-of-stream/index.js
generated
vendored
Normal file
87
node_modules/end-of-stream/index.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
var once = require('once');
|
||||
|
||||
var noop = function() {};
|
||||
|
||||
var isRequest = function(stream) {
|
||||
return stream.setHeader && typeof stream.abort === 'function';
|
||||
};
|
||||
|
||||
var isChildProcess = function(stream) {
|
||||
return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3
|
||||
};
|
||||
|
||||
var eos = function(stream, opts, callback) {
|
||||
if (typeof opts === 'function') return eos(stream, null, opts);
|
||||
if (!opts) opts = {};
|
||||
|
||||
callback = once(callback || noop);
|
||||
|
||||
var ws = stream._writableState;
|
||||
var rs = stream._readableState;
|
||||
var readable = opts.readable || (opts.readable !== false && stream.readable);
|
||||
var writable = opts.writable || (opts.writable !== false && stream.writable);
|
||||
|
||||
var onlegacyfinish = function() {
|
||||
if (!stream.writable) onfinish();
|
||||
};
|
||||
|
||||
var onfinish = function() {
|
||||
writable = false;
|
||||
if (!readable) callback.call(stream);
|
||||
};
|
||||
|
||||
var onend = function() {
|
||||
readable = false;
|
||||
if (!writable) callback.call(stream);
|
||||
};
|
||||
|
||||
var onexit = function(exitCode) {
|
||||
callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);
|
||||
};
|
||||
|
||||
var onerror = function(err) {
|
||||
callback.call(stream, err);
|
||||
};
|
||||
|
||||
var onclose = function() {
|
||||
if (readable && !(rs && rs.ended)) return callback.call(stream, new Error('premature close'));
|
||||
if (writable && !(ws && ws.ended)) return callback.call(stream, new Error('premature close'));
|
||||
};
|
||||
|
||||
var onrequest = function() {
|
||||
stream.req.on('finish', onfinish);
|
||||
};
|
||||
|
||||
if (isRequest(stream)) {
|
||||
stream.on('complete', onfinish);
|
||||
stream.on('abort', onclose);
|
||||
if (stream.req) onrequest();
|
||||
else stream.on('request', onrequest);
|
||||
} else if (writable && !ws) { // legacy streams
|
||||
stream.on('end', onlegacyfinish);
|
||||
stream.on('close', onlegacyfinish);
|
||||
}
|
||||
|
||||
if (isChildProcess(stream)) stream.on('exit', onexit);
|
||||
|
||||
stream.on('end', onend);
|
||||
stream.on('finish', onfinish);
|
||||
if (opts.error !== false) stream.on('error', onerror);
|
||||
stream.on('close', onclose);
|
||||
|
||||
return function() {
|
||||
stream.removeListener('complete', onfinish);
|
||||
stream.removeListener('abort', onclose);
|
||||
stream.removeListener('request', onrequest);
|
||||
if (stream.req) stream.req.removeListener('finish', onfinish);
|
||||
stream.removeListener('end', onlegacyfinish);
|
||||
stream.removeListener('close', onlegacyfinish);
|
||||
stream.removeListener('finish', onfinish);
|
||||
stream.removeListener('exit', onexit);
|
||||
stream.removeListener('end', onend);
|
||||
stream.removeListener('error', onerror);
|
||||
stream.removeListener('close', onclose);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = eos;
|
||||
11
node_modules/escape-string-regexp/index.js
generated
vendored
Normal file
11
node_modules/escape-string-regexp/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
||||
|
||||
module.exports = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
return str.replace(matchOperatorsRe, '\\$&');
|
||||
};
|
||||
296
node_modules/fd-slicer/index.js
generated
vendored
Normal file
296
node_modules/fd-slicer/index.js
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
var fs = require('fs');
|
||||
var util = require('util');
|
||||
var stream = require('stream');
|
||||
var Readable = stream.Readable;
|
||||
var Writable = stream.Writable;
|
||||
var PassThrough = stream.PassThrough;
|
||||
var Pend = require('pend');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
exports.createFromBuffer = createFromBuffer;
|
||||
exports.createFromFd = createFromFd;
|
||||
exports.BufferSlicer = BufferSlicer;
|
||||
exports.FdSlicer = FdSlicer;
|
||||
|
||||
util.inherits(FdSlicer, EventEmitter);
|
||||
function FdSlicer(fd, options) {
|
||||
options = options || {};
|
||||
EventEmitter.call(this);
|
||||
|
||||
this.fd = fd;
|
||||
this.pend = new Pend();
|
||||
this.pend.max = 1;
|
||||
this.refCount = 0;
|
||||
this.autoClose = !!options.autoClose;
|
||||
}
|
||||
|
||||
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
||||
var self = this;
|
||||
self.pend.go(function(cb) {
|
||||
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
|
||||
cb();
|
||||
callback(err, bytesRead, buffer);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
||||
var self = this;
|
||||
self.pend.go(function(cb) {
|
||||
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
|
||||
cb();
|
||||
callback(err, written, buffer);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
FdSlicer.prototype.createReadStream = function(options) {
|
||||
return new ReadStream(this, options);
|
||||
};
|
||||
|
||||
FdSlicer.prototype.createWriteStream = function(options) {
|
||||
return new WriteStream(this, options);
|
||||
};
|
||||
|
||||
FdSlicer.prototype.ref = function() {
|
||||
this.refCount += 1;
|
||||
};
|
||||
|
||||
FdSlicer.prototype.unref = function() {
|
||||
var self = this;
|
||||
self.refCount -= 1;
|
||||
|
||||
if (self.refCount > 0) return;
|
||||
if (self.refCount < 0) throw new Error("invalid unref");
|
||||
|
||||
if (self.autoClose) {
|
||||
fs.close(self.fd, onCloseDone);
|
||||
}
|
||||
|
||||
function onCloseDone(err) {
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
} else {
|
||||
self.emit('close');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
util.inherits(ReadStream, Readable);
|
||||
function ReadStream(context, options) {
|
||||
options = options || {};
|
||||
Readable.call(this, options);
|
||||
|
||||
this.context = context;
|
||||
this.context.ref();
|
||||
|
||||
this.start = options.start || 0;
|
||||
this.endOffset = options.end;
|
||||
this.pos = this.start;
|
||||
this.destroyed = false;
|
||||
}
|
||||
|
||||
ReadStream.prototype._read = function(n) {
|
||||
var self = this;
|
||||
if (self.destroyed) return;
|
||||
|
||||
var toRead = Math.min(self._readableState.highWaterMark, n);
|
||||
if (self.endOffset != null) {
|
||||
toRead = Math.min(toRead, self.endOffset - self.pos);
|
||||
}
|
||||
if (toRead <= 0) {
|
||||
self.destroyed = true;
|
||||
self.push(null);
|
||||
self.context.unref();
|
||||
return;
|
||||
}
|
||||
self.context.pend.go(function(cb) {
|
||||
if (self.destroyed) return cb();
|
||||
var buffer = new Buffer(toRead);
|
||||
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
||||
if (err) {
|
||||
self.destroy(err);
|
||||
} else if (bytesRead === 0) {
|
||||
self.destroyed = true;
|
||||
self.push(null);
|
||||
self.context.unref();
|
||||
} else {
|
||||
self.pos += bytesRead;
|
||||
self.push(buffer.slice(0, bytesRead));
|
||||
}
|
||||
cb();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
ReadStream.prototype.destroy = function(err) {
|
||||
if (this.destroyed) return;
|
||||
err = err || new Error("stream destroyed");
|
||||
this.destroyed = true;
|
||||
this.emit('error', err);
|
||||
this.context.unref();
|
||||
};
|
||||
|
||||
util.inherits(WriteStream, Writable);
|
||||
function WriteStream(context, options) {
|
||||
options = options || {};
|
||||
Writable.call(this, options);
|
||||
|
||||
this.context = context;
|
||||
this.context.ref();
|
||||
|
||||
this.start = options.start || 0;
|
||||
this.endOffset = (options.end == null) ? Infinity : +options.end;
|
||||
this.bytesWritten = 0;
|
||||
this.pos = this.start;
|
||||
this.destroyed = false;
|
||||
|
||||
this.on('finish', this.destroy.bind(this));
|
||||
}
|
||||
|
||||
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
||||
var self = this;
|
||||
if (self.destroyed) return;
|
||||
|
||||
if (self.pos + buffer.length > self.endOffset) {
|
||||
var err = new Error("maximum file length exceeded");
|
||||
err.code = 'ETOOBIG';
|
||||
self.destroy();
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
self.context.pend.go(function(cb) {
|
||||
if (self.destroyed) return cb();
|
||||
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
|
||||
if (err) {
|
||||
self.destroy();
|
||||
cb();
|
||||
callback(err);
|
||||
} else {
|
||||
self.bytesWritten += bytes;
|
||||
self.pos += bytes;
|
||||
self.emit('progress');
|
||||
cb();
|
||||
callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
WriteStream.prototype.destroy = function() {
|
||||
if (this.destroyed) return;
|
||||
this.destroyed = true;
|
||||
this.context.unref();
|
||||
};
|
||||
|
||||
util.inherits(BufferSlicer, EventEmitter);
|
||||
function BufferSlicer(buffer, options) {
|
||||
EventEmitter.call(this);
|
||||
|
||||
options = options || {};
|
||||
this.refCount = 0;
|
||||
this.buffer = buffer;
|
||||
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
||||
}
|
||||
|
||||
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
||||
var end = position + length;
|
||||
var delta = end - this.buffer.length;
|
||||
var written = (delta > 0) ? delta : length;
|
||||
this.buffer.copy(buffer, offset, position, end);
|
||||
setImmediate(function() {
|
||||
callback(null, written);
|
||||
});
|
||||
};
|
||||
|
||||
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
||||
buffer.copy(this.buffer, position, offset, offset + length);
|
||||
setImmediate(function() {
|
||||
callback(null, length, buffer);
|
||||
});
|
||||
};
|
||||
|
||||
BufferSlicer.prototype.createReadStream = function(options) {
|
||||
options = options || {};
|
||||
var readStream = new PassThrough(options);
|
||||
readStream.destroyed = false;
|
||||
readStream.start = options.start || 0;
|
||||
readStream.endOffset = options.end;
|
||||
// by the time this function returns, we'll be done.
|
||||
readStream.pos = readStream.endOffset || this.buffer.length;
|
||||
|
||||
// respect the maxChunkSize option to slice up the chunk into smaller pieces.
|
||||
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
||||
var offset = 0;
|
||||
while (true) {
|
||||
var nextOffset = offset + this.maxChunkSize;
|
||||
if (nextOffset >= entireSlice.length) {
|
||||
// last chunk
|
||||
if (offset < entireSlice.length) {
|
||||
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
||||
}
|
||||
break;
|
||||
}
|
||||
readStream.write(entireSlice.slice(offset, nextOffset));
|
||||
offset = nextOffset;
|
||||
}
|
||||
|
||||
readStream.end();
|
||||
readStream.destroy = function() {
|
||||
readStream.destroyed = true;
|
||||
};
|
||||
return readStream;
|
||||
};
|
||||
|
||||
BufferSlicer.prototype.createWriteStream = function(options) {
|
||||
var bufferSlicer = this;
|
||||
options = options || {};
|
||||
var writeStream = new Writable(options);
|
||||
writeStream.start = options.start || 0;
|
||||
writeStream.endOffset = (options.end == null) ? this.buffer.length : +options.end;
|
||||
writeStream.bytesWritten = 0;
|
||||
writeStream.pos = writeStream.start;
|
||||
writeStream.destroyed = false;
|
||||
writeStream._write = function(buffer, encoding, callback) {
|
||||
if (writeStream.destroyed) return;
|
||||
|
||||
var end = writeStream.pos + buffer.length;
|
||||
if (end > writeStream.endOffset) {
|
||||
var err = new Error("maximum file length exceeded");
|
||||
err.code = 'ETOOBIG';
|
||||
writeStream.destroyed = true;
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
||||
|
||||
writeStream.bytesWritten += buffer.length;
|
||||
writeStream.pos = end;
|
||||
writeStream.emit('progress');
|
||||
callback();
|
||||
};
|
||||
writeStream.destroy = function() {
|
||||
writeStream.destroyed = true;
|
||||
};
|
||||
return writeStream;
|
||||
};
|
||||
|
||||
BufferSlicer.prototype.ref = function() {
|
||||
this.refCount += 1;
|
||||
};
|
||||
|
||||
BufferSlicer.prototype.unref = function() {
|
||||
this.refCount -= 1;
|
||||
|
||||
if (this.refCount < 0) {
|
||||
throw new Error("invalid unref");
|
||||
}
|
||||
};
|
||||
|
||||
function createFromBuffer(buffer, options) {
|
||||
return new BufferSlicer(buffer, options);
|
||||
}
|
||||
|
||||
function createFromFd(fd, options) {
|
||||
return new FdSlicer(fd, options);
|
||||
}
|
||||
559
node_modules/file-type/index.js
generated
vendored
Normal file
559
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;
|
||||
};
|
||||
5
node_modules/filename-reserved-regex/index.js
generated
vendored
Normal file
5
node_modules/filename-reserved-regex/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
/* eslint-disable no-control-regex */
|
||||
// TODO: remove parens when Node.js 6 is targeted. Node.js 4 barfs at it.
|
||||
module.exports = () => (/[<>:"\/\\|?*\x00-\x1F]/g);
|
||||
module.exports.windowsNames = () => (/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i);
|
||||
46
node_modules/filenamify/index.js
generated
vendored
Normal file
46
node_modules/filenamify/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const trimRepeated = require('trim-repeated');
|
||||
const filenameReservedRegex = require('filename-reserved-regex');
|
||||
const stripOuter = require('strip-outer');
|
||||
|
||||
// Doesn't make sense to have longer filenames
|
||||
const MAX_FILENAME_LENGTH = 100;
|
||||
|
||||
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g; // eslint-disable-line no-control-regex
|
||||
const reRelativePath = /^\.+/;
|
||||
|
||||
const fn = (string, options) => {
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
const replacement = options.replacement === undefined ? '!' : options.replacement;
|
||||
|
||||
if (filenameReservedRegex().test(replacement) && reControlChars.test(replacement)) {
|
||||
throw new Error('Replacement string cannot contain reserved filename characters');
|
||||
}
|
||||
|
||||
string = string.replace(filenameReservedRegex(), replacement);
|
||||
string = string.replace(reControlChars, replacement);
|
||||
string = string.replace(reRelativePath, replacement);
|
||||
|
||||
if (replacement.length > 0) {
|
||||
string = trimRepeated(string, replacement);
|
||||
string = string.length > 1 ? stripOuter(string, replacement) : string;
|
||||
}
|
||||
|
||||
string = filenameReservedRegex.windowsNames().test(string) ? string + replacement : string;
|
||||
string = string.slice(0, MAX_FILENAME_LENGTH);
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
fn.path = (pth, options) => {
|
||||
pth = path.resolve(pth);
|
||||
return path.join(path.dirname(pth), fn(path.basename(pth), options));
|
||||
};
|
||||
|
||||
module.exports = fn;
|
||||
1
node_modules/fs-constants/browser.js
generated
vendored
Normal file
1
node_modules/fs-constants/browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('constants')
|
||||
1
node_modules/fs-constants/index.js
generated
vendored
Normal file
1
node_modules/fs-constants/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('fs').constants || require('constants')
|
||||
66
node_modules/fs.realpath/index.js
generated
vendored
Normal file
66
node_modules/fs.realpath/index.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
module.exports = realpath
|
||||
realpath.realpath = realpath
|
||||
realpath.sync = realpathSync
|
||||
realpath.realpathSync = realpathSync
|
||||
realpath.monkeypatch = monkeypatch
|
||||
realpath.unmonkeypatch = unmonkeypatch
|
||||
|
||||
var fs = require('fs')
|
||||
var origRealpath = fs.realpath
|
||||
var origRealpathSync = fs.realpathSync
|
||||
|
||||
var version = process.version
|
||||
var ok = /^v[0-5]\./.test(version)
|
||||
var old = require('./old.js')
|
||||
|
||||
function newError (er) {
|
||||
return er && er.syscall === 'realpath' && (
|
||||
er.code === 'ELOOP' ||
|
||||
er.code === 'ENOMEM' ||
|
||||
er.code === 'ENAMETOOLONG'
|
||||
)
|
||||
}
|
||||
|
||||
function realpath (p, cache, cb) {
|
||||
if (ok) {
|
||||
return origRealpath(p, cache, cb)
|
||||
}
|
||||
|
||||
if (typeof cache === 'function') {
|
||||
cb = cache
|
||||
cache = null
|
||||
}
|
||||
origRealpath(p, cache, function (er, result) {
|
||||
if (newError(er)) {
|
||||
old.realpath(p, cache, cb)
|
||||
} else {
|
||||
cb(er, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function realpathSync (p, cache) {
|
||||
if (ok) {
|
||||
return origRealpathSync(p, cache)
|
||||
}
|
||||
|
||||
try {
|
||||
return origRealpathSync(p, cache)
|
||||
} catch (er) {
|
||||
if (newError(er)) {
|
||||
return old.realpathSync(p, cache)
|
||||
} else {
|
||||
throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function monkeypatch () {
|
||||
fs.realpath = realpath
|
||||
fs.realpathSync = realpathSync
|
||||
}
|
||||
|
||||
function unmonkeypatch () {
|
||||
fs.realpath = origRealpath
|
||||
fs.realpathSync = origRealpathSync
|
||||
}
|
||||
303
node_modules/fs.realpath/old.js
generated
vendored
Normal file
303
node_modules/fs.realpath/old.js
generated
vendored
Normal file
@@ -0,0 +1,303 @@
|
||||
// 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 pathModule = require('path');
|
||||
var isWindows = process.platform === 'win32';
|
||||
var fs = require('fs');
|
||||
|
||||
// JavaScript implementation of realpath, ported from node pre-v6
|
||||
|
||||
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
||||
|
||||
function rethrow() {
|
||||
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
|
||||
// is fairly slow to generate.
|
||||
var callback;
|
||||
if (DEBUG) {
|
||||
var backtrace = new Error;
|
||||
callback = debugCallback;
|
||||
} else
|
||||
callback = missingCallback;
|
||||
|
||||
return callback;
|
||||
|
||||
function debugCallback(err) {
|
||||
if (err) {
|
||||
backtrace.message = err.message;
|
||||
err = backtrace;
|
||||
missingCallback(err);
|
||||
}
|
||||
}
|
||||
|
||||
function missingCallback(err) {
|
||||
if (err) {
|
||||
if (process.throwDeprecation)
|
||||
throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
|
||||
else if (!process.noDeprecation) {
|
||||
var msg = 'fs: missing callback ' + (err.stack || err.message);
|
||||
if (process.traceDeprecation)
|
||||
console.trace(msg);
|
||||
else
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function maybeCallback(cb) {
|
||||
return typeof cb === 'function' ? cb : rethrow();
|
||||
}
|
||||
|
||||
var normalize = pathModule.normalize;
|
||||
|
||||
// Regexp that finds the next partion of a (partial) path
|
||||
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
||||
if (isWindows) {
|
||||
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
||||
} else {
|
||||
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
||||
}
|
||||
|
||||
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
||||
if (isWindows) {
|
||||
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
||||
} else {
|
||||
var splitRootRe = /^[\/]*/;
|
||||
}
|
||||
|
||||
exports.realpathSync = function realpathSync(p, cache) {
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return cache[p];
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstatSync(base);
|
||||
knownHard[base] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
// NB: p.length changes.
|
||||
while (pos < p.length) {
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var resolvedLink;
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// some known symbolic link. no need to stat again.
|
||||
resolvedLink = cache[base];
|
||||
} else {
|
||||
var stat = fs.lstatSync(base);
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
continue;
|
||||
}
|
||||
|
||||
// read the link if it wasn't read before
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
var linkTarget = null;
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
linkTarget = seenLinks[id];
|
||||
}
|
||||
}
|
||||
if (linkTarget === null) {
|
||||
fs.statSync(base);
|
||||
linkTarget = fs.readlinkSync(base);
|
||||
}
|
||||
resolvedLink = pathModule.resolve(previous, linkTarget);
|
||||
// track this, if given a cache.
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
if (!isWindows) seenLinks[id] = linkTarget;
|
||||
}
|
||||
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
|
||||
if (cache) cache[original] = p;
|
||||
|
||||
return p;
|
||||
};
|
||||
|
||||
|
||||
exports.realpath = function realpath(p, cache, cb) {
|
||||
if (typeof cb !== 'function') {
|
||||
cb = maybeCallback(cache);
|
||||
cache = null;
|
||||
}
|
||||
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return process.nextTick(cb.bind(null, null, cache[p]));
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
knownHard[base] = true;
|
||||
LOOP();
|
||||
});
|
||||
} else {
|
||||
process.nextTick(LOOP);
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
function LOOP() {
|
||||
// stop if scanned past end of path
|
||||
if (pos >= p.length) {
|
||||
if (cache) cache[original] = p;
|
||||
return cb(null, p);
|
||||
}
|
||||
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// known symbolic link. no need to stat again.
|
||||
return gotResolvedLink(cache[base]);
|
||||
}
|
||||
|
||||
return fs.lstat(base, gotStat);
|
||||
}
|
||||
|
||||
function gotStat(err, stat) {
|
||||
if (err) return cb(err);
|
||||
|
||||
// if not a symlink, skip to the next path part
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
// stat & read the link if not read before
|
||||
// call gotTarget as soon as the link target is known
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
return gotTarget(null, seenLinks[id], base);
|
||||
}
|
||||
}
|
||||
fs.stat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
fs.readlink(base, function(err, target) {
|
||||
if (!isWindows) seenLinks[id] = target;
|
||||
gotTarget(err, target);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function gotTarget(err, target, base) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var resolvedLink = pathModule.resolve(previous, target);
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
gotResolvedLink(resolvedLink);
|
||||
}
|
||||
|
||||
function gotResolvedLink(resolvedLink) {
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
};
|
||||
13
node_modules/get-proxy/index.js
generated
vendored
Normal file
13
node_modules/get-proxy/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
const npmConf = require('npm-conf')();
|
||||
|
||||
module.exports = () => {
|
||||
return process.env.HTTPS_PROXY ||
|
||||
process.env.https_proxy ||
|
||||
process.env.HTTP_PROXY ||
|
||||
process.env.http_proxy ||
|
||||
npmConf.get('https-proxy') ||
|
||||
npmConf.get('http-proxy') ||
|
||||
npmConf.get('proxy') ||
|
||||
null;
|
||||
};
|
||||
51
node_modules/get-stream/buffer-stream.js
generated
vendored
Normal file
51
node_modules/get-stream/buffer-stream.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
const PassThrough = require('stream').PassThrough;
|
||||
|
||||
module.exports = opts => {
|
||||
opts = Object.assign({}, opts);
|
||||
|
||||
const array = opts.array;
|
||||
let encoding = opts.encoding;
|
||||
const buffer = encoding === 'buffer';
|
||||
let objectMode = false;
|
||||
|
||||
if (array) {
|
||||
objectMode = !(encoding || buffer);
|
||||
} else {
|
||||
encoding = encoding || 'utf8';
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
let len = 0;
|
||||
const ret = [];
|
||||
const stream = new PassThrough({objectMode});
|
||||
|
||||
if (encoding) {
|
||||
stream.setEncoding(encoding);
|
||||
}
|
||||
|
||||
stream.on('data', chunk => {
|
||||
ret.push(chunk);
|
||||
|
||||
if (objectMode) {
|
||||
len = ret.length;
|
||||
} else {
|
||||
len += chunk.length;
|
||||
}
|
||||
});
|
||||
|
||||
stream.getBufferedValue = () => {
|
||||
if (array) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return buffer ? Buffer.concat(ret, len) : ret.join('');
|
||||
};
|
||||
|
||||
stream.getBufferedLength = () => len;
|
||||
|
||||
return stream;
|
||||
};
|
||||
51
node_modules/get-stream/index.js
generated
vendored
Normal file
51
node_modules/get-stream/index.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
const bufferStream = require('./buffer-stream');
|
||||
|
||||
function getStream(inputStream, opts) {
|
||||
if (!inputStream) {
|
||||
return Promise.reject(new Error('Expected a stream'));
|
||||
}
|
||||
|
||||
opts = Object.assign({maxBuffer: Infinity}, opts);
|
||||
|
||||
const maxBuffer = opts.maxBuffer;
|
||||
let stream;
|
||||
let clean;
|
||||
|
||||
const p = new Promise((resolve, reject) => {
|
||||
const error = err => {
|
||||
if (err) { // null check
|
||||
err.bufferedData = stream.getBufferedValue();
|
||||
}
|
||||
|
||||
reject(err);
|
||||
};
|
||||
|
||||
stream = bufferStream(opts);
|
||||
inputStream.once('error', error);
|
||||
inputStream.pipe(stream);
|
||||
|
||||
stream.on('data', () => {
|
||||
if (stream.getBufferedLength() > maxBuffer) {
|
||||
reject(new Error('maxBuffer exceeded'));
|
||||
}
|
||||
});
|
||||
stream.once('error', error);
|
||||
stream.on('end', resolve);
|
||||
|
||||
clean = () => {
|
||||
// some streams doesn't implement the `stream.Readable` interface correctly
|
||||
if (inputStream.unpipe) {
|
||||
inputStream.unpipe(stream);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
p.then(clean, clean);
|
||||
|
||||
return p.then(() => stream.getBufferedValue());
|
||||
}
|
||||
|
||||
module.exports = getStream;
|
||||
module.exports.buffer = (stream, opts) => getStream(stream, Object.assign({}, opts, {encoding: 'buffer'}));
|
||||
module.exports.array = (stream, opts) => getStream(stream, Object.assign({}, opts, {array: true}));
|
||||
49
node_modules/git-clone/index.js
generated
vendored
Normal file
49
node_modules/git-clone/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
module.exports = function(repo, targetPath, opts, cb) {
|
||||
|
||||
if (typeof opts === 'function') {
|
||||
cb = opts;
|
||||
opts = null;
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
var git = opts.git || 'git';
|
||||
var args = ['clone'];
|
||||
|
||||
if (opts.shallow) {
|
||||
args.push('--depth');
|
||||
args.push('1');
|
||||
}
|
||||
|
||||
args.push('--');
|
||||
args.push(repo);
|
||||
args.push(targetPath);
|
||||
|
||||
var process = spawn(git, args);
|
||||
process.on('close', function(status) {
|
||||
if (status == 0) {
|
||||
if (opts.checkout) {
|
||||
_checkout();
|
||||
} else {
|
||||
cb && cb();
|
||||
}
|
||||
} else {
|
||||
cb && cb(new Error("'git clone' failed with status " + status));
|
||||
}
|
||||
});
|
||||
|
||||
function _checkout() {
|
||||
var args = ['checkout', opts.checkout];
|
||||
var process = spawn(git, args, { cwd: targetPath });
|
||||
process.on('close', function(status) {
|
||||
if (status == 0) {
|
||||
cb && cb();
|
||||
} else {
|
||||
cb && cb(new Error("'git checkout' failed with status " + status));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
240
node_modules/glob/common.js
generated
vendored
Normal file
240
node_modules/glob/common.js
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
exports.alphasort = alphasort
|
||||
exports.alphasorti = alphasorti
|
||||
exports.setopts = setopts
|
||||
exports.ownProp = ownProp
|
||||
exports.makeAbs = makeAbs
|
||||
exports.finish = finish
|
||||
exports.mark = mark
|
||||
exports.isIgnored = isIgnored
|
||||
exports.childrenIgnored = childrenIgnored
|
||||
|
||||
function ownProp (obj, field) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, field)
|
||||
}
|
||||
|
||||
var path = require("path")
|
||||
var minimatch = require("minimatch")
|
||||
var isAbsolute = require("path-is-absolute")
|
||||
var Minimatch = minimatch.Minimatch
|
||||
|
||||
function alphasorti (a, b) {
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase())
|
||||
}
|
||||
|
||||
function alphasort (a, b) {
|
||||
return a.localeCompare(b)
|
||||
}
|
||||
|
||||
function setupIgnores (self, options) {
|
||||
self.ignore = options.ignore || []
|
||||
|
||||
if (!Array.isArray(self.ignore))
|
||||
self.ignore = [self.ignore]
|
||||
|
||||
if (self.ignore.length) {
|
||||
self.ignore = self.ignore.map(ignoreMap)
|
||||
}
|
||||
}
|
||||
|
||||
// ignore patterns are always in dot:true mode.
|
||||
function ignoreMap (pattern) {
|
||||
var gmatcher = null
|
||||
if (pattern.slice(-3) === '/**') {
|
||||
var gpattern = pattern.replace(/(\/\*\*)+$/, '')
|
||||
gmatcher = new Minimatch(gpattern, { dot: true })
|
||||
}
|
||||
|
||||
return {
|
||||
matcher: new Minimatch(pattern, { dot: true }),
|
||||
gmatcher: gmatcher
|
||||
}
|
||||
}
|
||||
|
||||
function setopts (self, pattern, options) {
|
||||
if (!options)
|
||||
options = {}
|
||||
|
||||
// base-matching: just use globstar for that.
|
||||
if (options.matchBase && -1 === pattern.indexOf("/")) {
|
||||
if (options.noglobstar) {
|
||||
throw new Error("base matching requires globstar")
|
||||
}
|
||||
pattern = "**/" + pattern
|
||||
}
|
||||
|
||||
self.silent = !!options.silent
|
||||
self.pattern = pattern
|
||||
self.strict = options.strict !== false
|
||||
self.realpath = !!options.realpath
|
||||
self.realpathCache = options.realpathCache || Object.create(null)
|
||||
self.follow = !!options.follow
|
||||
self.dot = !!options.dot
|
||||
self.mark = !!options.mark
|
||||
self.nodir = !!options.nodir
|
||||
if (self.nodir)
|
||||
self.mark = true
|
||||
self.sync = !!options.sync
|
||||
self.nounique = !!options.nounique
|
||||
self.nonull = !!options.nonull
|
||||
self.nosort = !!options.nosort
|
||||
self.nocase = !!options.nocase
|
||||
self.stat = !!options.stat
|
||||
self.noprocess = !!options.noprocess
|
||||
self.absolute = !!options.absolute
|
||||
|
||||
self.maxLength = options.maxLength || Infinity
|
||||
self.cache = options.cache || Object.create(null)
|
||||
self.statCache = options.statCache || Object.create(null)
|
||||
self.symlinks = options.symlinks || Object.create(null)
|
||||
|
||||
setupIgnores(self, options)
|
||||
|
||||
self.changedCwd = false
|
||||
var cwd = process.cwd()
|
||||
if (!ownProp(options, "cwd"))
|
||||
self.cwd = cwd
|
||||
else {
|
||||
self.cwd = path.resolve(options.cwd)
|
||||
self.changedCwd = self.cwd !== cwd
|
||||
}
|
||||
|
||||
self.root = options.root || path.resolve(self.cwd, "/")
|
||||
self.root = path.resolve(self.root)
|
||||
if (process.platform === "win32")
|
||||
self.root = self.root.replace(/\\/g, "/")
|
||||
|
||||
// TODO: is an absolute `cwd` supposed to be resolved against `root`?
|
||||
// e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
|
||||
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)
|
||||
if (process.platform === "win32")
|
||||
self.cwdAbs = self.cwdAbs.replace(/\\/g, "/")
|
||||
self.nomount = !!options.nomount
|
||||
|
||||
// disable comments and negation in Minimatch.
|
||||
// Note that they are not supported in Glob itself anyway.
|
||||
options.nonegate = true
|
||||
options.nocomment = true
|
||||
|
||||
self.minimatch = new Minimatch(pattern, options)
|
||||
self.options = self.minimatch.options
|
||||
}
|
||||
|
||||
function finish (self) {
|
||||
var nou = self.nounique
|
||||
var all = nou ? [] : Object.create(null)
|
||||
|
||||
for (var i = 0, l = self.matches.length; i < l; i ++) {
|
||||
var matches = self.matches[i]
|
||||
if (!matches || Object.keys(matches).length === 0) {
|
||||
if (self.nonull) {
|
||||
// do like the shell, and spit out the literal glob
|
||||
var literal = self.minimatch.globSet[i]
|
||||
if (nou)
|
||||
all.push(literal)
|
||||
else
|
||||
all[literal] = true
|
||||
}
|
||||
} else {
|
||||
// had matches
|
||||
var m = Object.keys(matches)
|
||||
if (nou)
|
||||
all.push.apply(all, m)
|
||||
else
|
||||
m.forEach(function (m) {
|
||||
all[m] = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!nou)
|
||||
all = Object.keys(all)
|
||||
|
||||
if (!self.nosort)
|
||||
all = all.sort(self.nocase ? alphasorti : alphasort)
|
||||
|
||||
// at *some* point we statted all of these
|
||||
if (self.mark) {
|
||||
for (var i = 0; i < all.length; i++) {
|
||||
all[i] = self._mark(all[i])
|
||||
}
|
||||
if (self.nodir) {
|
||||
all = all.filter(function (e) {
|
||||
var notDir = !(/\/$/.test(e))
|
||||
var c = self.cache[e] || self.cache[makeAbs(self, e)]
|
||||
if (notDir && c)
|
||||
notDir = c !== 'DIR' && !Array.isArray(c)
|
||||
return notDir
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (self.ignore.length)
|
||||
all = all.filter(function(m) {
|
||||
return !isIgnored(self, m)
|
||||
})
|
||||
|
||||
self.found = all
|
||||
}
|
||||
|
||||
function mark (self, p) {
|
||||
var abs = makeAbs(self, p)
|
||||
var c = self.cache[abs]
|
||||
var m = p
|
||||
if (c) {
|
||||
var isDir = c === 'DIR' || Array.isArray(c)
|
||||
var slash = p.slice(-1) === '/'
|
||||
|
||||
if (isDir && !slash)
|
||||
m += '/'
|
||||
else if (!isDir && slash)
|
||||
m = m.slice(0, -1)
|
||||
|
||||
if (m !== p) {
|
||||
var mabs = makeAbs(self, m)
|
||||
self.statCache[mabs] = self.statCache[abs]
|
||||
self.cache[mabs] = self.cache[abs]
|
||||
}
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// lotta situps...
|
||||
function makeAbs (self, f) {
|
||||
var abs = f
|
||||
if (f.charAt(0) === '/') {
|
||||
abs = path.join(self.root, f)
|
||||
} else if (isAbsolute(f) || f === '') {
|
||||
abs = f
|
||||
} else if (self.changedCwd) {
|
||||
abs = path.resolve(self.cwd, f)
|
||||
} else {
|
||||
abs = path.resolve(f)
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
abs = abs.replace(/\\/g, '/')
|
||||
|
||||
return abs
|
||||
}
|
||||
|
||||
|
||||
// Return true, if pattern ends with globstar '**', for the accompanying parent directory.
|
||||
// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
|
||||
function isIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
||||
|
||||
function childrenIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
||||
790
node_modules/glob/glob.js
generated
vendored
Normal file
790
node_modules/glob/glob.js
generated
vendored
Normal file
@@ -0,0 +1,790 @@
|
||||
// Approach:
|
||||
//
|
||||
// 1. Get the minimatch set
|
||||
// 2. For each pattern in the set, PROCESS(pattern, false)
|
||||
// 3. Store matches per-set, then uniq them
|
||||
//
|
||||
// PROCESS(pattern, inGlobStar)
|
||||
// Get the first [n] items from pattern that are all strings
|
||||
// Join these together. This is PREFIX.
|
||||
// If there is no more remaining, then stat(PREFIX) and
|
||||
// add to matches if it succeeds. END.
|
||||
//
|
||||
// If inGlobStar and PREFIX is symlink and points to dir
|
||||
// set ENTRIES = []
|
||||
// else readdir(PREFIX) as ENTRIES
|
||||
// If fail, END
|
||||
//
|
||||
// with ENTRIES
|
||||
// If pattern[n] is GLOBSTAR
|
||||
// // handle the case where the globstar match is empty
|
||||
// // by pruning it out, and testing the resulting pattern
|
||||
// PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
|
||||
// // handle other cases.
|
||||
// for ENTRY in ENTRIES (not dotfiles)
|
||||
// // attach globstar + tail onto the entry
|
||||
// // Mark that this entry is a globstar match
|
||||
// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
|
||||
//
|
||||
// else // not globstar
|
||||
// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
|
||||
// Test ENTRY against pattern[n]
|
||||
// If fails, continue
|
||||
// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
|
||||
//
|
||||
// Caveat:
|
||||
// Cache all stats and readdirs results to minimize syscall. Since all
|
||||
// we ever care about is existence and directory-ness, we can just keep
|
||||
// `true` for files, and [children,...] for directories, or `false` for
|
||||
// things that don't exist.
|
||||
|
||||
module.exports = glob
|
||||
|
||||
var fs = require('fs')
|
||||
var rp = require('fs.realpath')
|
||||
var minimatch = require('minimatch')
|
||||
var Minimatch = minimatch.Minimatch
|
||||
var inherits = require('inherits')
|
||||
var EE = require('events').EventEmitter
|
||||
var path = require('path')
|
||||
var assert = require('assert')
|
||||
var isAbsolute = require('path-is-absolute')
|
||||
var globSync = require('./sync.js')
|
||||
var common = require('./common.js')
|
||||
var alphasort = common.alphasort
|
||||
var alphasorti = common.alphasorti
|
||||
var setopts = common.setopts
|
||||
var ownProp = common.ownProp
|
||||
var inflight = require('inflight')
|
||||
var util = require('util')
|
||||
var childrenIgnored = common.childrenIgnored
|
||||
var isIgnored = common.isIgnored
|
||||
|
||||
var once = require('once')
|
||||
|
||||
function glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') cb = options, options = {}
|
||||
if (!options) options = {}
|
||||
|
||||
if (options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return globSync(pattern, options)
|
||||
}
|
||||
|
||||
return new Glob(pattern, options, cb)
|
||||
}
|
||||
|
||||
glob.sync = globSync
|
||||
var GlobSync = glob.GlobSync = globSync.GlobSync
|
||||
|
||||
// old api surface
|
||||
glob.glob = glob
|
||||
|
||||
function extend (origin, add) {
|
||||
if (add === null || typeof add !== 'object') {
|
||||
return origin
|
||||
}
|
||||
|
||||
var keys = Object.keys(add)
|
||||
var i = keys.length
|
||||
while (i--) {
|
||||
origin[keys[i]] = add[keys[i]]
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
glob.hasMagic = function (pattern, options_) {
|
||||
var options = extend({}, options_)
|
||||
options.noprocess = true
|
||||
|
||||
var g = new Glob(pattern, options)
|
||||
var set = g.minimatch.set
|
||||
|
||||
if (!pattern)
|
||||
return false
|
||||
|
||||
if (set.length > 1)
|
||||
return true
|
||||
|
||||
for (var j = 0; j < set[0].length; j++) {
|
||||
if (typeof set[0][j] !== 'string')
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
glob.Glob = Glob
|
||||
inherits(Glob, EE)
|
||||
function Glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options
|
||||
options = null
|
||||
}
|
||||
|
||||
if (options && options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return new GlobSync(pattern, options)
|
||||
}
|
||||
|
||||
if (!(this instanceof Glob))
|
||||
return new Glob(pattern, options, cb)
|
||||
|
||||
setopts(this, pattern, options)
|
||||
this._didRealPath = false
|
||||
|
||||
// process each pattern in the minimatch set
|
||||
var n = this.minimatch.set.length
|
||||
|
||||
// The matches are stored as {<filename>: true,...} so that
|
||||
// duplicates are automagically pruned.
|
||||
// Later, we do an Object.keys() on these.
|
||||
// Keep them as a list so we can fill in when nonull is set.
|
||||
this.matches = new Array(n)
|
||||
|
||||
if (typeof cb === 'function') {
|
||||
cb = once(cb)
|
||||
this.on('error', cb)
|
||||
this.on('end', function (matches) {
|
||||
cb(null, matches)
|
||||
})
|
||||
}
|
||||
|
||||
var self = this
|
||||
this._processing = 0
|
||||
|
||||
this._emitQueue = []
|
||||
this._processQueue = []
|
||||
this.paused = false
|
||||
|
||||
if (this.noprocess)
|
||||
return this
|
||||
|
||||
if (n === 0)
|
||||
return done()
|
||||
|
||||
var sync = true
|
||||
for (var i = 0; i < n; i ++) {
|
||||
this._process(this.minimatch.set[i], i, false, done)
|
||||
}
|
||||
sync = false
|
||||
|
||||
function done () {
|
||||
--self._processing
|
||||
if (self._processing <= 0) {
|
||||
if (sync) {
|
||||
process.nextTick(function () {
|
||||
self._finish()
|
||||
})
|
||||
} else {
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._finish = function () {
|
||||
assert(this instanceof Glob)
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (this.realpath && !this._didRealpath)
|
||||
return this._realpath()
|
||||
|
||||
common.finish(this)
|
||||
this.emit('end', this.found)
|
||||
}
|
||||
|
||||
Glob.prototype._realpath = function () {
|
||||
if (this._didRealpath)
|
||||
return
|
||||
|
||||
this._didRealpath = true
|
||||
|
||||
var n = this.matches.length
|
||||
if (n === 0)
|
||||
return this._finish()
|
||||
|
||||
var self = this
|
||||
for (var i = 0; i < this.matches.length; i++)
|
||||
this._realpathSet(i, next)
|
||||
|
||||
function next () {
|
||||
if (--n === 0)
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._realpathSet = function (index, cb) {
|
||||
var matchset = this.matches[index]
|
||||
if (!matchset)
|
||||
return cb()
|
||||
|
||||
var found = Object.keys(matchset)
|
||||
var self = this
|
||||
var n = found.length
|
||||
|
||||
if (n === 0)
|
||||
return cb()
|
||||
|
||||
var set = this.matches[index] = Object.create(null)
|
||||
found.forEach(function (p, i) {
|
||||
// If there's a problem with the stat, then it means that
|
||||
// one or more of the links in the realpath couldn't be
|
||||
// resolved. just return the abs value in that case.
|
||||
p = self._makeAbs(p)
|
||||
rp.realpath(p, self.realpathCache, function (er, real) {
|
||||
if (!er)
|
||||
set[real] = true
|
||||
else if (er.syscall === 'stat')
|
||||
set[p] = true
|
||||
else
|
||||
self.emit('error', er) // srsly wtf right here
|
||||
|
||||
if (--n === 0) {
|
||||
self.matches[index] = set
|
||||
cb()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._mark = function (p) {
|
||||
return common.mark(this, p)
|
||||
}
|
||||
|
||||
Glob.prototype._makeAbs = function (f) {
|
||||
return common.makeAbs(this, f)
|
||||
}
|
||||
|
||||
Glob.prototype.abort = function () {
|
||||
this.aborted = true
|
||||
this.emit('abort')
|
||||
}
|
||||
|
||||
Glob.prototype.pause = function () {
|
||||
if (!this.paused) {
|
||||
this.paused = true
|
||||
this.emit('pause')
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype.resume = function () {
|
||||
if (this.paused) {
|
||||
this.emit('resume')
|
||||
this.paused = false
|
||||
if (this._emitQueue.length) {
|
||||
var eq = this._emitQueue.slice(0)
|
||||
this._emitQueue.length = 0
|
||||
for (var i = 0; i < eq.length; i ++) {
|
||||
var e = eq[i]
|
||||
this._emitMatch(e[0], e[1])
|
||||
}
|
||||
}
|
||||
if (this._processQueue.length) {
|
||||
var pq = this._processQueue.slice(0)
|
||||
this._processQueue.length = 0
|
||||
for (var i = 0; i < pq.length; i ++) {
|
||||
var p = pq[i]
|
||||
this._processing--
|
||||
this._process(p[0], p[1], p[2], p[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
|
||||
assert(this instanceof Glob)
|
||||
assert(typeof cb === 'function')
|
||||
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
this._processing++
|
||||
if (this.paused) {
|
||||
this._processQueue.push([pattern, index, inGlobStar, cb])
|
||||
return
|
||||
}
|
||||
|
||||
//console.error('PROCESS %d', this._processing, pattern)
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === 'string') {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// see if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
this._processSimple(pattern.join('/'), index, cb)
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's 'absolute' like /foo/bar,
|
||||
// or 'relative' like '../baz'
|
||||
prefix = pattern.slice(0, n).join('/')
|
||||
break
|
||||
}
|
||||
|
||||
var remain = pattern.slice(n)
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null)
|
||||
read = '.'
|
||||
else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
|
||||
if (!prefix || !isAbsolute(prefix))
|
||||
prefix = '/' + prefix
|
||||
read = prefix
|
||||
} else
|
||||
read = prefix
|
||||
|
||||
var abs = this._makeAbs(read)
|
||||
|
||||
//if ignored, skip _processing
|
||||
if (childrenIgnored(this, read))
|
||||
return cb()
|
||||
|
||||
var isGlobStar = remain[0] === minimatch.GLOBSTAR
|
||||
if (isGlobStar)
|
||||
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
else
|
||||
this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
|
||||
// if the abs isn't a dir, then nothing can match!
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = remain[0]
|
||||
var negate = !!this.minimatch.negate
|
||||
var rawGlob = pn._glob
|
||||
var dotOk = this.dot || rawGlob.charAt(0) === '.'
|
||||
|
||||
var matchedEntries = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) !== '.' || dotOk) {
|
||||
var m
|
||||
if (negate && !prefix) {
|
||||
m = !e.match(pn)
|
||||
} else {
|
||||
m = e.match(pn)
|
||||
}
|
||||
if (m)
|
||||
matchedEntries.push(e)
|
||||
}
|
||||
}
|
||||
|
||||
//console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
|
||||
|
||||
var len = matchedEntries.length
|
||||
// If there are no matched entries, then nothing matches.
|
||||
if (len === 0)
|
||||
return cb()
|
||||
|
||||
// if this is the last remaining pattern bit, then no need for
|
||||
// an additional stat *unless* the user has specified mark or
|
||||
// stat explicitly. We know they exist, since readdir returned
|
||||
// them.
|
||||
|
||||
if (remain.length === 1 && !this.mark && !this.stat) {
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
|
||||
if (e.charAt(0) === '/' && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
this._emitMatch(index, e)
|
||||
}
|
||||
// This was the last one, and no stats were needed
|
||||
return cb()
|
||||
}
|
||||
|
||||
// now test all matched entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
remain.shift()
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
var newPattern
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
this._process([e].concat(remain), index, inGlobStar, cb)
|
||||
}
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._emitMatch = function (index, e) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (isIgnored(this, e))
|
||||
return
|
||||
|
||||
if (this.paused) {
|
||||
this._emitQueue.push([index, e])
|
||||
return
|
||||
}
|
||||
|
||||
var abs = isAbsolute(e) ? e : this._makeAbs(e)
|
||||
|
||||
if (this.mark)
|
||||
e = this._mark(e)
|
||||
|
||||
if (this.absolute)
|
||||
e = abs
|
||||
|
||||
if (this.matches[index][e])
|
||||
return
|
||||
|
||||
if (this.nodir) {
|
||||
var c = this.cache[abs]
|
||||
if (c === 'DIR' || Array.isArray(c))
|
||||
return
|
||||
}
|
||||
|
||||
this.matches[index][e] = true
|
||||
|
||||
var st = this.statCache[abs]
|
||||
if (st)
|
||||
this.emit('stat', e, st)
|
||||
|
||||
this.emit('match', e)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirInGlobStar = function (abs, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// follow all symlinked directories forever
|
||||
// just proceed as if this is a non-globstar situation
|
||||
if (this.follow)
|
||||
return this._readdir(abs, false, cb)
|
||||
|
||||
var lstatkey = 'lstat\0' + abs
|
||||
var self = this
|
||||
var lstatcb = inflight(lstatkey, lstatcb_)
|
||||
|
||||
if (lstatcb)
|
||||
fs.lstat(abs, lstatcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (er && er.code === 'ENOENT')
|
||||
return cb()
|
||||
|
||||
var isSym = lstat && lstat.isSymbolicLink()
|
||||
self.symlinks[abs] = isSym
|
||||
|
||||
// If it's not a symlink or a dir, then it's definitely a regular file.
|
||||
// don't bother doing a readdir in that case.
|
||||
if (!isSym && lstat && !lstat.isDirectory()) {
|
||||
self.cache[abs] = 'FILE'
|
||||
cb()
|
||||
} else
|
||||
self._readdir(abs, false, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdir = function (abs, inGlobStar, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb)
|
||||
if (!cb)
|
||||
return
|
||||
|
||||
//console.error('RD %j %j', +inGlobStar, abs)
|
||||
if (inGlobStar && !ownProp(this.symlinks, abs))
|
||||
return this._readdirInGlobStar(abs, cb)
|
||||
|
||||
if (ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
if (!c || c === 'FILE')
|
||||
return cb()
|
||||
|
||||
if (Array.isArray(c))
|
||||
return cb(null, c)
|
||||
}
|
||||
|
||||
var self = this
|
||||
fs.readdir(abs, readdirCb(this, abs, cb))
|
||||
}
|
||||
|
||||
function readdirCb (self, abs, cb) {
|
||||
return function (er, entries) {
|
||||
if (er)
|
||||
self._readdirError(abs, er, cb)
|
||||
else
|
||||
self._readdirEntries(abs, entries, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdirEntries = function (abs, entries, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// if we haven't asked to stat everything, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time.
|
||||
if (!this.mark && !this.stat) {
|
||||
for (var i = 0; i < entries.length; i ++) {
|
||||
var e = entries[i]
|
||||
if (abs === '/')
|
||||
e = abs + e
|
||||
else
|
||||
e = abs + '/' + e
|
||||
this.cache[e] = true
|
||||
}
|
||||
}
|
||||
|
||||
this.cache[abs] = entries
|
||||
return cb(null, entries)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirError = function (f, er, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// handle errors, and cache the information
|
||||
switch (er.code) {
|
||||
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
|
||||
case 'ENOTDIR': // totally normal. means it *does* exist.
|
||||
var abs = this._makeAbs(f)
|
||||
this.cache[abs] = 'FILE'
|
||||
if (abs === this.cwdAbs) {
|
||||
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
|
||||
error.path = this.cwd
|
||||
error.code = er.code
|
||||
this.emit('error', error)
|
||||
this.abort()
|
||||
}
|
||||
break
|
||||
|
||||
case 'ENOENT': // not terribly unusual
|
||||
case 'ELOOP':
|
||||
case 'ENAMETOOLONG':
|
||||
case 'UNKNOWN':
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
break
|
||||
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
if (this.strict) {
|
||||
this.emit('error', er)
|
||||
// If the error is handled, then we abort
|
||||
// if not, we threw out of here
|
||||
this.abort()
|
||||
}
|
||||
if (!this.silent)
|
||||
console.error('glob error', er)
|
||||
break
|
||||
}
|
||||
|
||||
return cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
//console.error('pgs2', prefix, remain[0], entries)
|
||||
|
||||
// no entries means not a dir, so it can never have matches
|
||||
// foo.txt/** doesn't match foo.txt
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var remainWithoutGlobStar = remain.slice(1)
|
||||
var gspref = prefix ? [ prefix ] : []
|
||||
var noGlobStar = gspref.concat(remainWithoutGlobStar)
|
||||
|
||||
// the noGlobStar pattern exits the inGlobStar state
|
||||
this._process(noGlobStar, index, false, cb)
|
||||
|
||||
var isSym = this.symlinks[abs]
|
||||
var len = entries.length
|
||||
|
||||
// If it's a symlink, and we're in a globstar, then stop
|
||||
if (isSym && inGlobStar)
|
||||
return cb()
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) === '.' && !this.dot)
|
||||
continue
|
||||
|
||||
// these two cases enter the inGlobStar state
|
||||
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
|
||||
this._process(instead, index, true, cb)
|
||||
|
||||
var below = gspref.concat(entries[i], remain)
|
||||
this._process(below, index, true, cb)
|
||||
}
|
||||
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processSimple = function (prefix, index, cb) {
|
||||
// XXX review this. Shouldn't it be doing the mounting etc
|
||||
// before doing stat? kinda weird?
|
||||
var self = this
|
||||
this._stat(prefix, function (er, exists) {
|
||||
self._processSimple2(prefix, index, er, exists, cb)
|
||||
})
|
||||
}
|
||||
Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
|
||||
|
||||
//console.error('ps2', prefix, exists)
|
||||
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
// If it doesn't exist, then just mark the lack of results
|
||||
if (!exists)
|
||||
return cb()
|
||||
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
var trail = /[\/\\]$/.test(prefix)
|
||||
if (prefix.charAt(0) === '/') {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
if (trail)
|
||||
prefix += '/'
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
prefix = prefix.replace(/\\/g, '/')
|
||||
|
||||
// Mark this as a match
|
||||
this._emitMatch(index, prefix)
|
||||
cb()
|
||||
}
|
||||
|
||||
// Returns either 'DIR', 'FILE', or false
|
||||
Glob.prototype._stat = function (f, cb) {
|
||||
var abs = this._makeAbs(f)
|
||||
var needDir = f.slice(-1) === '/'
|
||||
|
||||
if (f.length > this.maxLength)
|
||||
return cb()
|
||||
|
||||
if (!this.stat && ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
|
||||
if (Array.isArray(c))
|
||||
c = 'DIR'
|
||||
|
||||
// It exists, but maybe not how we need it
|
||||
if (!needDir || c === 'DIR')
|
||||
return cb(null, c)
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
// otherwise we have to stat, because maybe c=true
|
||||
// if we know it exists, but not what it is.
|
||||
}
|
||||
|
||||
var exists
|
||||
var stat = this.statCache[abs]
|
||||
if (stat !== undefined) {
|
||||
if (stat === false)
|
||||
return cb(null, stat)
|
||||
else {
|
||||
var type = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
if (needDir && type === 'FILE')
|
||||
return cb()
|
||||
else
|
||||
return cb(null, type, stat)
|
||||
}
|
||||
}
|
||||
|
||||
var self = this
|
||||
var statcb = inflight('stat\0' + abs, lstatcb_)
|
||||
if (statcb)
|
||||
fs.lstat(abs, statcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (lstat && lstat.isSymbolicLink()) {
|
||||
// If it's a symlink, then treat it as the target, unless
|
||||
// the target does not exist, then treat it as a file.
|
||||
return fs.stat(abs, function (er, stat) {
|
||||
if (er)
|
||||
self._stat2(f, abs, null, lstat, cb)
|
||||
else
|
||||
self._stat2(f, abs, er, stat, cb)
|
||||
})
|
||||
} else {
|
||||
self._stat2(f, abs, er, lstat, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
|
||||
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
|
||||
this.statCache[abs] = false
|
||||
return cb()
|
||||
}
|
||||
|
||||
var needDir = f.slice(-1) === '/'
|
||||
this.statCache[abs] = stat
|
||||
|
||||
if (abs.slice(-1) === '/' && stat && !stat.isDirectory())
|
||||
return cb(null, false, stat)
|
||||
|
||||
var c = true
|
||||
if (stat)
|
||||
c = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
this.cache[abs] = this.cache[abs] || c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
return cb(null, c, stat)
|
||||
}
|
||||
486
node_modules/glob/sync.js
generated
vendored
Normal file
486
node_modules/glob/sync.js
generated
vendored
Normal file
@@ -0,0 +1,486 @@
|
||||
module.exports = globSync
|
||||
globSync.GlobSync = GlobSync
|
||||
|
||||
var fs = require('fs')
|
||||
var rp = require('fs.realpath')
|
||||
var minimatch = require('minimatch')
|
||||
var Minimatch = minimatch.Minimatch
|
||||
var Glob = require('./glob.js').Glob
|
||||
var util = require('util')
|
||||
var path = require('path')
|
||||
var assert = require('assert')
|
||||
var isAbsolute = require('path-is-absolute')
|
||||
var common = require('./common.js')
|
||||
var alphasort = common.alphasort
|
||||
var alphasorti = common.alphasorti
|
||||
var setopts = common.setopts
|
||||
var ownProp = common.ownProp
|
||||
var childrenIgnored = common.childrenIgnored
|
||||
var isIgnored = common.isIgnored
|
||||
|
||||
function globSync (pattern, options) {
|
||||
if (typeof options === 'function' || arguments.length === 3)
|
||||
throw new TypeError('callback provided to sync glob\n'+
|
||||
'See: https://github.com/isaacs/node-glob/issues/167')
|
||||
|
||||
return new GlobSync(pattern, options).found
|
||||
}
|
||||
|
||||
function GlobSync (pattern, options) {
|
||||
if (!pattern)
|
||||
throw new Error('must provide pattern')
|
||||
|
||||
if (typeof options === 'function' || arguments.length === 3)
|
||||
throw new TypeError('callback provided to sync glob\n'+
|
||||
'See: https://github.com/isaacs/node-glob/issues/167')
|
||||
|
||||
if (!(this instanceof GlobSync))
|
||||
return new GlobSync(pattern, options)
|
||||
|
||||
setopts(this, pattern, options)
|
||||
|
||||
if (this.noprocess)
|
||||
return this
|
||||
|
||||
var n = this.minimatch.set.length
|
||||
this.matches = new Array(n)
|
||||
for (var i = 0; i < n; i ++) {
|
||||
this._process(this.minimatch.set[i], i, false)
|
||||
}
|
||||
this._finish()
|
||||
}
|
||||
|
||||
GlobSync.prototype._finish = function () {
|
||||
assert(this instanceof GlobSync)
|
||||
if (this.realpath) {
|
||||
var self = this
|
||||
this.matches.forEach(function (matchset, index) {
|
||||
var set = self.matches[index] = Object.create(null)
|
||||
for (var p in matchset) {
|
||||
try {
|
||||
p = self._makeAbs(p)
|
||||
var real = rp.realpathSync(p, self.realpathCache)
|
||||
set[real] = true
|
||||
} catch (er) {
|
||||
if (er.syscall === 'stat')
|
||||
set[self._makeAbs(p)] = true
|
||||
else
|
||||
throw er
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
common.finish(this)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._process = function (pattern, index, inGlobStar) {
|
||||
assert(this instanceof GlobSync)
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === 'string') {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// See if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
this._processSimple(pattern.join('/'), index)
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's 'absolute' like /foo/bar,
|
||||
// or 'relative' like '../baz'
|
||||
prefix = pattern.slice(0, n).join('/')
|
||||
break
|
||||
}
|
||||
|
||||
var remain = pattern.slice(n)
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null)
|
||||
read = '.'
|
||||
else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
|
||||
if (!prefix || !isAbsolute(prefix))
|
||||
prefix = '/' + prefix
|
||||
read = prefix
|
||||
} else
|
||||
read = prefix
|
||||
|
||||
var abs = this._makeAbs(read)
|
||||
|
||||
//if ignored, skip processing
|
||||
if (childrenIgnored(this, read))
|
||||
return
|
||||
|
||||
var isGlobStar = remain[0] === minimatch.GLOBSTAR
|
||||
if (isGlobStar)
|
||||
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar)
|
||||
else
|
||||
this._processReaddir(prefix, read, abs, remain, index, inGlobStar)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
|
||||
var entries = this._readdir(abs, inGlobStar)
|
||||
|
||||
// if the abs isn't a dir, then nothing can match!
|
||||
if (!entries)
|
||||
return
|
||||
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = remain[0]
|
||||
var negate = !!this.minimatch.negate
|
||||
var rawGlob = pn._glob
|
||||
var dotOk = this.dot || rawGlob.charAt(0) === '.'
|
||||
|
||||
var matchedEntries = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) !== '.' || dotOk) {
|
||||
var m
|
||||
if (negate && !prefix) {
|
||||
m = !e.match(pn)
|
||||
} else {
|
||||
m = e.match(pn)
|
||||
}
|
||||
if (m)
|
||||
matchedEntries.push(e)
|
||||
}
|
||||
}
|
||||
|
||||
var len = matchedEntries.length
|
||||
// If there are no matched entries, then nothing matches.
|
||||
if (len === 0)
|
||||
return
|
||||
|
||||
// if this is the last remaining pattern bit, then no need for
|
||||
// an additional stat *unless* the user has specified mark or
|
||||
// stat explicitly. We know they exist, since readdir returned
|
||||
// them.
|
||||
|
||||
if (remain.length === 1 && !this.mark && !this.stat) {
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
if (prefix) {
|
||||
if (prefix.slice(-1) !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
|
||||
if (e.charAt(0) === '/' && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
this._emitMatch(index, e)
|
||||
}
|
||||
// This was the last one, and no stats were needed
|
||||
return
|
||||
}
|
||||
|
||||
// now test all matched entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
remain.shift()
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
var newPattern
|
||||
if (prefix)
|
||||
newPattern = [prefix, e]
|
||||
else
|
||||
newPattern = [e]
|
||||
this._process(newPattern.concat(remain), index, inGlobStar)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._emitMatch = function (index, e) {
|
||||
if (isIgnored(this, e))
|
||||
return
|
||||
|
||||
var abs = this._makeAbs(e)
|
||||
|
||||
if (this.mark)
|
||||
e = this._mark(e)
|
||||
|
||||
if (this.absolute) {
|
||||
e = abs
|
||||
}
|
||||
|
||||
if (this.matches[index][e])
|
||||
return
|
||||
|
||||
if (this.nodir) {
|
||||
var c = this.cache[abs]
|
||||
if (c === 'DIR' || Array.isArray(c))
|
||||
return
|
||||
}
|
||||
|
||||
this.matches[index][e] = true
|
||||
|
||||
if (this.stat)
|
||||
this._stat(e)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._readdirInGlobStar = function (abs) {
|
||||
// follow all symlinked directories forever
|
||||
// just proceed as if this is a non-globstar situation
|
||||
if (this.follow)
|
||||
return this._readdir(abs, false)
|
||||
|
||||
var entries
|
||||
var lstat
|
||||
var stat
|
||||
try {
|
||||
lstat = fs.lstatSync(abs)
|
||||
} catch (er) {
|
||||
if (er.code === 'ENOENT') {
|
||||
// lstat failed, doesn't exist
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
var isSym = lstat && lstat.isSymbolicLink()
|
||||
this.symlinks[abs] = isSym
|
||||
|
||||
// If it's not a symlink or a dir, then it's definitely a regular file.
|
||||
// don't bother doing a readdir in that case.
|
||||
if (!isSym && lstat && !lstat.isDirectory())
|
||||
this.cache[abs] = 'FILE'
|
||||
else
|
||||
entries = this._readdir(abs, false)
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdir = function (abs, inGlobStar) {
|
||||
var entries
|
||||
|
||||
if (inGlobStar && !ownProp(this.symlinks, abs))
|
||||
return this._readdirInGlobStar(abs)
|
||||
|
||||
if (ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
if (!c || c === 'FILE')
|
||||
return null
|
||||
|
||||
if (Array.isArray(c))
|
||||
return c
|
||||
}
|
||||
|
||||
try {
|
||||
return this._readdirEntries(abs, fs.readdirSync(abs))
|
||||
} catch (er) {
|
||||
this._readdirError(abs, er)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdirEntries = function (abs, entries) {
|
||||
// if we haven't asked to stat everything, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time.
|
||||
if (!this.mark && !this.stat) {
|
||||
for (var i = 0; i < entries.length; i ++) {
|
||||
var e = entries[i]
|
||||
if (abs === '/')
|
||||
e = abs + e
|
||||
else
|
||||
e = abs + '/' + e
|
||||
this.cache[e] = true
|
||||
}
|
||||
}
|
||||
|
||||
this.cache[abs] = entries
|
||||
|
||||
// mark and cache dir-ness
|
||||
return entries
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdirError = function (f, er) {
|
||||
// handle errors, and cache the information
|
||||
switch (er.code) {
|
||||
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
|
||||
case 'ENOTDIR': // totally normal. means it *does* exist.
|
||||
var abs = this._makeAbs(f)
|
||||
this.cache[abs] = 'FILE'
|
||||
if (abs === this.cwdAbs) {
|
||||
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
|
||||
error.path = this.cwd
|
||||
error.code = er.code
|
||||
throw error
|
||||
}
|
||||
break
|
||||
|
||||
case 'ENOENT': // not terribly unusual
|
||||
case 'ELOOP':
|
||||
case 'ENAMETOOLONG':
|
||||
case 'UNKNOWN':
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
break
|
||||
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
if (this.strict)
|
||||
throw er
|
||||
if (!this.silent)
|
||||
console.error('glob error', er)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
|
||||
|
||||
var entries = this._readdir(abs, inGlobStar)
|
||||
|
||||
// no entries means not a dir, so it can never have matches
|
||||
// foo.txt/** doesn't match foo.txt
|
||||
if (!entries)
|
||||
return
|
||||
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var remainWithoutGlobStar = remain.slice(1)
|
||||
var gspref = prefix ? [ prefix ] : []
|
||||
var noGlobStar = gspref.concat(remainWithoutGlobStar)
|
||||
|
||||
// the noGlobStar pattern exits the inGlobStar state
|
||||
this._process(noGlobStar, index, false)
|
||||
|
||||
var len = entries.length
|
||||
var isSym = this.symlinks[abs]
|
||||
|
||||
// If it's a symlink, and we're in a globstar, then stop
|
||||
if (isSym && inGlobStar)
|
||||
return
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) === '.' && !this.dot)
|
||||
continue
|
||||
|
||||
// these two cases enter the inGlobStar state
|
||||
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
|
||||
this._process(instead, index, true)
|
||||
|
||||
var below = gspref.concat(entries[i], remain)
|
||||
this._process(below, index, true)
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._processSimple = function (prefix, index) {
|
||||
// XXX review this. Shouldn't it be doing the mounting etc
|
||||
// before doing stat? kinda weird?
|
||||
var exists = this._stat(prefix)
|
||||
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
// If it doesn't exist, then just mark the lack of results
|
||||
if (!exists)
|
||||
return
|
||||
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
var trail = /[\/\\]$/.test(prefix)
|
||||
if (prefix.charAt(0) === '/') {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
if (trail)
|
||||
prefix += '/'
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
prefix = prefix.replace(/\\/g, '/')
|
||||
|
||||
// Mark this as a match
|
||||
this._emitMatch(index, prefix)
|
||||
}
|
||||
|
||||
// Returns either 'DIR', 'FILE', or false
|
||||
GlobSync.prototype._stat = function (f) {
|
||||
var abs = this._makeAbs(f)
|
||||
var needDir = f.slice(-1) === '/'
|
||||
|
||||
if (f.length > this.maxLength)
|
||||
return false
|
||||
|
||||
if (!this.stat && ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
|
||||
if (Array.isArray(c))
|
||||
c = 'DIR'
|
||||
|
||||
// It exists, but maybe not how we need it
|
||||
if (!needDir || c === 'DIR')
|
||||
return c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return false
|
||||
|
||||
// otherwise we have to stat, because maybe c=true
|
||||
// if we know it exists, but not what it is.
|
||||
}
|
||||
|
||||
var exists
|
||||
var stat = this.statCache[abs]
|
||||
if (!stat) {
|
||||
var lstat
|
||||
try {
|
||||
lstat = fs.lstatSync(abs)
|
||||
} catch (er) {
|
||||
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
|
||||
this.statCache[abs] = false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (lstat && lstat.isSymbolicLink()) {
|
||||
try {
|
||||
stat = fs.statSync(abs)
|
||||
} catch (er) {
|
||||
stat = lstat
|
||||
}
|
||||
} else {
|
||||
stat = lstat
|
||||
}
|
||||
}
|
||||
|
||||
this.statCache[abs] = stat
|
||||
|
||||
var c = true
|
||||
if (stat)
|
||||
c = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
|
||||
this.cache[abs] = this.cache[abs] || c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return false
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
GlobSync.prototype._mark = function (p) {
|
||||
return common.mark(this, p)
|
||||
}
|
||||
|
||||
GlobSync.prototype._makeAbs = function (f) {
|
||||
return common.makeAbs(this, f)
|
||||
}
|
||||
364
node_modules/got/index.js
generated
vendored
Normal file
364
node_modules/got/index.js
generated
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
'use strict';
|
||||
const EventEmitter = require('events');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const PassThrough = require('stream').PassThrough;
|
||||
const urlLib = require('url');
|
||||
const querystring = require('querystring');
|
||||
const duplexer3 = require('duplexer3');
|
||||
const isStream = require('is-stream');
|
||||
const getStream = require('get-stream');
|
||||
const timedOut = require('timed-out');
|
||||
const urlParseLax = require('url-parse-lax');
|
||||
const lowercaseKeys = require('lowercase-keys');
|
||||
const isRedirect = require('is-redirect');
|
||||
const unzipResponse = require('unzip-response');
|
||||
const createErrorClass = require('create-error-class');
|
||||
const isRetryAllowed = require('is-retry-allowed');
|
||||
const Buffer = require('safe-buffer').Buffer;
|
||||
const pkg = require('./package');
|
||||
|
||||
function requestAsEventEmitter(opts) {
|
||||
opts = opts || {};
|
||||
|
||||
const ee = new EventEmitter();
|
||||
const requestUrl = opts.href || urlLib.resolve(urlLib.format(opts), opts.path);
|
||||
let redirectCount = 0;
|
||||
let retryCount = 0;
|
||||
let redirectUrl;
|
||||
|
||||
const get = opts => {
|
||||
const fn = opts.protocol === 'https:' ? https : http;
|
||||
|
||||
const req = fn.request(opts, res => {
|
||||
const statusCode = res.statusCode;
|
||||
|
||||
if (isRedirect(statusCode) && opts.followRedirect && 'location' in res.headers && (opts.method === 'GET' || opts.method === 'HEAD')) {
|
||||
res.resume();
|
||||
|
||||
if (++redirectCount > 10) {
|
||||
ee.emit('error', new got.MaxRedirectsError(statusCode, opts), null, res);
|
||||
return;
|
||||
}
|
||||
|
||||
const bufferString = Buffer.from(res.headers.location, 'binary').toString();
|
||||
|
||||
redirectUrl = urlLib.resolve(urlLib.format(opts), bufferString);
|
||||
const redirectOpts = Object.assign({}, opts, urlLib.parse(redirectUrl));
|
||||
|
||||
ee.emit('redirect', res, redirectOpts);
|
||||
|
||||
get(redirectOpts);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setImmediate(() => {
|
||||
const response = typeof unzipResponse === 'function' && req.method !== 'HEAD' ? unzipResponse(res) : res;
|
||||
response.url = redirectUrl || requestUrl;
|
||||
response.requestUrl = requestUrl;
|
||||
|
||||
ee.emit('response', response);
|
||||
});
|
||||
});
|
||||
|
||||
req.once('error', err => {
|
||||
const backoff = opts.retries(++retryCount, err);
|
||||
|
||||
if (backoff) {
|
||||
setTimeout(get, backoff, opts);
|
||||
return;
|
||||
}
|
||||
|
||||
ee.emit('error', new got.RequestError(err, opts));
|
||||
});
|
||||
|
||||
if (opts.gotTimeout) {
|
||||
timedOut(req, opts.gotTimeout);
|
||||
}
|
||||
|
||||
setImmediate(() => {
|
||||
ee.emit('request', req);
|
||||
});
|
||||
};
|
||||
|
||||
get(opts);
|
||||
return ee;
|
||||
}
|
||||
|
||||
function asPromise(opts) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const ee = requestAsEventEmitter(opts);
|
||||
|
||||
ee.on('request', req => {
|
||||
if (isStream(opts.body)) {
|
||||
opts.body.pipe(req);
|
||||
opts.body = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
req.end(opts.body);
|
||||
});
|
||||
|
||||
ee.on('response', res => {
|
||||
const stream = opts.encoding === null ? getStream.buffer(res) : getStream(res, opts);
|
||||
|
||||
stream
|
||||
.catch(err => reject(new got.ReadError(err, opts)))
|
||||
.then(data => {
|
||||
const statusCode = res.statusCode;
|
||||
const limitStatusCode = opts.followRedirect ? 299 : 399;
|
||||
|
||||
res.body = data;
|
||||
|
||||
if (opts.json && res.body) {
|
||||
try {
|
||||
res.body = JSON.parse(res.body);
|
||||
} catch (e) {
|
||||
throw new got.ParseError(e, statusCode, opts, data);
|
||||
}
|
||||
}
|
||||
|
||||
if (statusCode < 200 || statusCode > limitStatusCode) {
|
||||
throw new got.HTTPError(statusCode, opts);
|
||||
}
|
||||
|
||||
resolve(res);
|
||||
})
|
||||
.catch(err => {
|
||||
Object.defineProperty(err, 'response', {value: res});
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
ee.on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
function asStream(opts) {
|
||||
const input = new PassThrough();
|
||||
const output = new PassThrough();
|
||||
const proxy = duplexer3(input, output);
|
||||
|
||||
if (opts.json) {
|
||||
throw new Error('got can not be used as stream when options.json is used');
|
||||
}
|
||||
|
||||
if (opts.body) {
|
||||
proxy.write = () => {
|
||||
throw new Error('got\'s stream is not writable when options.body is used');
|
||||
};
|
||||
}
|
||||
|
||||
const ee = requestAsEventEmitter(opts);
|
||||
|
||||
ee.on('request', req => {
|
||||
proxy.emit('request', req);
|
||||
|
||||
if (isStream(opts.body)) {
|
||||
opts.body.pipe(req);
|
||||
return;
|
||||
}
|
||||
|
||||
if (opts.body) {
|
||||
req.end(opts.body);
|
||||
return;
|
||||
}
|
||||
|
||||
if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
|
||||
input.pipe(req);
|
||||
return;
|
||||
}
|
||||
|
||||
req.end();
|
||||
});
|
||||
|
||||
ee.on('response', res => {
|
||||
const statusCode = res.statusCode;
|
||||
|
||||
res.pipe(output);
|
||||
|
||||
if (statusCode < 200 || statusCode > 299) {
|
||||
proxy.emit('error', new got.HTTPError(statusCode, opts), null, res);
|
||||
return;
|
||||
}
|
||||
|
||||
proxy.emit('response', res);
|
||||
});
|
||||
|
||||
ee.on('redirect', proxy.emit.bind(proxy, 'redirect'));
|
||||
ee.on('error', proxy.emit.bind(proxy, 'error'));
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
function normalizeArguments(url, opts) {
|
||||
if (typeof url !== 'string' && typeof url !== 'object') {
|
||||
throw new Error(`Parameter \`url\` must be a string or object, not ${typeof url}`);
|
||||
}
|
||||
|
||||
if (typeof url === 'string') {
|
||||
url = url.replace(/^unix:/, 'http://$&');
|
||||
url = urlParseLax(url);
|
||||
|
||||
if (url.auth) {
|
||||
throw new Error('Basic authentication must be done with auth option');
|
||||
}
|
||||
}
|
||||
|
||||
opts = Object.assign(
|
||||
{
|
||||
protocol: 'http:',
|
||||
path: '',
|
||||
retries: 5
|
||||
},
|
||||
url,
|
||||
opts
|
||||
);
|
||||
|
||||
opts.headers = Object.assign({
|
||||
'user-agent': `${pkg.name}/${pkg.version} (https://github.com/sindresorhus/got)`,
|
||||
'accept-encoding': 'gzip,deflate'
|
||||
}, lowercaseKeys(opts.headers));
|
||||
|
||||
const query = opts.query;
|
||||
|
||||
if (query) {
|
||||
if (typeof query !== 'string') {
|
||||
opts.query = querystring.stringify(query);
|
||||
}
|
||||
|
||||
opts.path = `${opts.path.split('?')[0]}?${opts.query}`;
|
||||
delete opts.query;
|
||||
}
|
||||
|
||||
if (opts.json && opts.headers.accept === undefined) {
|
||||
opts.headers.accept = 'application/json';
|
||||
}
|
||||
|
||||
let body = opts.body;
|
||||
|
||||
if (body) {
|
||||
if (typeof body !== 'string' && !(body !== null && typeof body === 'object')) {
|
||||
throw new Error('options.body must be a ReadableStream, string, Buffer or plain Object');
|
||||
}
|
||||
|
||||
opts.method = opts.method || 'POST';
|
||||
|
||||
if (isStream(body) && typeof body.getBoundary === 'function') {
|
||||
// Special case for https://github.com/form-data/form-data
|
||||
opts.headers['content-type'] = opts.headers['content-type'] || `multipart/form-data; boundary=${body.getBoundary()}`;
|
||||
} else if (body !== null && typeof body === 'object' && !Buffer.isBuffer(body) && !isStream(body)) {
|
||||
opts.headers['content-type'] = opts.headers['content-type'] || 'application/x-www-form-urlencoded';
|
||||
body = opts.body = querystring.stringify(body);
|
||||
}
|
||||
|
||||
if (opts.headers['content-length'] === undefined && opts.headers['transfer-encoding'] === undefined && !isStream(body)) {
|
||||
const length = typeof body === 'string' ? Buffer.byteLength(body) : body.length;
|
||||
opts.headers['content-length'] = length;
|
||||
}
|
||||
}
|
||||
|
||||
opts.method = (opts.method || 'GET').toUpperCase();
|
||||
|
||||
if (opts.hostname === 'unix') {
|
||||
const matches = /(.+):(.+)/.exec(opts.path);
|
||||
|
||||
if (matches) {
|
||||
opts.socketPath = matches[1];
|
||||
opts.path = matches[2];
|
||||
opts.host = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof opts.retries !== 'function') {
|
||||
const retries = opts.retries;
|
||||
|
||||
opts.retries = (iter, err) => {
|
||||
if (iter > retries || !isRetryAllowed(err)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const noise = Math.random() * 100;
|
||||
|
||||
return ((1 << iter) * 1000) + noise;
|
||||
};
|
||||
}
|
||||
|
||||
if (opts.followRedirect === undefined) {
|
||||
opts.followRedirect = true;
|
||||
}
|
||||
|
||||
if (opts.timeout) {
|
||||
opts.gotTimeout = opts.timeout;
|
||||
delete opts.timeout;
|
||||
}
|
||||
|
||||
return opts;
|
||||
}
|
||||
|
||||
function got(url, opts) {
|
||||
try {
|
||||
return asPromise(normalizeArguments(url, opts));
|
||||
} catch (err) {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
const helpers = [
|
||||
'get',
|
||||
'post',
|
||||
'put',
|
||||
'patch',
|
||||
'head',
|
||||
'delete'
|
||||
];
|
||||
|
||||
helpers.forEach(el => {
|
||||
got[el] = (url, opts) => got(url, Object.assign({}, opts, {method: el}));
|
||||
});
|
||||
|
||||
got.stream = (url, opts) => asStream(normalizeArguments(url, opts));
|
||||
|
||||
for (const el of helpers) {
|
||||
got.stream[el] = (url, opts) => got.stream(url, Object.assign({}, opts, {method: el}));
|
||||
}
|
||||
|
||||
function stdError(error, opts) {
|
||||
if (error.code !== undefined) {
|
||||
this.code = error.code;
|
||||
}
|
||||
|
||||
Object.assign(this, {
|
||||
message: error.message,
|
||||
host: opts.host,
|
||||
hostname: opts.hostname,
|
||||
method: opts.method,
|
||||
path: opts.path
|
||||
});
|
||||
}
|
||||
|
||||
got.RequestError = createErrorClass('RequestError', stdError);
|
||||
got.ReadError = createErrorClass('ReadError', stdError);
|
||||
got.ParseError = createErrorClass('ParseError', function (e, statusCode, opts, data) {
|
||||
stdError.call(this, e, opts);
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = http.STATUS_CODES[this.statusCode];
|
||||
this.message = `${e.message} in "${urlLib.format(opts)}": \n${data.slice(0, 77)}...`;
|
||||
});
|
||||
|
||||
got.HTTPError = createErrorClass('HTTPError', function (statusCode, opts) {
|
||||
stdError.call(this, {}, opts);
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = http.STATUS_CODES[this.statusCode];
|
||||
this.message = `Response code ${this.statusCode} (${this.statusMessage})`;
|
||||
});
|
||||
|
||||
got.MaxRedirectsError = createErrorClass('MaxRedirectsError', function (statusCode, opts) {
|
||||
stdError.call(this, {}, opts);
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = http.STATUS_CODES[this.statusCode];
|
||||
this.message = 'Redirected 10 times. Aborting.';
|
||||
});
|
||||
|
||||
module.exports = got;
|
||||
19
node_modules/graceful-fs/clone.js
generated
vendored
Normal file
19
node_modules/graceful-fs/clone.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = clone
|
||||
|
||||
function clone (obj) {
|
||||
if (obj === null || typeof obj !== 'object')
|
||||
return obj
|
||||
|
||||
if (obj instanceof Object)
|
||||
var copy = { __proto__: obj.__proto__ }
|
||||
else
|
||||
var copy = Object.create(null)
|
||||
|
||||
Object.getOwnPropertyNames(obj).forEach(function (key) {
|
||||
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
|
||||
})
|
||||
|
||||
return copy
|
||||
}
|
||||
279
node_modules/graceful-fs/graceful-fs.js
generated
vendored
Normal file
279
node_modules/graceful-fs/graceful-fs.js
generated
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
var fs = require('fs')
|
||||
var polyfills = require('./polyfills.js')
|
||||
var legacy = require('./legacy-streams.js')
|
||||
var clone = require('./clone.js')
|
||||
|
||||
var queue = []
|
||||
|
||||
var util = require('util')
|
||||
|
||||
function noop () {}
|
||||
|
||||
var debug = noop
|
||||
if (util.debuglog)
|
||||
debug = util.debuglog('gfs4')
|
||||
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
|
||||
debug = function() {
|
||||
var m = util.format.apply(util, arguments)
|
||||
m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
|
||||
console.error(m)
|
||||
}
|
||||
|
||||
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
|
||||
process.on('exit', function() {
|
||||
debug(queue)
|
||||
require('assert').equal(queue.length, 0)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = patch(clone(fs))
|
||||
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
||||
module.exports = patch(fs)
|
||||
fs.__patched = true;
|
||||
}
|
||||
|
||||
// Always patch fs.close/closeSync, because we want to
|
||||
// retry() whenever a close happens *anywhere* in the program.
|
||||
// This is essential when multiple graceful-fs instances are
|
||||
// in play at the same time.
|
||||
module.exports.close = (function (fs$close) { return function (fd, cb) {
|
||||
return fs$close.call(fs, fd, function (err) {
|
||||
if (!err)
|
||||
retry()
|
||||
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
})
|
||||
}})(fs.close)
|
||||
|
||||
module.exports.closeSync = (function (fs$closeSync) { return function (fd) {
|
||||
// Note that graceful-fs also retries when fs.closeSync() fails.
|
||||
// Looks like a bug to me, although it's probably a harmless one.
|
||||
var rval = fs$closeSync.apply(fs, arguments)
|
||||
retry()
|
||||
return rval
|
||||
}})(fs.closeSync)
|
||||
|
||||
// Only patch fs once, otherwise we'll run into a memory leak if
|
||||
// graceful-fs is loaded multiple times, such as in test environments that
|
||||
// reset the loaded modules between tests.
|
||||
// We look for the string `graceful-fs` from the comment above. This
|
||||
// way we are not adding any extra properties and it will detect if older
|
||||
// versions of graceful-fs are installed.
|
||||
if (!/\bgraceful-fs\b/.test(fs.closeSync.toString())) {
|
||||
fs.closeSync = module.exports.closeSync;
|
||||
fs.close = module.exports.close;
|
||||
}
|
||||
|
||||
function patch (fs) {
|
||||
// Everything that references the open() function needs to be in here
|
||||
polyfills(fs)
|
||||
fs.gracefulify = patch
|
||||
fs.FileReadStream = ReadStream; // Legacy name.
|
||||
fs.FileWriteStream = WriteStream; // Legacy name.
|
||||
fs.createReadStream = createReadStream
|
||||
fs.createWriteStream = createWriteStream
|
||||
var fs$readFile = fs.readFile
|
||||
fs.readFile = readFile
|
||||
function readFile (path, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$readFile(path, options, cb)
|
||||
|
||||
function go$readFile (path, options, cb) {
|
||||
return fs$readFile(path, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$readFile, [path, options, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$writeFile = fs.writeFile
|
||||
fs.writeFile = writeFile
|
||||
function writeFile (path, data, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$writeFile(path, data, options, cb)
|
||||
|
||||
function go$writeFile (path, data, options, cb) {
|
||||
return fs$writeFile(path, data, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$writeFile, [path, data, options, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$appendFile = fs.appendFile
|
||||
if (fs$appendFile)
|
||||
fs.appendFile = appendFile
|
||||
function appendFile (path, data, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$appendFile(path, data, options, cb)
|
||||
|
||||
function go$appendFile (path, data, options, cb) {
|
||||
return fs$appendFile(path, data, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$appendFile, [path, data, options, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$readdir = fs.readdir
|
||||
fs.readdir = readdir
|
||||
function readdir (path, options, cb) {
|
||||
var args = [path]
|
||||
if (typeof options !== 'function') {
|
||||
args.push(options)
|
||||
} else {
|
||||
cb = options
|
||||
}
|
||||
args.push(go$readdir$cb)
|
||||
|
||||
return go$readdir(args)
|
||||
|
||||
function go$readdir$cb (err, files) {
|
||||
if (files && files.sort)
|
||||
files.sort()
|
||||
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$readdir, [args]])
|
||||
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function go$readdir (args) {
|
||||
return fs$readdir.apply(fs, args)
|
||||
}
|
||||
|
||||
if (process.version.substr(0, 4) === 'v0.8') {
|
||||
var legStreams = legacy(fs)
|
||||
ReadStream = legStreams.ReadStream
|
||||
WriteStream = legStreams.WriteStream
|
||||
}
|
||||
|
||||
var fs$ReadStream = fs.ReadStream
|
||||
if (fs$ReadStream) {
|
||||
ReadStream.prototype = Object.create(fs$ReadStream.prototype)
|
||||
ReadStream.prototype.open = ReadStream$open
|
||||
}
|
||||
|
||||
var fs$WriteStream = fs.WriteStream
|
||||
if (fs$WriteStream) {
|
||||
WriteStream.prototype = Object.create(fs$WriteStream.prototype)
|
||||
WriteStream.prototype.open = WriteStream$open
|
||||
}
|
||||
|
||||
fs.ReadStream = ReadStream
|
||||
fs.WriteStream = WriteStream
|
||||
|
||||
function ReadStream (path, options) {
|
||||
if (this instanceof ReadStream)
|
||||
return fs$ReadStream.apply(this, arguments), this
|
||||
else
|
||||
return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
|
||||
}
|
||||
|
||||
function ReadStream$open () {
|
||||
var that = this
|
||||
open(that.path, that.flags, that.mode, function (err, fd) {
|
||||
if (err) {
|
||||
if (that.autoClose)
|
||||
that.destroy()
|
||||
|
||||
that.emit('error', err)
|
||||
} else {
|
||||
that.fd = fd
|
||||
that.emit('open', fd)
|
||||
that.read()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function WriteStream (path, options) {
|
||||
if (this instanceof WriteStream)
|
||||
return fs$WriteStream.apply(this, arguments), this
|
||||
else
|
||||
return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
|
||||
}
|
||||
|
||||
function WriteStream$open () {
|
||||
var that = this
|
||||
open(that.path, that.flags, that.mode, function (err, fd) {
|
||||
if (err) {
|
||||
that.destroy()
|
||||
that.emit('error', err)
|
||||
} else {
|
||||
that.fd = fd
|
||||
that.emit('open', fd)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function createReadStream (path, options) {
|
||||
return new ReadStream(path, options)
|
||||
}
|
||||
|
||||
function createWriteStream (path, options) {
|
||||
return new WriteStream(path, options)
|
||||
}
|
||||
|
||||
var fs$open = fs.open
|
||||
fs.open = open
|
||||
function open (path, flags, mode, cb) {
|
||||
if (typeof mode === 'function')
|
||||
cb = mode, mode = null
|
||||
|
||||
return go$open(path, flags, mode, cb)
|
||||
|
||||
function go$open (path, flags, mode, cb) {
|
||||
return fs$open(path, flags, mode, function (err, fd) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$open, [path, flags, mode, cb]])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
retry()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return fs
|
||||
}
|
||||
|
||||
function enqueue (elem) {
|
||||
debug('ENQUEUE', elem[0].name, elem[1])
|
||||
queue.push(elem)
|
||||
}
|
||||
|
||||
function retry () {
|
||||
var elem = queue.shift()
|
||||
if (elem) {
|
||||
debug('RETRY', elem[0].name, elem[1])
|
||||
elem[0].apply(null, elem[1])
|
||||
}
|
||||
}
|
||||
118
node_modules/graceful-fs/legacy-streams.js
generated
vendored
Normal file
118
node_modules/graceful-fs/legacy-streams.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
var Stream = require('stream').Stream
|
||||
|
||||
module.exports = legacy
|
||||
|
||||
function legacy (fs) {
|
||||
return {
|
||||
ReadStream: ReadStream,
|
||||
WriteStream: WriteStream
|
||||
}
|
||||
|
||||
function ReadStream (path, options) {
|
||||
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
||||
|
||||
Stream.call(this);
|
||||
|
||||
var self = this;
|
||||
|
||||
this.path = path;
|
||||
this.fd = null;
|
||||
this.readable = true;
|
||||
this.paused = false;
|
||||
|
||||
this.flags = 'r';
|
||||
this.mode = 438; /*=0666*/
|
||||
this.bufferSize = 64 * 1024;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Mixin options into this
|
||||
var keys = Object.keys(options);
|
||||
for (var index = 0, length = keys.length; index < length; index++) {
|
||||
var key = keys[index];
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
if (this.encoding) this.setEncoding(this.encoding);
|
||||
|
||||
if (this.start !== undefined) {
|
||||
if ('number' !== typeof this.start) {
|
||||
throw TypeError('start must be a Number');
|
||||
}
|
||||
if (this.end === undefined) {
|
||||
this.end = Infinity;
|
||||
} else if ('number' !== typeof this.end) {
|
||||
throw TypeError('end must be a Number');
|
||||
}
|
||||
|
||||
if (this.start > this.end) {
|
||||
throw new Error('start must be <= end');
|
||||
}
|
||||
|
||||
this.pos = this.start;
|
||||
}
|
||||
|
||||
if (this.fd !== null) {
|
||||
process.nextTick(function() {
|
||||
self._read();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
fs.open(this.path, this.flags, this.mode, function (err, fd) {
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
self.readable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
self.fd = fd;
|
||||
self.emit('open', fd);
|
||||
self._read();
|
||||
})
|
||||
}
|
||||
|
||||
function WriteStream (path, options) {
|
||||
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
||||
|
||||
Stream.call(this);
|
||||
|
||||
this.path = path;
|
||||
this.fd = null;
|
||||
this.writable = true;
|
||||
|
||||
this.flags = 'w';
|
||||
this.encoding = 'binary';
|
||||
this.mode = 438; /*=0666*/
|
||||
this.bytesWritten = 0;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Mixin options into this
|
||||
var keys = Object.keys(options);
|
||||
for (var index = 0, length = keys.length; index < length; index++) {
|
||||
var key = keys[index];
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
if (this.start !== undefined) {
|
||||
if ('number' !== typeof this.start) {
|
||||
throw TypeError('start must be a Number');
|
||||
}
|
||||
if (this.start < 0) {
|
||||
throw new Error('start must be >= zero');
|
||||
}
|
||||
|
||||
this.pos = this.start;
|
||||
}
|
||||
|
||||
this.busy = false;
|
||||
this._queue = [];
|
||||
|
||||
if (this.fd === null) {
|
||||
this._open = fs.open;
|
||||
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
||||
this.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
329
node_modules/graceful-fs/polyfills.js
generated
vendored
Normal file
329
node_modules/graceful-fs/polyfills.js
generated
vendored
Normal file
@@ -0,0 +1,329 @@
|
||||
var constants = require('constants')
|
||||
|
||||
var origCwd = process.cwd
|
||||
var cwd = null
|
||||
|
||||
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
|
||||
|
||||
process.cwd = function() {
|
||||
if (!cwd)
|
||||
cwd = origCwd.call(process)
|
||||
return cwd
|
||||
}
|
||||
try {
|
||||
process.cwd()
|
||||
} catch (er) {}
|
||||
|
||||
var chdir = process.chdir
|
||||
process.chdir = function(d) {
|
||||
cwd = null
|
||||
chdir.call(process, d)
|
||||
}
|
||||
|
||||
module.exports = patch
|
||||
|
||||
function patch (fs) {
|
||||
// (re-)implement some things that are known busted or missing.
|
||||
|
||||
// lchmod, broken prior to 0.6.2
|
||||
// back-port the fix here.
|
||||
if (constants.hasOwnProperty('O_SYMLINK') &&
|
||||
process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
||||
patchLchmod(fs)
|
||||
}
|
||||
|
||||
// lutimes implementation, or no-op
|
||||
if (!fs.lutimes) {
|
||||
patchLutimes(fs)
|
||||
}
|
||||
|
||||
// https://github.com/isaacs/node-graceful-fs/issues/4
|
||||
// Chown should not fail on einval or eperm if non-root.
|
||||
// It should not fail on enosys ever, as this just indicates
|
||||
// that a fs doesn't support the intended operation.
|
||||
|
||||
fs.chown = chownFix(fs.chown)
|
||||
fs.fchown = chownFix(fs.fchown)
|
||||
fs.lchown = chownFix(fs.lchown)
|
||||
|
||||
fs.chmod = chmodFix(fs.chmod)
|
||||
fs.fchmod = chmodFix(fs.fchmod)
|
||||
fs.lchmod = chmodFix(fs.lchmod)
|
||||
|
||||
fs.chownSync = chownFixSync(fs.chownSync)
|
||||
fs.fchownSync = chownFixSync(fs.fchownSync)
|
||||
fs.lchownSync = chownFixSync(fs.lchownSync)
|
||||
|
||||
fs.chmodSync = chmodFixSync(fs.chmodSync)
|
||||
fs.fchmodSync = chmodFixSync(fs.fchmodSync)
|
||||
fs.lchmodSync = chmodFixSync(fs.lchmodSync)
|
||||
|
||||
fs.stat = statFix(fs.stat)
|
||||
fs.fstat = statFix(fs.fstat)
|
||||
fs.lstat = statFix(fs.lstat)
|
||||
|
||||
fs.statSync = statFixSync(fs.statSync)
|
||||
fs.fstatSync = statFixSync(fs.fstatSync)
|
||||
fs.lstatSync = statFixSync(fs.lstatSync)
|
||||
|
||||
// if lchmod/lchown do not exist, then make them no-ops
|
||||
if (!fs.lchmod) {
|
||||
fs.lchmod = function (path, mode, cb) {
|
||||
if (cb) process.nextTick(cb)
|
||||
}
|
||||
fs.lchmodSync = function () {}
|
||||
}
|
||||
if (!fs.lchown) {
|
||||
fs.lchown = function (path, uid, gid, cb) {
|
||||
if (cb) process.nextTick(cb)
|
||||
}
|
||||
fs.lchownSync = function () {}
|
||||
}
|
||||
|
||||
// on Windows, A/V software can lock the directory, causing this
|
||||
// to fail with an EACCES or EPERM if the directory contains newly
|
||||
// created files. Try again on failure, for up to 60 seconds.
|
||||
|
||||
// Set the timeout this long because some Windows Anti-Virus, such as Parity
|
||||
// bit9, may lock files for up to a minute, causing npm package install
|
||||
// failures. Also, take care to yield the scheduler. Windows scheduling gives
|
||||
// CPU to a busy looping process, which can cause the program causing the lock
|
||||
// contention to be starved of CPU by node, so the contention doesn't resolve.
|
||||
if (platform === "win32") {
|
||||
fs.rename = (function (fs$rename) { return function (from, to, cb) {
|
||||
var start = Date.now()
|
||||
var backoff = 0;
|
||||
fs$rename(from, to, function CB (er) {
|
||||
if (er
|
||||
&& (er.code === "EACCES" || er.code === "EPERM")
|
||||
&& Date.now() - start < 60000) {
|
||||
setTimeout(function() {
|
||||
fs.stat(to, function (stater, st) {
|
||||
if (stater && stater.code === "ENOENT")
|
||||
fs$rename(from, to, CB);
|
||||
else
|
||||
cb(er)
|
||||
})
|
||||
}, backoff)
|
||||
if (backoff < 100)
|
||||
backoff += 10;
|
||||
return;
|
||||
}
|
||||
if (cb) cb(er)
|
||||
})
|
||||
}})(fs.rename)
|
||||
}
|
||||
|
||||
// if read() returns EAGAIN, then just try it again.
|
||||
fs.read = (function (fs$read) { return function (fd, buffer, offset, length, position, callback_) {
|
||||
var callback
|
||||
if (callback_ && typeof callback_ === 'function') {
|
||||
var eagCounter = 0
|
||||
callback = function (er, _, __) {
|
||||
if (er && er.code === 'EAGAIN' && eagCounter < 10) {
|
||||
eagCounter ++
|
||||
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
||||
}
|
||||
callback_.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
||||
}})(fs.read)
|
||||
|
||||
fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
|
||||
var eagCounter = 0
|
||||
while (true) {
|
||||
try {
|
||||
return fs$readSync.call(fs, fd, buffer, offset, length, position)
|
||||
} catch (er) {
|
||||
if (er.code === 'EAGAIN' && eagCounter < 10) {
|
||||
eagCounter ++
|
||||
continue
|
||||
}
|
||||
throw er
|
||||
}
|
||||
}
|
||||
}})(fs.readSync)
|
||||
|
||||
function patchLchmod (fs) {
|
||||
fs.lchmod = function (path, mode, callback) {
|
||||
fs.open( path
|
||||
, constants.O_WRONLY | constants.O_SYMLINK
|
||||
, mode
|
||||
, function (err, fd) {
|
||||
if (err) {
|
||||
if (callback) callback(err)
|
||||
return
|
||||
}
|
||||
// prefer to return the chmod error, if one occurs,
|
||||
// but still try to close, and report closing errors if they occur.
|
||||
fs.fchmod(fd, mode, function (err) {
|
||||
fs.close(fd, function(err2) {
|
||||
if (callback) callback(err || err2)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fs.lchmodSync = function (path, mode) {
|
||||
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)
|
||||
|
||||
// prefer to return the chmod error, if one occurs,
|
||||
// but still try to close, and report closing errors if they occur.
|
||||
var threw = true
|
||||
var ret
|
||||
try {
|
||||
ret = fs.fchmodSync(fd, mode)
|
||||
threw = false
|
||||
} finally {
|
||||
if (threw) {
|
||||
try {
|
||||
fs.closeSync(fd)
|
||||
} catch (er) {}
|
||||
} else {
|
||||
fs.closeSync(fd)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
function patchLutimes (fs) {
|
||||
if (constants.hasOwnProperty("O_SYMLINK")) {
|
||||
fs.lutimes = function (path, at, mt, cb) {
|
||||
fs.open(path, constants.O_SYMLINK, function (er, fd) {
|
||||
if (er) {
|
||||
if (cb) cb(er)
|
||||
return
|
||||
}
|
||||
fs.futimes(fd, at, mt, function (er) {
|
||||
fs.close(fd, function (er2) {
|
||||
if (cb) cb(er || er2)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fs.lutimesSync = function (path, at, mt) {
|
||||
var fd = fs.openSync(path, constants.O_SYMLINK)
|
||||
var ret
|
||||
var threw = true
|
||||
try {
|
||||
ret = fs.futimesSync(fd, at, mt)
|
||||
threw = false
|
||||
} finally {
|
||||
if (threw) {
|
||||
try {
|
||||
fs.closeSync(fd)
|
||||
} catch (er) {}
|
||||
} else {
|
||||
fs.closeSync(fd)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
} else {
|
||||
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
|
||||
fs.lutimesSync = function () {}
|
||||
}
|
||||
}
|
||||
|
||||
function chmodFix (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, mode, cb) {
|
||||
return orig.call(fs, target, mode, function (er) {
|
||||
if (chownErOk(er)) er = null
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function chmodFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, mode) {
|
||||
try {
|
||||
return orig.call(fs, target, mode)
|
||||
} catch (er) {
|
||||
if (!chownErOk(er)) throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function chownFix (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, uid, gid, cb) {
|
||||
return orig.call(fs, target, uid, gid, function (er) {
|
||||
if (chownErOk(er)) er = null
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function chownFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, uid, gid) {
|
||||
try {
|
||||
return orig.call(fs, target, uid, gid)
|
||||
} catch (er) {
|
||||
if (!chownErOk(er)) throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function statFix (orig) {
|
||||
if (!orig) return orig
|
||||
// Older versions of Node erroneously returned signed integers for
|
||||
// uid + gid.
|
||||
return function (target, cb) {
|
||||
return orig.call(fs, target, function (er, stats) {
|
||||
if (!stats) return cb.apply(this, arguments)
|
||||
if (stats.uid < 0) stats.uid += 0x100000000
|
||||
if (stats.gid < 0) stats.gid += 0x100000000
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function statFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
// Older versions of Node erroneously returned signed integers for
|
||||
// uid + gid.
|
||||
return function (target) {
|
||||
var stats = orig.call(fs, target)
|
||||
if (stats.uid < 0) stats.uid += 0x100000000
|
||||
if (stats.gid < 0) stats.gid += 0x100000000
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
||||
// ENOSYS means that the fs doesn't support the op. Just ignore
|
||||
// that, because it doesn't matter.
|
||||
//
|
||||
// if there's no getuid, or if getuid() is something other
|
||||
// than 0, and the error is EINVAL or EPERM, then just ignore
|
||||
// it.
|
||||
//
|
||||
// This specific case is a silent failure in cp, install, tar,
|
||||
// and most other unix tools that manage permissions.
|
||||
//
|
||||
// When running as root, or if other types of errors are
|
||||
// encountered, then it's strict.
|
||||
function chownErOk (er) {
|
||||
if (!er)
|
||||
return true
|
||||
|
||||
if (er.code === "ENOSYS")
|
||||
return true
|
||||
|
||||
var nonroot = !process.getuid || process.getuid() !== 0
|
||||
if (nonroot) {
|
||||
if (er.code === "EINVAL" || er.code === "EPERM")
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
12
node_modules/graceful-readlink/index.js
generated
vendored
Normal file
12
node_modules/graceful-readlink/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var fs = require('fs')
|
||||
, lstat = fs.lstatSync;
|
||||
|
||||
exports.readlinkSync = function (p) {
|
||||
if (lstat(p).isSymbolicLink()) {
|
||||
return fs.readlinkSync(p);
|
||||
} else {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
8
node_modules/has-flag/index.js
generated
vendored
Normal file
8
node_modules/has-flag/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
module.exports = (flag, argv) => {
|
||||
argv = argv || process.argv;
|
||||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||
const pos = argv.indexOf(prefix + flag);
|
||||
const terminatorPos = argv.indexOf('--');
|
||||
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
||||
};
|
||||
1
node_modules/has-symbol-support-x/.nvmrc
generated
vendored
Normal file
1
node_modules/has-symbol-support-x/.nvmrc
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lts/*
|
||||
17
node_modules/has-symbol-support-x/.uglifyjsrc.json
generated
vendored
Normal file
17
node_modules/has-symbol-support-x/.uglifyjsrc.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"warnings": false,
|
||||
"parse": {},
|
||||
"compress": {
|
||||
"keep_fnames": true
|
||||
},
|
||||
"mangle": false,
|
||||
"output": {
|
||||
"ascii_only": true,
|
||||
"beautify": false,
|
||||
"comments": "some"
|
||||
},
|
||||
"sourceMap": {},
|
||||
"nameCache": null,
|
||||
"toplevel": false,
|
||||
"ie8": true
|
||||
}
|
||||
20
node_modules/has-symbol-support-x/badges.html
generated
vendored
Normal file
20
node_modules/has-symbol-support-x/badges.html
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<a href="https://travis-ci.org/Xotic750/@{PACKAGE-NAME}"
|
||||
title="Travis status">
|
||||
<img
|
||||
src="https://travis-ci.org/Xotic750/@{PACKAGE-NAME}.svg?branch=master"
|
||||
alt="Travis status" height="18"/>
|
||||
</a>
|
||||
<a href="https://david-dm.org/Xotic750/@{PACKAGE-NAME}"
|
||||
title="Dependency status">
|
||||
<img src="https://david-dm.org/Xotic750/@{PACKAGE-NAME}.svg"
|
||||
alt="Dependency status" height="18"/>
|
||||
</a>
|
||||
<a href="https://david-dm.org/Xotic750/@{PACKAGE-NAME}#info=devDependencies"
|
||||
title="devDependency status">
|
||||
<img src="https://david-dm.org/Xotic750/@{PACKAGE-NAME}/dev-status.svg"
|
||||
alt="devDependency status" height="18"/>
|
||||
</a>
|
||||
<a href="https://badge.fury.io/js/@{PACKAGE-NAME}" title="npm version">
|
||||
<img src="https://badge.fury.io/js/@{PACKAGE-NAME}.svg"
|
||||
alt="npm version" height="18"/>
|
||||
</a>
|
||||
18
node_modules/has-symbol-support-x/index.js
generated
vendored
Normal file
18
node_modules/has-symbol-support-x/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Tests if ES6 Symbol is supported.
|
||||
* @version 1.4.2
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-symbol-support-x
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Indicates if `Symbol`exists and creates the correct type.
|
||||
* `true`, if it exists and creates the correct type, otherwise `false`.
|
||||
*
|
||||
* @type boolean
|
||||
*/
|
||||
module.exports = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
|
||||
22
node_modules/has-symbol-support-x/lib/has-symbol-support-x.js
generated
vendored
Normal file
22
node_modules/has-symbol-support-x/lib/has-symbol-support-x.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.returnExports = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(_dereq_,module,exports){
|
||||
/**
|
||||
* @file Tests if ES6 Symbol is supported.
|
||||
* @version 1.4.2
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-symbol-support-x
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Indicates if `Symbol`exists and creates the correct type.
|
||||
* `true`, if it exists and creates the correct type, otherwise `false`.
|
||||
*
|
||||
* @type boolean
|
||||
*/
|
||||
module.exports = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
10
node_modules/has-symbol-support-x/lib/has-symbol-support-x.min.js
generated
vendored
Normal file
10
node_modules/has-symbol-support-x/lib/has-symbol-support-x.min.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).returnExports=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module,exports){
|
||||
/**
|
||||
* @file Tests if ES6 Symbol is supported.
|
||||
* @version 1.4.2
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-symbol-support-x
|
||||
*/
|
||||
"use strict";module.exports="function"==typeof Symbol&&"symbol"==typeof Symbol("")},{}]},{},[1])(1)});
|
||||
1
node_modules/has-to-string-tag-x/.nvmrc
generated
vendored
Normal file
1
node_modules/has-to-string-tag-x/.nvmrc
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lts/*
|
||||
17
node_modules/has-to-string-tag-x/.uglifyjsrc.json
generated
vendored
Normal file
17
node_modules/has-to-string-tag-x/.uglifyjsrc.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"warnings": false,
|
||||
"parse": {},
|
||||
"compress": {
|
||||
"keep_fnames": true
|
||||
},
|
||||
"mangle": false,
|
||||
"output": {
|
||||
"ascii_only": true,
|
||||
"beautify": false,
|
||||
"comments": "some"
|
||||
},
|
||||
"sourceMap": {},
|
||||
"nameCache": null,
|
||||
"toplevel": false,
|
||||
"ie8": true
|
||||
}
|
||||
20
node_modules/has-to-string-tag-x/badges.html
generated
vendored
Normal file
20
node_modules/has-to-string-tag-x/badges.html
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<a href="https://travis-ci.org/Xotic750/@{PACKAGE-NAME}"
|
||||
title="Travis status">
|
||||
<img
|
||||
src="https://travis-ci.org/Xotic750/@{PACKAGE-NAME}.svg?branch=master"
|
||||
alt="Travis status" height="18"/>
|
||||
</a>
|
||||
<a href="https://david-dm.org/Xotic750/@{PACKAGE-NAME}"
|
||||
title="Dependency status">
|
||||
<img src="https://david-dm.org/Xotic750/@{PACKAGE-NAME}.svg"
|
||||
alt="Dependency status" height="18"/>
|
||||
</a>
|
||||
<a href="https://david-dm.org/Xotic750/@{PACKAGE-NAME}#info=devDependencies"
|
||||
title="devDependency status">
|
||||
<img src="https://david-dm.org/Xotic750/@{PACKAGE-NAME}/dev-status.svg"
|
||||
alt="devDependency status" height="18"/>
|
||||
</a>
|
||||
<a href="https://badge.fury.io/js/@{PACKAGE-NAME}" title="npm version">
|
||||
<img src="https://badge.fury.io/js/@{PACKAGE-NAME}.svg"
|
||||
alt="npm version" height="18"/>
|
||||
</a>
|
||||
19
node_modules/has-to-string-tag-x/index.js
generated
vendored
Normal file
19
node_modules/has-to-string-tag-x/index.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file Tests if ES6 @@toStringTag is supported.
|
||||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag|26.3.1 @@toStringTag}
|
||||
* @version 1.4.1
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-to-string-tag-x
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Indicates if `Symbol.toStringTag`exists and is the correct type.
|
||||
* `true`, if it exists and is the correct type, otherwise `false`.
|
||||
*
|
||||
* @type boolean
|
||||
*/
|
||||
module.exports = require('has-symbol-support-x') && typeof Symbol.toStringTag === 'symbol';
|
||||
43
node_modules/has-to-string-tag-x/lib/has-to-string-tag-x.js
generated
vendored
Normal file
43
node_modules/has-to-string-tag-x/lib/has-to-string-tag-x.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.returnExports = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
||||
/**
|
||||
* @file Tests if ES6 @@toStringTag is supported.
|
||||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag|26.3.1 @@toStringTag}
|
||||
* @version 1.4.1
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-to-string-tag-x
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Indicates if `Symbol.toStringTag`exists and is the correct type.
|
||||
* `true`, if it exists and is the correct type, otherwise `false`.
|
||||
*
|
||||
* @type boolean
|
||||
*/
|
||||
module.exports = _dereq_('has-symbol-support-x') && typeof Symbol.toStringTag === 'symbol';
|
||||
|
||||
},{"has-symbol-support-x":2}],2:[function(_dereq_,module,exports){
|
||||
/**
|
||||
* @file Tests if ES6 Symbol is supported.
|
||||
* @version 1.4.1
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-symbol-support-x
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Indicates if `Symbol`exists and creates the correct type.
|
||||
* `true`, if it exists and creates the correct type, otherwise `false`.
|
||||
*
|
||||
* @type boolean
|
||||
*/
|
||||
module.exports = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
18
node_modules/has-to-string-tag-x/lib/has-to-string-tag-x.min.js
generated
vendored
Normal file
18
node_modules/has-to-string-tag-x/lib/has-to-string-tag-x.min.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).returnExports=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module,exports){/**
|
||||
* @file Tests if ES6 @@toStringTag is supported.
|
||||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag|26.3.1 @@toStringTag}
|
||||
* @version 1.4.1
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-to-string-tag-x
|
||||
*/
|
||||
"use strict";module.exports=_dereq_("has-symbol-support-x")&&"symbol"==typeof Symbol.toStringTag},{"has-symbol-support-x":2}],2:[function(_dereq_,module,exports){/**
|
||||
* @file Tests if ES6 Symbol is supported.
|
||||
* @version 1.4.1
|
||||
* @author Xotic750 <Xotic750@gmail.com>
|
||||
* @copyright Xotic750
|
||||
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
||||
* @module has-symbol-support-x
|
||||
*/
|
||||
"use strict";module.exports="function"==typeof Symbol&&"symbol"==typeof Symbol("")},{}]},{},[1])(1)});
|
||||
84
node_modules/ieee754/index.js
generated
vendored
Normal file
84
node_modules/ieee754/index.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
||||
var e, m
|
||||
var eLen = (nBytes * 8) - mLen - 1
|
||||
var eMax = (1 << eLen) - 1
|
||||
var eBias = eMax >> 1
|
||||
var nBits = -7
|
||||
var i = isLE ? (nBytes - 1) : 0
|
||||
var d = isLE ? -1 : 1
|
||||
var s = buffer[offset + i]
|
||||
|
||||
i += d
|
||||
|
||||
e = s & ((1 << (-nBits)) - 1)
|
||||
s >>= (-nBits)
|
||||
nBits += eLen
|
||||
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
||||
|
||||
m = e & ((1 << (-nBits)) - 1)
|
||||
e >>= (-nBits)
|
||||
nBits += mLen
|
||||
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
||||
|
||||
if (e === 0) {
|
||||
e = 1 - eBias
|
||||
} else if (e === eMax) {
|
||||
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
||||
} else {
|
||||
m = m + Math.pow(2, mLen)
|
||||
e = e - eBias
|
||||
}
|
||||
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
||||
}
|
||||
|
||||
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
||||
var e, m, c
|
||||
var eLen = (nBytes * 8) - mLen - 1
|
||||
var eMax = (1 << eLen) - 1
|
||||
var eBias = eMax >> 1
|
||||
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
||||
var i = isLE ? 0 : (nBytes - 1)
|
||||
var d = isLE ? 1 : -1
|
||||
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
||||
|
||||
value = Math.abs(value)
|
||||
|
||||
if (isNaN(value) || value === Infinity) {
|
||||
m = isNaN(value) ? 1 : 0
|
||||
e = eMax
|
||||
} else {
|
||||
e = Math.floor(Math.log(value) / Math.LN2)
|
||||
if (value * (c = Math.pow(2, -e)) < 1) {
|
||||
e--
|
||||
c *= 2
|
||||
}
|
||||
if (e + eBias >= 1) {
|
||||
value += rt / c
|
||||
} else {
|
||||
value += rt * Math.pow(2, 1 - eBias)
|
||||
}
|
||||
if (value * c >= 2) {
|
||||
e++
|
||||
c /= 2
|
||||
}
|
||||
|
||||
if (e + eBias >= eMax) {
|
||||
m = 0
|
||||
e = eMax
|
||||
} else if (e + eBias >= 1) {
|
||||
m = ((value * c) - 1) * Math.pow(2, mLen)
|
||||
e = e + eBias
|
||||
} else {
|
||||
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
||||
e = 0
|
||||
}
|
||||
}
|
||||
|
||||
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
||||
|
||||
e = (e << mLen) | m
|
||||
eLen += mLen
|
||||
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
||||
|
||||
buffer[offset + i - d] |= s * 128
|
||||
}
|
||||
54
node_modules/inflight/inflight.js
generated
vendored
Normal file
54
node_modules/inflight/inflight.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
var wrappy = require('wrappy')
|
||||
var reqs = Object.create(null)
|
||||
var once = require('once')
|
||||
|
||||
module.exports = wrappy(inflight)
|
||||
|
||||
function inflight (key, cb) {
|
||||
if (reqs[key]) {
|
||||
reqs[key].push(cb)
|
||||
return null
|
||||
} else {
|
||||
reqs[key] = [cb]
|
||||
return makeres(key)
|
||||
}
|
||||
}
|
||||
|
||||
function makeres (key) {
|
||||
return once(function RES () {
|
||||
var cbs = reqs[key]
|
||||
var len = cbs.length
|
||||
var args = slice(arguments)
|
||||
|
||||
// XXX It's somewhat ambiguous whether a new callback added in this
|
||||
// pass should be queued for later execution if something in the
|
||||
// list of callbacks throws, or if it should just be discarded.
|
||||
// However, it's such an edge case that it hardly matters, and either
|
||||
// choice is likely as surprising as the other.
|
||||
// As it happens, we do go ahead and schedule it for later execution.
|
||||
try {
|
||||
for (var i = 0; i < len; i++) {
|
||||
cbs[i].apply(null, args)
|
||||
}
|
||||
} finally {
|
||||
if (cbs.length > len) {
|
||||
// added more in the interim.
|
||||
// de-zalgo, just in case, but don't call again.
|
||||
cbs.splice(0, len)
|
||||
process.nextTick(function () {
|
||||
RES.apply(null, args)
|
||||
})
|
||||
} else {
|
||||
delete reqs[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function slice (args) {
|
||||
var length = args.length
|
||||
var array = []
|
||||
|
||||
for (var i = 0; i < length; i++) array[i] = args[i]
|
||||
return array
|
||||
}
|
||||
7
node_modules/inherits/inherits.js
generated
vendored
Normal file
7
node_modules/inherits/inherits.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
try {
|
||||
var util = require('util');
|
||||
if (typeof util.inherits !== 'function') throw '';
|
||||
module.exports = util.inherits;
|
||||
} catch (e) {
|
||||
module.exports = require('./inherits_browser.js');
|
||||
}
|
||||
23
node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
23
node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
if (typeof Object.create === 'function') {
|
||||
// implementation from standard node.js 'util' module
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
} else {
|
||||
// old school shim for old browsers
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
var TempCtor = function () {}
|
||||
TempCtor.prototype = superCtor.prototype
|
||||
ctor.prototype = new TempCtor()
|
||||
ctor.prototype.constructor = ctor
|
||||
}
|
||||
}
|
||||
194
node_modules/ini/ini.js
generated
vendored
Normal file
194
node_modules/ini/ini.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
exports.parse = exports.decode = decode
|
||||
|
||||
exports.stringify = exports.encode = encode
|
||||
|
||||
exports.safe = safe
|
||||
exports.unsafe = unsafe
|
||||
|
||||
var eol = typeof process !== 'undefined' &&
|
||||
process.platform === 'win32' ? '\r\n' : '\n'
|
||||
|
||||
function encode (obj, opt) {
|
||||
var children = []
|
||||
var out = ''
|
||||
|
||||
if (typeof opt === 'string') {
|
||||
opt = {
|
||||
section: opt,
|
||||
whitespace: false
|
||||
}
|
||||
} else {
|
||||
opt = opt || {}
|
||||
opt.whitespace = opt.whitespace === true
|
||||
}
|
||||
|
||||
var separator = opt.whitespace ? ' = ' : '='
|
||||
|
||||
Object.keys(obj).forEach(function (k, _, __) {
|
||||
var val = obj[k]
|
||||
if (val && Array.isArray(val)) {
|
||||
val.forEach(function (item) {
|
||||
out += safe(k + '[]') + separator + safe(item) + '\n'
|
||||
})
|
||||
} else if (val && typeof val === 'object') {
|
||||
children.push(k)
|
||||
} else {
|
||||
out += safe(k) + separator + safe(val) + eol
|
||||
}
|
||||
})
|
||||
|
||||
if (opt.section && out.length) {
|
||||
out = '[' + safe(opt.section) + ']' + eol + out
|
||||
}
|
||||
|
||||
children.forEach(function (k, _, __) {
|
||||
var nk = dotSplit(k).join('\\.')
|
||||
var section = (opt.section ? opt.section + '.' : '') + nk
|
||||
var child = encode(obj[k], {
|
||||
section: section,
|
||||
whitespace: opt.whitespace
|
||||
})
|
||||
if (out.length && child.length) {
|
||||
out += eol
|
||||
}
|
||||
out += child
|
||||
})
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
function dotSplit (str) {
|
||||
return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002')
|
||||
.replace(/\\\./g, '\u0001')
|
||||
.split(/\./).map(function (part) {
|
||||
return part.replace(/\1/g, '\\.')
|
||||
.replace(/\2LITERAL\\1LITERAL\2/g, '\u0001')
|
||||
})
|
||||
}
|
||||
|
||||
function decode (str) {
|
||||
var out = {}
|
||||
var p = out
|
||||
var section = null
|
||||
// section |key = value
|
||||
var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
|
||||
var lines = str.split(/[\r\n]+/g)
|
||||
|
||||
lines.forEach(function (line, _, __) {
|
||||
if (!line || line.match(/^\s*[;#]/)) return
|
||||
var match = line.match(re)
|
||||
if (!match) return
|
||||
if (match[1] !== undefined) {
|
||||
section = unsafe(match[1])
|
||||
p = out[section] = out[section] || {}
|
||||
return
|
||||
}
|
||||
var key = unsafe(match[2])
|
||||
var value = match[3] ? unsafe(match[4]) : true
|
||||
switch (value) {
|
||||
case 'true':
|
||||
case 'false':
|
||||
case 'null': value = JSON.parse(value)
|
||||
}
|
||||
|
||||
// Convert keys with '[]' suffix to an array
|
||||
if (key.length > 2 && key.slice(-2) === '[]') {
|
||||
key = key.substring(0, key.length - 2)
|
||||
if (!p[key]) {
|
||||
p[key] = []
|
||||
} else if (!Array.isArray(p[key])) {
|
||||
p[key] = [p[key]]
|
||||
}
|
||||
}
|
||||
|
||||
// safeguard against resetting a previously defined
|
||||
// array by accidentally forgetting the brackets
|
||||
if (Array.isArray(p[key])) {
|
||||
p[key].push(value)
|
||||
} else {
|
||||
p[key] = value
|
||||
}
|
||||
})
|
||||
|
||||
// {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}}
|
||||
// use a filter to return the keys that have to be deleted.
|
||||
Object.keys(out).filter(function (k, _, __) {
|
||||
if (!out[k] ||
|
||||
typeof out[k] !== 'object' ||
|
||||
Array.isArray(out[k])) {
|
||||
return false
|
||||
}
|
||||
// see if the parent section is also an object.
|
||||
// if so, add it to that, and mark this one for deletion
|
||||
var parts = dotSplit(k)
|
||||
var p = out
|
||||
var l = parts.pop()
|
||||
var nl = l.replace(/\\\./g, '.')
|
||||
parts.forEach(function (part, _, __) {
|
||||
if (!p[part] || typeof p[part] !== 'object') p[part] = {}
|
||||
p = p[part]
|
||||
})
|
||||
if (p === out && nl === l) {
|
||||
return false
|
||||
}
|
||||
p[nl] = out[k]
|
||||
return true
|
||||
}).forEach(function (del, _, __) {
|
||||
delete out[del]
|
||||
})
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
function isQuoted (val) {
|
||||
return (val.charAt(0) === '"' && val.slice(-1) === '"') ||
|
||||
(val.charAt(0) === "'" && val.slice(-1) === "'")
|
||||
}
|
||||
|
||||
function safe (val) {
|
||||
return (typeof val !== 'string' ||
|
||||
val.match(/[=\r\n]/) ||
|
||||
val.match(/^\[/) ||
|
||||
(val.length > 1 &&
|
||||
isQuoted(val)) ||
|
||||
val !== val.trim())
|
||||
? JSON.stringify(val)
|
||||
: val.replace(/;/g, '\\;').replace(/#/g, '\\#')
|
||||
}
|
||||
|
||||
function unsafe (val, doUnesc) {
|
||||
val = (val || '').trim()
|
||||
if (isQuoted(val)) {
|
||||
// remove the single quotes before calling JSON.parse
|
||||
if (val.charAt(0) === "'") {
|
||||
val = val.substr(1, val.length - 2)
|
||||
}
|
||||
try { val = JSON.parse(val) } catch (_) {}
|
||||
} else {
|
||||
// walk the val to find the first not-escaped ; character
|
||||
var esc = false
|
||||
var unesc = ''
|
||||
for (var i = 0, l = val.length; i < l; i++) {
|
||||
var c = val.charAt(i)
|
||||
if (esc) {
|
||||
if ('\\;#'.indexOf(c) !== -1) {
|
||||
unesc += c
|
||||
} else {
|
||||
unesc += '\\' + c
|
||||
}
|
||||
esc = false
|
||||
} else if (';#'.indexOf(c) !== -1) {
|
||||
break
|
||||
} else if (c === '\\') {
|
||||
esc = true
|
||||
} else {
|
||||
unesc += c
|
||||
}
|
||||
}
|
||||
if (esc) {
|
||||
unesc += '\\'
|
||||
}
|
||||
return unesc.trim()
|
||||
}
|
||||
return val
|
||||
}
|
||||
31
node_modules/is-natural-number/index.js
generated
vendored
Normal file
31
node_modules/is-natural-number/index.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*!
|
||||
* is-natural-number.js | MIT (c) Shinnosuke Watanabe
|
||||
* https://github.com/shinnn/is-natural-number.js
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
module.exports = function isNaturalNumber(val, option) {
|
||||
if (option) {
|
||||
if (typeof option !== 'object') {
|
||||
throw new TypeError(
|
||||
String(option) +
|
||||
' is not an object. Expected an object that has boolean `includeZero` property.'
|
||||
);
|
||||
}
|
||||
|
||||
if ('includeZero' in option) {
|
||||
if (typeof option.includeZero !== 'boolean') {
|
||||
throw new TypeError(
|
||||
String(option.includeZero) +
|
||||
' is neither true nor false. `includeZero` option must be a Boolean value.'
|
||||
);
|
||||
}
|
||||
|
||||
if (option.includeZero && val === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Number.isSafeInteger(val) && val >= 1;
|
||||
};
|
||||
29
node_modules/is-natural-number/index.jsnext.js
generated
vendored
Normal file
29
node_modules/is-natural-number/index.jsnext.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*!
|
||||
* is-natural-number.js | MIT (c) Shinnosuke Watanabe
|
||||
* https://github.com/shinnn/is-natural-number.js
|
||||
*/
|
||||
export default function isNaturalNumber(val, option) {
|
||||
if (option) {
|
||||
if (typeof option !== 'object') {
|
||||
throw new TypeError(
|
||||
String(option) +
|
||||
' is not an object. Expected an object that has boolean `includeZero` property.'
|
||||
);
|
||||
}
|
||||
|
||||
if ('includeZero' in option) {
|
||||
if (typeof option.includeZero !== 'boolean') {
|
||||
throw new TypeError(
|
||||
String(option.includeZero) +
|
||||
' is neither true nor false. `includeZero` option must be a Boolean value.'
|
||||
);
|
||||
}
|
||||
|
||||
if (option.includeZero && val === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Number.isSafeInteger(val) && val >= 1;
|
||||
}
|
||||
55
node_modules/is-object/.jscs.json
generated
vendored
Normal file
55
node_modules/is-object/.jscs.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
|
||||
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],
|
||||
|
||||
"disallowSpaceAfterKeywords": [],
|
||||
|
||||
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
|
||||
"requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
|
||||
"disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true },
|
||||
"requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
|
||||
"disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
|
||||
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
|
||||
"disallowQuotedKeysInObjects": "allButReserved",
|
||||
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
|
||||
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
|
||||
"requireSpaceAfterPrefixUnaryOperators": [],
|
||||
|
||||
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
|
||||
"requireSpaceBeforePostfixUnaryOperators": [],
|
||||
|
||||
"disallowSpaceBeforeBinaryOperators": [],
|
||||
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
|
||||
|
||||
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
|
||||
"disallowSpaceAfterBinaryOperators": [],
|
||||
|
||||
"disallowImplicitTypeConversion": ["binary", "string"],
|
||||
|
||||
"disallowKeywords": ["with", "eval"],
|
||||
|
||||
"validateLineBreaks": "LF",
|
||||
|
||||
"requireKeywordsOnNewLine": [],
|
||||
"disallowKeywordsOnNewLine": ["else"],
|
||||
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
|
||||
"disallowTrailingWhitespace": true,
|
||||
|
||||
"excludeFiles": ["node_modules/**", "vendor/**"],
|
||||
|
||||
"disallowMultipleLineStrings": true,
|
||||
|
||||
"additionalRules": []
|
||||
}
|
||||
|
||||
14
node_modules/is-object/.testem.json
generated
vendored
Normal file
14
node_modules/is-object/.testem.json
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"launchers": {
|
||||
"node": {
|
||||
"command": "node ./test"
|
||||
}
|
||||
},
|
||||
"src_files": [
|
||||
"./**/*.js"
|
||||
],
|
||||
"before_tests": "npm run build",
|
||||
"on_exit": "rm test/static/bundle.js",
|
||||
"test_page": "test/static/index.html",
|
||||
"launch_in_dev": ["node", "phantomjs"]
|
||||
}
|
||||
5
node_modules/is-object/index.js
generated
vendored
Normal file
5
node_modules/is-object/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function isObject(x) {
|
||||
return typeof x === "object" && x !== null;
|
||||
};
|
||||
14
node_modules/is-redirect/index.js
generated
vendored
Normal file
14
node_modules/is-redirect/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
module.exports = function (x) {
|
||||
if (typeof x !== 'number') {
|
||||
throw new TypeError('Expected a number');
|
||||
}
|
||||
|
||||
return x === 300 ||
|
||||
x === 301 ||
|
||||
x === 302 ||
|
||||
x === 303 ||
|
||||
x === 305 ||
|
||||
x === 307 ||
|
||||
x === 308;
|
||||
};
|
||||
60
node_modules/is-retry-allowed/index.js
generated
vendored
Normal file
60
node_modules/is-retry-allowed/index.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var WHITELIST = [
|
||||
'ETIMEDOUT',
|
||||
'ECONNRESET',
|
||||
'EADDRINUSE',
|
||||
'ESOCKETTIMEDOUT',
|
||||
'ECONNREFUSED',
|
||||
'EPIPE'
|
||||
];
|
||||
|
||||
var BLACKLIST = [
|
||||
'ENOTFOUND',
|
||||
'ENETUNREACH',
|
||||
|
||||
// SSL errors from https://github.com/nodejs/node/blob/ed3d8b13ee9a705d89f9e0397d9e96519e7e47ac/src/node_crypto.cc#L1950
|
||||
'UNABLE_TO_GET_ISSUER_CERT',
|
||||
'UNABLE_TO_GET_CRL',
|
||||
'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
|
||||
'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
|
||||
'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
|
||||
'CERT_SIGNATURE_FAILURE',
|
||||
'CRL_SIGNATURE_FAILURE',
|
||||
'CERT_NOT_YET_VALID',
|
||||
'CERT_HAS_EXPIRED',
|
||||
'CRL_NOT_YET_VALID',
|
||||
'CRL_HAS_EXPIRED',
|
||||
'ERROR_IN_CERT_NOT_BEFORE_FIELD',
|
||||
'ERROR_IN_CERT_NOT_AFTER_FIELD',
|
||||
'ERROR_IN_CRL_LAST_UPDATE_FIELD',
|
||||
'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
|
||||
'OUT_OF_MEM',
|
||||
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
||||
'SELF_SIGNED_CERT_IN_CHAIN',
|
||||
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
||||
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
||||
'CERT_CHAIN_TOO_LONG',
|
||||
'CERT_REVOKED',
|
||||
'INVALID_CA',
|
||||
'PATH_LENGTH_EXCEEDED',
|
||||
'INVALID_PURPOSE',
|
||||
'CERT_UNTRUSTED',
|
||||
'CERT_REJECTED'
|
||||
];
|
||||
|
||||
module.exports = function (err) {
|
||||
if (!err || !err.code) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (WHITELIST.indexOf(err.code) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (BLACKLIST.indexOf(err.code) !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
21
node_modules/is-stream/index.js
generated
vendored
Normal file
21
node_modules/is-stream/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var isStream = module.exports = function (stream) {
|
||||
return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function';
|
||||
};
|
||||
|
||||
isStream.writable = function (stream) {
|
||||
return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object';
|
||||
};
|
||||
|
||||
isStream.readable = function (stream) {
|
||||
return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';
|
||||
};
|
||||
|
||||
isStream.duplex = function (stream) {
|
||||
return isStream.writable(stream) && isStream.readable(stream);
|
||||
};
|
||||
|
||||
isStream.transform = function (stream) {
|
||||
return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object';
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user