/home/lnzliplg/www/index.js.tar
lib/node_modules/npm/node_modules/is-cidr/index.js 0000644 00000000505 15173055474 0016250 0 ustar 00 "use strict";
const cidrRegex = require("cidr-regex");
const re4 = cidrRegex.v4({exact: true});
const re6 = cidrRegex.v6({exact: true});
const isCidr = module.exports = str => {
if (re4.test(str)) return 4;
if (re6.test(str)) return 6;
return 0;
};
isCidr.v4 = str => re4.test(str);
isCidr.v6 = str => re6.test(str);
lib/node_modules/npm/node_modules/deep-extend/index.js 0000644 00000000057 15173056403 0017113 0 ustar 00 module.exports = require('./lib/deep-extend');
lib/node_modules/npm/node_modules/p-finally/index.js 0000644 00000000456 15173056603 0016611 0 ustar 00 'use strict';
module.exports = (promise, onFinally) => {
onFinally = onFinally || (() => {});
return promise.then(
val => new Promise(resolve => {
resolve(onFinally());
}).then(() => val),
err => new Promise(resolve => {
resolve(onFinally());
}).then(() => {
throw err;
})
);
};
lib/node_modules/npm/node_modules/is-callable/index.js 0000644 00000002131 15173056720 0017056 0 ustar 00 'use strict';
var fnToStr = Function.prototype.toString;
var constructorRegex = /^\s*class\b/;
var isES6ClassFn = function isES6ClassFunction(value) {
try {
var fnStr = fnToStr.call(value);
return constructorRegex.test(fnStr);
} catch (e) {
return false; // not a function
}
};
var tryFunctionObject = function tryFunctionToStr(value) {
try {
if (isES6ClassFn(value)) { return false; }
fnToStr.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var fnClass = '[object Function]';
var genClass = '[object GeneratorFunction]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isCallable(value) {
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (typeof value === 'function' && !value.prototype) { return true; }
if (hasToStringTag) { return tryFunctionObject(value); }
if (isES6ClassFn(value)) { return false; }
var strClass = toStr.call(value);
return strClass === fnClass || strClass === genClass;
};
lib/node_modules/npm/node_modules/y18n/index.js 0000644 00000012231 15173067242 0015510 0 ustar 00 var fs = require('fs')
var path = require('path')
var util = require('util')
function Y18N (opts) {
// configurable options.
opts = opts || {}
this.directory = opts.directory || './locales'
this.updateFiles = typeof opts.updateFiles === 'boolean' ? opts.updateFiles : true
this.locale = opts.locale || 'en'
this.fallbackToLanguage = typeof opts.fallbackToLanguage === 'boolean' ? opts.fallbackToLanguage : true
// internal stuff.
this.cache = Object.create(null)
this.writeQueue = []
}
Y18N.prototype.__ = function () {
if (typeof arguments[0] !== 'string') {
return this._taggedLiteral.apply(this, arguments)
}
var args = Array.prototype.slice.call(arguments)
var str = args.shift()
var cb = function () {} // start with noop.
if (typeof args[args.length - 1] === 'function') cb = args.pop()
cb = cb || function () {} // noop.
if (!this.cache[this.locale]) this._readLocaleFile()
// we've observed a new string, update the language file.
if (!this.cache[this.locale][str] && this.updateFiles) {
this.cache[this.locale][str] = str
// include the current directory and locale,
// since these values could change before the
// write is performed.
this._enqueueWrite([this.directory, this.locale, cb])
} else {
cb()
}
return util.format.apply(util, [this.cache[this.locale][str] || str].concat(args))
}
Y18N.prototype._taggedLiteral = function (parts) {
var args = arguments
var str = ''
parts.forEach(function (part, i) {
var arg = args[i + 1]
str += part
if (typeof arg !== 'undefined') {
str += '%s'
}
})
return this.__.apply(null, [str].concat([].slice.call(arguments, 1)))
}
Y18N.prototype._enqueueWrite = function (work) {
this.writeQueue.push(work)
if (this.writeQueue.length === 1) this._processWriteQueue()
}
Y18N.prototype._processWriteQueue = function () {
var _this = this
var work = this.writeQueue[0]
// destructure the enqueued work.
var directory = work[0]
var locale = work[1]
var cb = work[2]
var languageFile = this._resolveLocaleFile(directory, locale)
var serializedLocale = JSON.stringify(this.cache[locale], null, 2)
fs.writeFile(languageFile, serializedLocale, 'utf-8', function (err) {
_this.writeQueue.shift()
if (_this.writeQueue.length > 0) _this._processWriteQueue()
cb(err)
})
}
Y18N.prototype._readLocaleFile = function () {
var localeLookup = {}
var languageFile = this._resolveLocaleFile(this.directory, this.locale)
try {
localeLookup = JSON.parse(fs.readFileSync(languageFile, 'utf-8'))
} catch (err) {
if (err instanceof SyntaxError) {
err.message = 'syntax error in ' + languageFile
}
if (err.code === 'ENOENT') localeLookup = {}
else throw err
}
this.cache[this.locale] = localeLookup
}
Y18N.prototype._resolveLocaleFile = function (directory, locale) {
var file = path.resolve(directory, './', locale + '.json')
if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf('_')) {
// attempt fallback to language only
var languageFile = path.resolve(directory, './', locale.split('_')[0] + '.json')
if (this._fileExistsSync(languageFile)) file = languageFile
}
return file
}
// this only exists because fs.existsSync() "will be deprecated"
// see https://nodejs.org/api/fs.html#fs_fs_existssync_path
Y18N.prototype._fileExistsSync = function (file) {
try {
return fs.statSync(file).isFile()
} catch (err) {
return false
}
}
Y18N.prototype.__n = function () {
var args = Array.prototype.slice.call(arguments)
var singular = args.shift()
var plural = args.shift()
var quantity = args.shift()
var cb = function () {} // start with noop.
if (typeof args[args.length - 1] === 'function') cb = args.pop()
if (!this.cache[this.locale]) this._readLocaleFile()
var str = quantity === 1 ? singular : plural
if (this.cache[this.locale][singular]) {
str = this.cache[this.locale][singular][quantity === 1 ? 'one' : 'other']
}
// we've observed a new string, update the language file.
if (!this.cache[this.locale][singular] && this.updateFiles) {
this.cache[this.locale][singular] = {
one: singular,
other: plural
}
// include the current directory and locale,
// since these values could change before the
// write is performed.
this._enqueueWrite([this.directory, this.locale, cb])
} else {
cb()
}
// if a %d placeholder is provided, add quantity
// to the arguments expanded by util.format.
var values = [str]
if (~str.indexOf('%d')) values.push(quantity)
return util.format.apply(util, values.concat(args))
}
Y18N.prototype.setLocale = function (locale) {
this.locale = locale
}
Y18N.prototype.getLocale = function () {
return this.locale
}
Y18N.prototype.updateLocale = function (obj) {
if (!this.cache[this.locale]) this._readLocaleFile()
for (var key in obj) {
this.cache[this.locale][key] = obj[key]
}
}
module.exports = function (opts) {
var y18n = new Y18N(opts)
// bind all functions to y18n, so that
// they can be used in isolation.
for (var key in y18n) {
if (typeof y18n[key] === 'function') {
y18n[key] = y18n[key].bind(y18n)
}
}
return y18n
}
lib/node_modules/npm/node_modules/ansi-align/index.js 0000644 00000002466 15173072742 0016745 0 ustar 00 'use strict'
const stringWidth = require('string-width')
function ansiAlign (text, opts) {
if (!text) return text
opts = opts || {}
const align = opts.align || 'center'
// short-circuit `align: 'left'` as no-op
if (align === 'left') return text
const split = opts.split || '\n'
const pad = opts.pad || ' '
const widthDiffFn = align !== 'right' ? halfDiff : fullDiff
let returnString = false
if (!Array.isArray(text)) {
returnString = true
text = String(text).split(split)
}
let width
let maxWidth = 0
text = text.map(function (str) {
str = String(str)
width = stringWidth(str)
maxWidth = Math.max(width, maxWidth)
return {
str,
width
}
}).map(function (obj) {
return new Array(widthDiffFn(maxWidth, obj.width) + 1).join(pad) + obj.str
})
return returnString ? text.join(split) : text
}
ansiAlign.left = function left (text) {
return ansiAlign(text, { align: 'left' })
}
ansiAlign.center = function center (text) {
return ansiAlign(text, { align: 'center' })
}
ansiAlign.right = function right (text) {
return ansiAlign(text, { align: 'right' })
}
module.exports = ansiAlign
function halfDiff (maxWidth, curWidth) {
return Math.floor((maxWidth - curWidth) / 2)
}
function fullDiff (maxWidth, curWidth) {
return maxWidth - curWidth
}
lib/node_modules/npm/node_modules/npm-packlist/index.js 0000644 00000020725 15173073155 0017322 0 ustar 00 'use strict'
// Do a two-pass walk, first to get the list of packages that need to be
// bundled, then again to get the actual files and folders.
// Keep a cache of node_modules content and package.json data, so that the
// second walk doesn't have to re-do all the same work.
const bundleWalk = require('npm-bundled')
const BundleWalker = bundleWalk.BundleWalker
const BundleWalkerSync = bundleWalk.BundleWalkerSync
const ignoreWalk = require('ignore-walk')
const IgnoreWalker = ignoreWalk.Walker
const IgnoreWalkerSync = ignoreWalk.WalkerSync
const rootBuiltinRules = Symbol('root-builtin-rules')
const packageNecessaryRules = Symbol('package-necessary-rules')
const path = require('path')
const normalizePackageBin = require('npm-normalize-package-bin')
const defaultRules = [
'.npmignore',
'.gitignore',
'**/.git',
'**/.svn',
'**/.hg',
'**/CVS',
'**/.git/**',
'**/.svn/**',
'**/.hg/**',
'**/CVS/**',
'/.lock-wscript',
'/.wafpickle-*',
'/build/config.gypi',
'npm-debug.log',
'**/.npmrc',
'.*.swp',
'.DS_Store',
'**/.DS_Store/**',
'._*',
'**/._*/**',
'*.orig',
'/package-lock.json',
'/yarn.lock',
'archived-packages/**',
'core',
'!core/',
'!**/core/',
'*.core',
'*.vgcore',
'vgcore.*',
'core.+([0-9])',
]
// There may be others, but :?|<> are handled by node-tar
const nameIsBadForWindows = file => /\*/.test(file)
// a decorator that applies our custom rules to an ignore walker
const npmWalker = Class => class Walker extends Class {
constructor (opt) {
opt = opt || {}
// the order in which rules are applied.
opt.ignoreFiles = [
rootBuiltinRules,
'package.json',
'.npmignore',
'.gitignore',
packageNecessaryRules
]
opt.includeEmpty = false
opt.path = opt.path || process.cwd()
const dirName = path.basename(opt.path)
const parentName = path.basename(path.dirname(opt.path))
opt.follow =
dirName === 'node_modules' ||
(parentName === 'node_modules' && /^@/.test(dirName))
super(opt)
// ignore a bunch of things by default at the root level.
// also ignore anything in node_modules, except bundled dependencies
if (!this.parent) {
this.bundled = opt.bundled || []
this.bundledScopes = Array.from(new Set(
this.bundled.filter(f => /^@/.test(f))
.map(f => f.split('/')[0])))
const rules = defaultRules.join('\n') + '\n'
this.packageJsonCache = opt.packageJsonCache || new Map()
super.onReadIgnoreFile(rootBuiltinRules, rules, _=>_)
} else {
this.bundled = []
this.bundledScopes = []
this.packageJsonCache = this.parent.packageJsonCache
}
}
onReaddir (entries) {
if (!this.parent) {
entries = entries.filter(e =>
e !== '.git' &&
!(e === 'node_modules' && this.bundled.length === 0)
)
}
return super.onReaddir(entries)
}
filterEntry (entry, partial) {
// get the partial path from the root of the walk
const p = this.path.substr(this.root.length + 1)
const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/
const isRoot = !this.parent
const pkg = isRoot && pkgre.test(entry) ?
entry.replace(pkgre, '$1') : null
const rootNM = isRoot && entry === 'node_modules'
const rootPJ = isRoot && entry === 'package.json'
return (
// if we're in a bundled package, check with the parent.
/^node_modules($|\/)/i.test(p) ? this.parent.filterEntry(
this.basename + '/' + entry, partial)
// if package is bundled, all files included
// also include @scope dirs for bundled scoped deps
// they'll be ignored if no files end up in them.
// However, this only matters if we're in the root.
// node_modules folders elsewhere, like lib/node_modules,
// should be included normally unless ignored.
: pkg ? -1 !== this.bundled.indexOf(pkg) ||
-1 !== this.bundledScopes.indexOf(pkg)
// only walk top node_modules if we want to bundle something
: rootNM ? !!this.bundled.length
// always include package.json at the root.
: rootPJ ? true
// otherwise, follow ignore-walk's logic
: super.filterEntry(entry, partial)
)
}
filterEntries () {
if (this.ignoreRules['package.json'])
this.ignoreRules['.gitignore'] = this.ignoreRules['.npmignore'] = null
else if (this.ignoreRules['.npmignore'])
this.ignoreRules['.gitignore'] = null
this.filterEntries = super.filterEntries
super.filterEntries()
}
addIgnoreFile (file, then) {
const ig = path.resolve(this.path, file)
if (this.packageJsonCache.has(ig))
this.onPackageJson(ig, this.packageJsonCache.get(ig), then)
else
super.addIgnoreFile(file, then)
}
onPackageJson (ig, pkg, then) {
this.packageJsonCache.set(ig, pkg)
// if there's a bin, browser or main, make sure we don't ignore it
// also, don't ignore the package.json itself!
//
// Weird side-effect of this: a readme (etc) file will be included
// if it exists anywhere within a folder with a package.json file.
// The original intent was only to include these files in the root,
// but now users in the wild are dependent on that behavior for
// localized documentation and other use cases. Adding a `/` to
// these rules, while tempting and arguably more "correct", is a
// breaking change.
const rules = [
pkg.browser ? '!' + pkg.browser : '',
pkg.main ? '!' + pkg.main : '',
'!package.json',
'!npm-shrinkwrap.json',
'!@(readme|copying|license|licence|notice|changes|changelog|history){,.*[^~$]}'
]
if (pkg.bin) {
// always an object, because normalized already
for (const key in pkg.bin)
rules.push('!' + pkg.bin[key])
}
const data = rules.filter(f => f).join('\n') + '\n'
super.onReadIgnoreFile(packageNecessaryRules, data, _=>_)
if (Array.isArray(pkg.files))
super.onReadIgnoreFile('package.json', '*\n' + pkg.files.map(
f => '!' + f + '\n!' + f.replace(/\/+$/, '') + '/**'
).join('\n') + '\n', then)
else
then()
}
// override parent stat function to completely skip any filenames
// that will break windows entirely.
// XXX(isaacs) Next major version should make this an error instead.
stat (entry, file, dir, then) {
if (nameIsBadForWindows(entry))
then()
else
super.stat(entry, file, dir, then)
}
// override parent onstat function to nix all symlinks
onstat (st, entry, file, dir, then) {
if (st.isSymbolicLink())
then()
else
super.onstat(st, entry, file, dir, then)
}
onReadIgnoreFile (file, data, then) {
if (file === 'package.json')
try {
const ig = path.resolve(this.path, file)
this.onPackageJson(ig, normalizePackageBin(JSON.parse(data)), then)
} catch (er) {
// ignore package.json files that are not json
then()
}
else
super.onReadIgnoreFile(file, data, then)
}
sort (a, b) {
return sort(a, b)
}
}
class Walker extends npmWalker(IgnoreWalker) {
walker (entry, then) {
new Walker(this.walkerOpt(entry)).on('done', then).start()
}
}
class WalkerSync extends npmWalker(IgnoreWalkerSync) {
walker (entry, then) {
new WalkerSync(this.walkerOpt(entry)).start()
then()
}
}
const walk = (options, callback) => {
options = options || {}
const p = new Promise((resolve, reject) => {
const bw = new BundleWalker(options)
bw.on('done', bundled => {
options.bundled = bundled
options.packageJsonCache = bw.packageJsonCache
new Walker(options).on('done', resolve).on('error', reject).start()
})
bw.start()
})
return callback ? p.then(res => callback(null, res), callback) : p
}
const walkSync = options => {
options = options || {}
const bw = new BundleWalkerSync(options).start()
options.bundled = bw.result
options.packageJsonCache = bw.packageJsonCache
const walker = new WalkerSync(options)
walker.start()
return walker.result
}
// optimize for compressibility
// extname, then basename, then locale alphabetically
// https://twitter.com/isntitvacant/status/1131094910923231232
const sort = (a, b) => {
const exta = path.extname(a).toLowerCase()
const extb = path.extname(b).toLowerCase()
const basea = path.basename(a).toLowerCase()
const baseb = path.basename(b).toLowerCase()
return exta.localeCompare(extb) ||
basea.localeCompare(baseb) ||
a.localeCompare(b)
}
module.exports = walk
walk.sync = walkSync
walk.Walker = Walker
walk.WalkerSync = WalkerSync
lib/node_modules/npm/node_modules/umask/index.js 0000644 00000003730 15173105755 0016037 0 ustar 00 'use strict';
var util = require("util");
function toString(val) {
val = val.toString(8);
while (val.length < 4) {
val = "0" + val;
}
return val;
}
var defaultUmask = 18; // 0022;
var defaultUmaskString = toString(defaultUmask);
function validate(data, k, val) {
// must be either an integer or an octal string.
if (typeof val === "number" && !isNaN(val)) {
data[k] = val;
return true;
}
if (typeof val === "string") {
if (val.charAt(0) !== "0") {
return false;
}
data[k] = parseInt(val, 8);
return true;
}
return false;
}
function convert_fromString(val, cb) {
if (typeof val === "string") {
// check for octal string first
if (val.charAt(0) === '0' && /^[0-7]+$/.test(val)) {
val = parseInt(val, 8);
} else if (val.charAt(0) !== '0' && /^[0-9]+$/.test(val)) {
// legacy support for decimal strings
val = parseInt(val, 10);
} else {
return cb(new Error(util.format("Expected octal string, got %j, defaulting to %j",
val, defaultUmaskString)),
defaultUmask);
}
} else if (typeof val !== "number") {
return cb(new Error(util.format("Expected number or octal string, got %j, defaulting to %j",
val, defaultUmaskString)),
defaultUmask);
}
val = Math.floor(val);
if ((val < 0) || (val > 511)) {
return cb(new Error(util.format("Must be in range 0..511 (0000..0777), got %j", val)),
defaultUmask);
}
cb(null, val);
}
function fromString(val, cb) {
// synchronous callback, no zalgo
convert_fromString(val, cb || function (err, result) {
/*jslint unparam:true*/
val = result;
});
return val;
}
exports.toString = toString;
exports.fromString = fromString;
exports.validate = validate;
lib/node_modules/npm/node_modules/detect-newline/index.js 0000644 00000000721 15173107004 0017610 0 ustar 00 'use strict';
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
var newlines = (str.match(/(?:\r?\n)/g) || []);
if (newlines.length === 0) {
return null;
}
var crlf = newlines.filter(function (el) {
return el === '\r\n';
}).length;
var lf = newlines.length - crlf;
return crlf > lf ? '\r\n' : '\n';
};
module.exports.graceful = function (str) {
return module.exports(str) || '\n';
};
lib/node_modules/npm/node_modules/ci-info/index.js 0000644 00000003313 15173117021 0016225 0 ustar 00 'use strict'
var vendors = require('./vendors.json')
var env = process.env
// Used for testing only
Object.defineProperty(exports, '_vendors', {
value: vendors.map(function (v) { return v.constant })
})
exports.name = null
exports.isPR = null
vendors.forEach(function (vendor) {
var envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env]
var isCI = envs.every(function (obj) {
return checkEnv(obj)
})
exports[vendor.constant] = isCI
if (isCI) {
exports.name = vendor.name
switch (typeof vendor.pr) {
case 'string':
// "pr": "CIRRUS_PR"
exports.isPR = !!env[vendor.pr]
break
case 'object':
if ('env' in vendor.pr) {
// "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" }
exports.isPR = vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne
} else if ('any' in vendor.pr) {
// "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
exports.isPR = vendor.pr.any.some(function (key) {
return !!env[key]
})
} else {
// "pr": { "DRONE_BUILD_EVENT": "pull_request" }
exports.isPR = checkEnv(vendor.pr)
}
break
default:
// PR detection not supported for this vendor
exports.isPR = null
}
}
})
exports.isCI = !!(
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
env.BUILD_NUMBER || // Jenkins, TeamCity
env.RUN_ID || // TaskCluster, dsari
exports.name ||
false
)
function checkEnv (obj) {
if (typeof obj === 'string') return !!env[obj]
return Object.keys(obj).every(function (k) {
return env[k] === obj[k]
})
}
lib/node_modules/npm/node_modules/ms/index.js 0000644 00000005732 15173145326 0015340 0 ustar 00 /**
* Helpers.
*/
var s = 1000;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var w = d * 7;
var y = d * 365.25;
/**
* Parse or format the given `val`.
*
* Options:
*
* - `long` verbose formatting [false]
*
* @param {String|Number} val
* @param {Object} [options]
* @throws {Error} throw an error if val is not a non-empty string or a number
* @return {String|Number}
* @api public
*/
module.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === 'string' && val.length > 0) {
return parse(val);
} else if (type === 'number' && isNaN(val) === false) {
return options.long ? fmtLong(val) : fmtShort(val);
}
throw new Error(
'val is not a non-empty string or a valid number. val=' +
JSON.stringify(val)
);
};
/**
* Parse the given `str` and return milliseconds.
*
* @param {String} str
* @return {Number}
* @api private
*/
function parse(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
return;
}
var n = parseFloat(match[1]);
var type = (match[2] || 'ms').toLowerCase();
switch (type) {
case 'years':
case 'year':
case 'yrs':
case 'yr':
case 'y':
return n * y;
case 'weeks':
case 'week':
case 'w':
return n * w;
case 'days':
case 'day':
case 'd':
return n * d;
case 'hours':
case 'hour':
case 'hrs':
case 'hr':
case 'h':
return n * h;
case 'minutes':
case 'minute':
case 'mins':
case 'min':
case 'm':
return n * m;
case 'seconds':
case 'second':
case 'secs':
case 'sec':
case 's':
return n * s;
case 'milliseconds':
case 'millisecond':
case 'msecs':
case 'msec':
case 'ms':
return n;
default:
return undefined;
}
}
/**
* Short format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function fmtShort(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return Math.round(ms / d) + 'd';
}
if (msAbs >= h) {
return Math.round(ms / h) + 'h';
}
if (msAbs >= m) {
return Math.round(ms / m) + 'm';
}
if (msAbs >= s) {
return Math.round(ms / s) + 's';
}
return ms + 'ms';
}
/**
* Long format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function fmtLong(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return plural(ms, msAbs, d, 'day');
}
if (msAbs >= h) {
return plural(ms, msAbs, h, 'hour');
}
if (msAbs >= m) {
return plural(ms, msAbs, m, 'minute');
}
if (msAbs >= s) {
return plural(ms, msAbs, s, 'second');
}
return ms + ' ms';
}
/**
* Pluralization helper.
*/
function plural(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
}
lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js 0000644 00000015376 15173145776 0020332 0 ustar 00 'use strict'
/**
* index.js
*
* a request API compatible with window.fetch
*/
const url = require('url')
const http = require('http')
const https = require('https')
const zlib = require('zlib')
const PassThrough = require('stream').PassThrough
const Body = require('./body.js')
const writeToStream = Body.writeToStream
const Response = require('./response')
const Headers = require('./headers')
const Request = require('./request')
const getNodeRequestOptions = Request.getNodeRequestOptions
const FetchError = require('./fetch-error')
const isURL = /^https?:/
/**
* Fetch function
*
* @param Mixed url Absolute url or Request instance
* @param Object opts Fetch options
* @return Promise
*/
exports = module.exports = fetch
function fetch (uri, opts) {
// allow custom promise
if (!fetch.Promise) {
throw new Error('native promise missing, set fetch.Promise to your favorite alternative')
}
Body.Promise = fetch.Promise
// wrap http.request into fetch
return new fetch.Promise((resolve, reject) => {
// build request object
const request = new Request(uri, opts)
const options = getNodeRequestOptions(request)
const send = (options.protocol === 'https:' ? https : http).request
// http.request only support string as host header, this hack make custom host header possible
if (options.headers.host) {
options.headers.host = options.headers.host[0]
}
// send request
const req = send(options)
let reqTimeout
if (request.timeout) {
req.once('socket', socket => {
reqTimeout = setTimeout(() => {
req.abort()
reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'))
}, request.timeout)
})
}
req.on('error', err => {
clearTimeout(reqTimeout)
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err))
})
req.on('response', res => {
clearTimeout(reqTimeout)
// handle redirect
if (fetch.isRedirect(res.statusCode) && request.redirect !== 'manual') {
if (request.redirect === 'error') {
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'))
return
}
if (request.counter >= request.follow) {
reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'))
return
}
if (!res.headers.location) {
reject(new FetchError(`redirect location header missing at: ${request.url}`, 'invalid-redirect'))
return
}
// Remove authorization if changing hostnames (but not if just
// changing ports or protocols). This matches the behavior of request:
// https://github.com/request/request/blob/b12a6245/lib/redirect.js#L134-L138
const resolvedUrl = url.resolve(request.url, res.headers.location)
let redirectURL = ''
if (!isURL.test(res.headers.location)) {
redirectURL = url.parse(resolvedUrl)
} else {
redirectURL = url.parse(res.headers.location)
}
if (url.parse(request.url).hostname !== redirectURL.hostname) {
request.headers.delete('authorization')
}
// per fetch spec, for POST request with 301/302 response, or any request with 303 response, use GET when following redirect
if (res.statusCode === 303 ||
((res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST')) {
request.method = 'GET'
request.body = null
request.headers.delete('content-length')
}
request.counter++
resolve(fetch(resolvedUrl, request))
return
}
// normalize location header for manual redirect mode
const headers = new Headers()
for (const name of Object.keys(res.headers)) {
if (Array.isArray(res.headers[name])) {
for (const val of res.headers[name]) {
headers.append(name, val)
}
} else {
headers.append(name, res.headers[name])
}
}
if (request.redirect === 'manual' && headers.has('location')) {
headers.set('location', url.resolve(request.url, headers.get('location')))
}
// prepare response
let body = res.pipe(new PassThrough())
const responseOptions = {
url: request.url,
status: res.statusCode,
statusText: res.statusMessage,
headers: headers,
size: request.size,
timeout: request.timeout
}
// HTTP-network fetch step 16.1.2
const codings = headers.get('Content-Encoding')
// HTTP-network fetch step 16.1.3: handle content codings
// in following scenarios we ignore compression support
// 1. compression support is disabled
// 2. HEAD request
// 3. no Content-Encoding header
// 4. no content response (204)
// 5. content not modified response (304)
if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {
resolve(new Response(body, responseOptions))
return
}
// Be less strict when decoding compressed responses, since sometimes
// servers send slightly invalid responses that are still accepted
// by common browsers.
// Always using Z_SYNC_FLUSH is what cURL does.
const zlibOptions = {
flush: zlib.Z_SYNC_FLUSH,
finishFlush: zlib.Z_SYNC_FLUSH
}
// for gzip
if (codings === 'gzip' || codings === 'x-gzip') {
body = body.pipe(zlib.createGunzip(zlibOptions))
resolve(new Response(body, responseOptions))
return
}
// for deflate
if (codings === 'deflate' || codings === 'x-deflate') {
// handle the infamous raw deflate response from old servers
// a hack for old IIS and Apache servers
const raw = res.pipe(new PassThrough())
raw.once('data', chunk => {
// see http://stackoverflow.com/questions/37519828
if ((chunk[0] & 0x0F) === 0x08) {
body = body.pipe(zlib.createInflate(zlibOptions))
} else {
body = body.pipe(zlib.createInflateRaw(zlibOptions))
}
resolve(new Response(body, responseOptions))
})
return
}
// otherwise, use response as-is
resolve(new Response(body, responseOptions))
})
writeToStream(req, request)
})
};
/**
* Redirect code matching
*
* @param Number code Status code
* @return Boolean
*/
fetch.isRedirect = code => code === 301 || code === 302 || code === 303 || code === 307 || code === 308
// expose Promise
fetch.Promise = global.Promise
exports.Headers = Headers
exports.Request = Request
exports.Response = Response
exports.FetchError = FetchError
lib/node_modules/npm/node_modules/os-homedir/index.js 0000644 00000001140 15173170012 0016742 0 ustar 00 'use strict';
var os = require('os');
function homedir() {
var env = process.env;
var home = env.HOME;
var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
if (process.platform === 'win32') {
return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null;
}
if (process.platform === 'darwin') {
return home || (user ? '/Users/' + user : null);
}
if (process.platform === 'linux') {
return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null));
}
return home || null;
}
module.exports = typeof os.homedir === 'function' ? os.homedir : homedir;
lib/node_modules/npm/node_modules/ecc-jsbn/index.js 0000644 00000003450 15173170675 0016405 0 ustar 00 var crypto = require("crypto");
var BigInteger = require("jsbn").BigInteger;
var ECPointFp = require("./lib/ec.js").ECPointFp;
var Buffer = require("safer-buffer").Buffer;
exports.ECCurves = require("./lib/sec.js");
// zero prepad
function unstupid(hex,len)
{
return (hex.length >= len) ? hex : unstupid("0"+hex,len);
}
exports.ECKey = function(curve, key, isPublic)
{
var priv;
var c = curve();
var n = c.getN();
var bytes = Math.floor(n.bitLength()/8);
if(key)
{
if(isPublic)
{
var curve = c.getCurve();
// var x = key.slice(1,bytes+1); // skip the 04 for uncompressed format
// var y = key.slice(bytes+1);
// this.P = new ECPointFp(curve,
// curve.fromBigInteger(new BigInteger(x.toString("hex"), 16)),
// curve.fromBigInteger(new BigInteger(y.toString("hex"), 16)));
this.P = curve.decodePointHex(key.toString("hex"));
}else{
if(key.length != bytes) return false;
priv = new BigInteger(key.toString("hex"), 16);
}
}else{
var n1 = n.subtract(BigInteger.ONE);
var r = new BigInteger(crypto.randomBytes(n.bitLength()));
priv = r.mod(n1).add(BigInteger.ONE);
this.P = c.getG().multiply(priv);
}
if(this.P)
{
// var pubhex = unstupid(this.P.getX().toBigInteger().toString(16),bytes*2)+unstupid(this.P.getY().toBigInteger().toString(16),bytes*2);
// this.PublicKey = Buffer.from("04"+pubhex,"hex");
this.PublicKey = Buffer.from(c.getCurve().encodeCompressedPointHex(this.P),"hex");
}
if(priv)
{
this.PrivateKey = Buffer.from(unstupid(priv.toString(16),bytes*2),"hex");
this.deriveSharedSecret = function(key)
{
if(!key || !key.P) return false;
var S = key.P.multiply(priv);
return Buffer.from(unstupid(S.getX().toBigInteger().toString(16),bytes*2),"hex");
}
}
}