diff options
Diffstat (limited to 'node_modules/download')
87 files changed, 7566 insertions, 0 deletions
diff --git a/node_modules/download/index.js b/node_modules/download/index.js new file mode 100644 index 0000000..e8dbda5 --- /dev/null +++ b/node_modules/download/index.js @@ -0,0 +1,99 @@ +'use strict'; +const fs = require('fs'); +const path = require('path'); +const {URL} = require('url'); +const contentDisposition = require('content-disposition'); +const archiveType = require('archive-type'); +const decompress = require('decompress'); +const filenamify = require('filenamify'); +const getStream = require('get-stream'); +const got = require('got'); +const makeDir = require('make-dir'); +const pify = require('pify'); +const pEvent = require('p-event'); +const fileType = require('file-type'); +const extName = require('ext-name'); + +const fsP = pify(fs); +const filenameFromPath = res => path.basename(new URL(res.requestUrl).pathname); + +const getExtFromMime = res => { + const header = res.headers['content-type']; + + if (!header) { + return null; + } + + const exts = extName.mime(header); + + if (exts.length !== 1) { + return null; + } + + return exts[0].ext; +}; + +const getFilename = (res, data) => { + const header = res.headers['content-disposition']; + + if (header) { + const parsed = contentDisposition.parse(header); + + if (parsed.parameters && parsed.parameters.filename) { + return parsed.parameters.filename; + } + } + + let filename = filenameFromPath(res); + + if (!path.extname(filename)) { + const ext = (fileType(data) || {}).ext || getExtFromMime(res); + + if (ext) { + filename = `${filename}.${ext}`; + } + } + + return filename; +}; + +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); + + const stream = got.stream(uri, opts); + + const promise = pEvent(stream, 'response').then(res => { + const encoding = opts.encoding === null ? 'buffer' : opts.encoding; + return Promise.all([getStream(stream, {encoding}), res]); + }).then(result => { + const [data, res] = result; + + if (!output) { + return opts.extract && archiveType(data) ? decompress(data, opts) : data; + } + + const filename = opts.filename || filenamify(getFilename(res, data)); + const outputFilepath = path.join(output, filename); + + if (opts.extract && archiveType(data)) { + return decompress(data, path.dirname(outputFilepath), opts); + } + + return makeDir(path.dirname(outputFilepath)) + .then(() => fsP.writeFile(outputFilepath, data)) + .then(() => data); + }); + + stream.then = promise.then.bind(promise); + stream.catch = promise.catch.bind(promise); + + return stream; +}; diff --git a/node_modules/download/license b/node_modules/download/license new file mode 100644 index 0000000..db6bc32 --- /dev/null +++ b/node_modules/download/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +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. diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/example.d.ts b/node_modules/download/node_modules/@sindresorhus/is/dist/example.d.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/example.d.ts diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/example.js b/node_modules/download/node_modules/@sindresorhus/is/dist/example.js new file mode 100644 index 0000000..4d575fc --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/example.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=example.js.map
\ No newline at end of file diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/example.js.map b/node_modules/download/node_modules/@sindresorhus/is/dist/example.js.map new file mode 100644 index 0000000..1677c0d --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/example.js.map @@ -0,0 +1 @@ +{"version":3,"file":"example.js","sourceRoot":"","sources":["../example.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/index.d.ts b/node_modules/download/node_modules/@sindresorhus/is/dist/index.d.ts new file mode 100644 index 0000000..fc54f3a --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/index.d.ts @@ -0,0 +1,95 @@ +/// <reference types="node" /> +export declare const enum TypeName { + null = "null", + boolean = "boolean", + undefined = "undefined", + string = "string", + number = "number", + symbol = "symbol", + Function = "Function", + Array = "Array", + Buffer = "Buffer", + Object = "Object", + RegExp = "RegExp", + Date = "Date", + Error = "Error", + Map = "Map", + Set = "Set", + WeakMap = "WeakMap", + WeakSet = "WeakSet", + Int8Array = "Int8Array", + Uint8Array = "Uint8Array", + Uint8ClampedArray = "Uint8ClampedArray", + Int16Array = "Int16Array", + Uint16Array = "Uint16Array", + Int32Array = "Int32Array", + Uint32Array = "Uint32Array", + Float32Array = "Float32Array", + Float64Array = "Float64Array", + ArrayBuffer = "ArrayBuffer", + SharedArrayBuffer = "SharedArrayBuffer", + DataView = "DataView", + Promise = "Promise", +} +declare function is(value: any): TypeName; +declare namespace is { + const undefined: (value: any) => boolean; + const string: (value: any) => boolean; + const number: (value: any) => boolean; + const function_: (value: any) => boolean; + const null_: (value: any) => boolean; + const class_: (value: any) => any; + const boolean: (value: any) => boolean; + const symbol: (value: any) => boolean; + const array: (arg: any) => arg is any[]; + const buffer: (obj: any) => obj is Buffer; + const nullOrUndefined: (value: any) => boolean; + const object: (value: any) => boolean; + const iterable: (value: any) => boolean; + const generator: (value: any) => boolean; + const nativePromise: (value: any) => boolean; + const promise: (value: any) => boolean; + const generatorFunction: (value: any) => boolean; + const asyncFunction: (value: any) => boolean; + const boundFunction: (value: any) => boolean; + const regExp: (value: any) => boolean; + const date: (value: any) => boolean; + const error: (value: any) => boolean; + const map: (value: any) => boolean; + const set: (value: any) => boolean; + const weakMap: (value: any) => boolean; + const weakSet: (value: any) => boolean; + const int8Array: (value: any) => boolean; + const uint8Array: (value: any) => boolean; + const uint8ClampedArray: (value: any) => boolean; + const int16Array: (value: any) => boolean; + const uint16Array: (value: any) => boolean; + const int32Array: (value: any) => boolean; + const uint32Array: (value: any) => boolean; + const float32Array: (value: any) => boolean; + const float64Array: (value: any) => boolean; + const arrayBuffer: (value: any) => boolean; + const sharedArrayBuffer: (value: any) => boolean; + const dataView: (value: any) => boolean; + const directInstanceOf: (instance: any, klass: any) => boolean; + const truthy: (value: any) => boolean; + const falsy: (value: any) => boolean; + const nan: (value: any) => boolean; + const primitive: (value: any) => boolean; + const integer: (value: any) => boolean; + const safeInteger: (value: any) => boolean; + const plainObject: (value: any) => boolean; + const typedArray: (value: any) => boolean; + const arrayLike: (value: any) => boolean; + const inRange: (value: number, range: number | number[]) => boolean; + const domElement: (value: any) => boolean; + const nodeStream: (value: any) => boolean; + const infinite: (value: any) => boolean; + const even: (rem: number) => boolean; + const odd: (rem: number) => boolean; + const empty: (value: any) => boolean; + const emptyOrWhitespace: (value: any) => boolean; + function any(...predicate: any[]): any; + function all(...predicate: any[]): any; +} +export default is; diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/index.js b/node_modules/download/node_modules/@sindresorhus/is/dist/index.js new file mode 100644 index 0000000..d613b67 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/index.js @@ -0,0 +1,215 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const util = require("util"); +const toString = Object.prototype.toString; +const isOfType = (type) => (value) => typeof value === type; // tslint:disable-line:strict-type-predicates +const getObjectType = (value) => { + const objectName = toString.call(value).slice(8, -1); + if (objectName) { + return objectName; + } + return null; +}; +const isObjectOfType = (typeName) => (value) => { + return getObjectType(value) === typeName; +}; +function is(value) { + if (value === null) { + return "null" /* null */; + } + if (value === true || value === false) { + return "boolean" /* boolean */; + } + const type = typeof value; + if (type === 'undefined') { + return "undefined" /* undefined */; + } + if (type === 'string') { + return "string" /* string */; + } + if (type === 'number') { + return "number" /* number */; + } + if (type === 'symbol') { + return "symbol" /* symbol */; + } + if (is.function_(value)) { + return "Function" /* Function */; + } + if (Array.isArray(value)) { + return "Array" /* Array */; + } + if (Buffer.isBuffer(value)) { + return "Buffer" /* Buffer */; + } + const tagType = getObjectType(value); + if (tagType) { + return tagType; + } + if (value instanceof String || value instanceof Boolean || value instanceof Number) { + throw new TypeError('Please don\'t use object wrappers for primitive types'); + } + return "Object" /* Object */; +} +(function (is) { + const isObject = (value) => typeof value === 'object'; + // tslint:disable:variable-name + is.undefined = isOfType('undefined'); + is.string = isOfType('string'); + is.number = isOfType('number'); + is.function_ = isOfType('function'); + is.null_ = (value) => value === null; + is.class_ = (value) => is.function_(value) && value.toString().startsWith('class '); + is.boolean = (value) => value === true || value === false; + // tslint:enable:variable-name + is.symbol = isOfType('symbol'); + is.array = Array.isArray; + is.buffer = Buffer.isBuffer; + is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value); + is.object = (value) => !is.nullOrUndefined(value) && (is.function_(value) || isObject(value)); + is.iterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.iterator]); + is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw); + is.nativePromise = isObjectOfType("Promise" /* Promise */); + const hasPromiseAPI = (value) => !is.null_(value) && + isObject(value) && + is.function_(value.then) && + is.function_(value.catch); + is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value); + // TODO: Change to use `isObjectOfType` once Node.js 6 or higher is targeted + const isFunctionOfType = (type) => (value) => is.function_(value) && is.function_(value.constructor) && value.constructor.name === type; + is.generatorFunction = isFunctionOfType('GeneratorFunction'); + is.asyncFunction = isFunctionOfType('AsyncFunction'); + is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype'); + is.regExp = isObjectOfType("RegExp" /* RegExp */); + is.date = isObjectOfType("Date" /* Date */); + is.error = isObjectOfType("Error" /* Error */); + is.map = isObjectOfType("Map" /* Map */); + is.set = isObjectOfType("Set" /* Set */); + is.weakMap = isObjectOfType("WeakMap" /* WeakMap */); + is.weakSet = isObjectOfType("WeakSet" /* WeakSet */); + is.int8Array = isObjectOfType("Int8Array" /* Int8Array */); + is.uint8Array = isObjectOfType("Uint8Array" /* Uint8Array */); + is.uint8ClampedArray = isObjectOfType("Uint8ClampedArray" /* Uint8ClampedArray */); + is.int16Array = isObjectOfType("Int16Array" /* Int16Array */); + is.uint16Array = isObjectOfType("Uint16Array" /* Uint16Array */); + is.int32Array = isObjectOfType("Int32Array" /* Int32Array */); + is.uint32Array = isObjectOfType("Uint32Array" /* Uint32Array */); + is.float32Array = isObjectOfType("Float32Array" /* Float32Array */); + is.float64Array = isObjectOfType("Float64Array" /* Float64Array */); + is.arrayBuffer = isObjectOfType("ArrayBuffer" /* ArrayBuffer */); + is.sharedArrayBuffer = isObjectOfType("SharedArrayBuffer" /* SharedArrayBuffer */); + is.dataView = isObjectOfType("DataView" /* DataView */); + // TODO: Remove `object` checks when targeting ES2015 or higher + // See `Notes`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf + is.directInstanceOf = (instance, klass) => is.object(instance) && is.object(klass) && Object.getPrototypeOf(instance) === klass.prototype; + is.truthy = (value) => Boolean(value); + is.falsy = (value) => !value; + is.nan = (value) => Number.isNaN(value); + const primitiveTypes = new Set([ + 'undefined', + 'string', + 'number', + 'boolean', + 'symbol' + ]); + is.primitive = (value) => is.null_(value) || primitiveTypes.has(typeof value); + is.integer = (value) => Number.isInteger(value); + is.safeInteger = (value) => Number.isSafeInteger(value); + is.plainObject = (value) => { + // From: https://github.com/sindresorhus/is-plain-obj/blob/master/index.js + let prototype; + return getObjectType(value) === "Object" /* Object */ && + (prototype = Object.getPrototypeOf(value), prototype === null || // tslint:disable-line:ban-comma-operator + prototype === Object.getPrototypeOf({})); + }; + const typedArrayTypes = new Set([ + "Int8Array" /* Int8Array */, + "Uint8Array" /* Uint8Array */, + "Uint8ClampedArray" /* Uint8ClampedArray */, + "Int16Array" /* Int16Array */, + "Uint16Array" /* Uint16Array */, + "Int32Array" /* Int32Array */, + "Uint32Array" /* Uint32Array */, + "Float32Array" /* Float32Array */, + "Float64Array" /* Float64Array */ + ]); + is.typedArray = (value) => { + const objectType = getObjectType(value); + if (objectType === null) { + return false; + } + return typedArrayTypes.has(objectType); + }; + const isValidLength = (value) => is.safeInteger(value) && value > -1; + is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length); + is.inRange = (value, range) => { + if (is.number(range)) { + return value >= Math.min(0, range) && value <= Math.max(range, 0); + } + if (is.array(range) && range.length === 2) { + // TODO: Use spread operator here when targeting Node.js 6 or higher + return value >= Math.min.apply(null, range) && value <= Math.max.apply(null, range); + } + throw new TypeError(`Invalid range: ${util.inspect(range)}`); + }; + const NODE_TYPE_ELEMENT = 1; + const DOM_PROPERTIES_TO_CHECK = [ + 'innerHTML', + 'ownerDocument', + 'style', + 'attributes', + 'nodeValue' + ]; + is.domElement = (value) => is.object(value) && value.nodeType === NODE_TYPE_ELEMENT && is.string(value.nodeName) && + !is.plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value); + is.nodeStream = (value) => !is.nullOrUndefined(value) && isObject(value) && is.function_(value.pipe); + is.infinite = (value) => value === Infinity || value === -Infinity; + const isAbsoluteMod2 = (value) => (rem) => is.integer(rem) && Math.abs(rem % 2) === value; + is.even = isAbsoluteMod2(0); + is.odd = isAbsoluteMod2(1); + const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false; + const isEmptyStringOrArray = (value) => (is.string(value) || is.array(value)) && value.length === 0; + const isEmptyObject = (value) => !is.map(value) && !is.set(value) && is.object(value) && Object.keys(value).length === 0; + const isEmptyMapOrSet = (value) => (is.map(value) || is.set(value)) && value.size === 0; + is.empty = (value) => is.falsy(value) || isEmptyStringOrArray(value) || isEmptyObject(value) || isEmptyMapOrSet(value); + is.emptyOrWhitespace = (value) => is.empty(value) || isWhiteSpaceString(value); + const predicateOnArray = (method, predicate, args) => { + // `args` is the calling function's "arguments object". + // We have to do it this way to keep node v4 support. + // So here we convert it to an array and slice off the first item. + const values = Array.prototype.slice.call(args, 1); + if (is.function_(predicate) === false) { + throw new TypeError(`Invalid predicate: ${util.inspect(predicate)}`); + } + if (values.length === 0) { + throw new TypeError('Invalid number of values'); + } + return method.call(values, predicate); + }; + function any(predicate) { + return predicateOnArray(Array.prototype.some, predicate, arguments); + } + is.any = any; + function all(predicate) { + return predicateOnArray(Array.prototype.every, predicate, arguments); + } + is.all = all; + // tslint:enable:only-arrow-functions no-function-expression +})(is || (is = {})); +// Some few keywords are reserved, but we'll populate them for Node.js users +// See https://github.com/Microsoft/TypeScript/issues/2536 +Object.defineProperties(is, { + class: { + value: is.class_ + }, + function: { + value: is.function_ + }, + null: { + value: is.null_ + } +}); +exports.default = is; +// For CommonJS default export support +module.exports = is; +module.exports.default = is; diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/index.js.map b/node_modules/download/node_modules/@sindresorhus/is/dist/index.js.map new file mode 100644 index 0000000..7461e68 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AAC3C,MAAM,aAAa,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAW,CAAC;AAClF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,C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KACf;CACD,CAAC,CAAC;AAEH,kBAAe,EAAE,CAAC;AAGlB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;AACpB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC"}
\ No newline at end of file diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.d.ts b/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.d.ts new file mode 100644 index 0000000..f5fe722 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.d.ts @@ -0,0 +1,59 @@ +/// <reference types="node" /> +declare function is(value: any): string; +declare namespace is { + const undefined: (value: any) => boolean; + const string: (value: any) => boolean; + const number: (value: any) => boolean; + const function_: (value: any) => boolean; + const null_: (value: any) => boolean; + const class_: (value: any) => any; + const boolean: (value: any) => boolean; + const symbol: (value: any) => boolean; + const array: (arg: any) => arg is any[]; + const buffer: (obj: any) => obj is Buffer; + const nullOrUndefined: (value: any) => boolean; + const object: (value: any) => boolean; + const iterable: (value: any) => boolean; + const generator: (value: any) => boolean; + const nativePromise: (value: any) => boolean; + const promise: (value: any) => boolean; + const generatorFunction: (value: any) => boolean; + const asyncFunction: (value: any) => boolean; + const regExp: (value: any) => boolean; + const date: (value: any) => boolean; + const error: (value: any) => boolean; + const map: (value: any) => boolean; + const set: (value: any) => boolean; + const weakMap: (value: any) => boolean; + const weakSet: (value: any) => boolean; + const int8Array: (value: any) => boolean; + const uint8Array: (value: any) => boolean; + const uint8ClampedArray: (value: any) => boolean; + const int16Array: (value: any) => boolean; + const uint16Array: (value: any) => boolean; + const int32Array: (value: any) => boolean; + const uint32Array: (value: any) => boolean; + const float32Array: (value: any) => boolean; + const float64Array: (value: any) => boolean; + const arrayBuffer: (value: any) => boolean; + const sharedArrayBuffer: (value: any) => boolean; + const truthy: (value: any) => boolean; + const falsy: (value: any) => boolean; + const nan: (value: any) => boolean; + const primitive: (value: any) => boolean; + const integer: (value: any) => boolean; + const safeInteger: (value: any) => boolean; + const plainObject: (value: any) => boolean; + const typedArray: (value: any) => boolean; + const arrayLike: (value: any) => boolean; + const inRange: (value: number, range: number | number[]) => boolean; + const domElement: (value: any) => boolean; + const infinite: (value: any) => boolean; + const even: (rem: number) => boolean; + const odd: (rem: number) => boolean; + const empty: (value: any) => boolean; + const emptyOrWhitespace: (value: any) => boolean; + function any(...predicate: any[]): any; + function all(...predicate: any[]): any; +} +export default is; diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.js b/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.js new file mode 100644 index 0000000..2ff01c9 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.js @@ -0,0 +1,182 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const util = require("util"); +const toString = Object.prototype.toString; +const getObjectType = (value) => toString.call(value).slice(8, -1); +const isOfType = (type) => (value) => typeof value === type; +const isObjectOfType = (type) => (value) => getObjectType(value) === type; +function is(value) { + if (value === null) { + return 'null'; + } + if (value === true || value === false) { + return 'boolean'; + } + const type = typeof value; + if (type === 'undefined') { + return 'undefined'; + } + if (type === 'string') { + return 'string'; + } + if (type === 'number') { + return 'number'; + } + if (type === 'symbol') { + return 'symbol'; + } + if (is.function_(value)) { + return 'Function'; + } + if (Array.isArray(value)) { + return 'Array'; + } + if (Buffer.isBuffer(value)) { + return 'Buffer'; + } + const tagType = getObjectType(value); + if (tagType) { + return tagType; + } + if (value instanceof String || value instanceof Boolean || value instanceof Number) { + throw new TypeError('Please don\'t use object wrappers for primitive types'); + } + return 'Object'; +} +(function (is) { + const isObject = (value) => typeof value === 'object'; + is.undefined = isOfType('undefined'); + is.string = isOfType('string'); + is.number = isOfType('number'); + is.function_ = isOfType('function'); + is.null_ = (value) => value === null; + is.class_ = (value) => is.function_(value) && value.toString().startsWith('class '); + is.boolean = (value) => value === true || value === false; + is.symbol = isOfType('symbol'); + is.array = Array.isArray; + is.buffer = Buffer.isBuffer; + is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value); + is.object = (value) => !is.nullOrUndefined(value) && (is.function_(value) || isObject(value)); + is.iterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.iterator]); + is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw); + is.nativePromise = isObjectOfType('Promise'); + const hasPromiseAPI = (value) => !is.null_(value) && + isObject(value) && + is.function_(value.then) && + is.function_(value.catch); + is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value); + const isFunctionOfType = (type) => (value) => is.function_(value) && is.function_(value.constructor) && value.constructor.name === type; + is.generatorFunction = isFunctionOfType('GeneratorFunction'); + is.asyncFunction = isFunctionOfType('AsyncFunction'); + is.regExp = isObjectOfType('RegExp'); + is.date = isObjectOfType('Date'); + is.error = isObjectOfType('Error'); + is.map = isObjectOfType('Map'); + is.set = isObjectOfType('Set'); + is.weakMap = isObjectOfType('WeakMap'); + is.weakSet = isObjectOfType('WeakSet'); + is.int8Array = isObjectOfType('Int8Array'); + is.uint8Array = isObjectOfType('Uint8Array'); + is.uint8ClampedArray = isObjectOfType('Uint8ClampedArray'); + is.int16Array = isObjectOfType('Int16Array'); + is.uint16Array = isObjectOfType('Uint16Array'); + is.int32Array = isObjectOfType('Int32Array'); + is.uint32Array = isObjectOfType('Uint32Array'); + is.float32Array = isObjectOfType('Float32Array'); + is.float64Array = isObjectOfType('Float64Array'); + is.arrayBuffer = isObjectOfType('ArrayBuffer'); + is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer'); + is.truthy = (value) => Boolean(value); + is.falsy = (value) => !value; + is.nan = (value) => Number.isNaN(value); + const primitiveTypes = new Set([ + 'undefined', + 'string', + 'number', + 'boolean', + 'symbol' + ]); + is.primitive = (value) => is.null_(value) || primitiveTypes.has(typeof value); + is.integer = (value) => Number.isInteger(value); + is.safeInteger = (value) => Number.isSafeInteger(value); + is.plainObject = (value) => { + let prototype; + return getObjectType(value) === 'Object' && + (prototype = Object.getPrototypeOf(value), prototype === null || + prototype === Object.getPrototypeOf({})); + }; + const typedArrayTypes = new Set([ + 'Int8Array', + 'Uint8Array', + 'Uint8ClampedArray', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array' + ]); + is.typedArray = (value) => typedArrayTypes.has(getObjectType(value)); + const isValidLength = (value) => is.safeInteger(value) && value > -1; + is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length); + is.inRange = (value, range) => { + if (is.number(range)) { + return value >= Math.min(0, range) && value <= Math.max(range, 0); + } + if (is.array(range) && range.length === 2) { + return value >= Math.min.apply(null, range) && value <= Math.max.apply(null, range); + } + throw new TypeError(`Invalid range: ${util.inspect(range)}`); + }; + const NODE_TYPE_ELEMENT = 1; + const DOM_PROPERTIES_TO_CHECK = [ + 'innerHTML', + 'ownerDocument', + 'style', + 'attributes', + 'nodeValue' + ]; + is.domElement = (value) => is.object(value) && value.nodeType === NODE_TYPE_ELEMENT && is.string(value.nodeName) && + !is.plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value); + is.infinite = (value) => value === Infinity || value === -Infinity; + const isAbsoluteMod2 = (value) => (rem) => is.integer(rem) && Math.abs(rem % 2) === value; + is.even = isAbsoluteMod2(0); + is.odd = isAbsoluteMod2(1); + const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false; + const isEmptyStringOrArray = (value) => (is.string(value) || is.array(value)) && value.length === 0; + const isEmptyObject = (value) => !is.map(value) && !is.set(value) && is.object(value) && Object.keys(value).length === 0; + const isEmptyMapOrSet = (value) => (is.map(value) || is.set(value)) && value.size === 0; + is.empty = (value) => is.falsy(value) || isEmptyStringOrArray(value) || isEmptyObject(value) || isEmptyMapOrSet(value); + is.emptyOrWhitespace = (value) => is.empty(value) || isWhiteSpaceString(value); + const predicateOnArray = (method, predicate, args) => { + const values = Array.prototype.slice.call(args, 1); + if (is.function_(predicate) === false) { + throw new TypeError(`Invalid predicate: ${util.inspect(predicate)}`); + } + if (values.length === 0) { + throw new TypeError('Invalid number of values'); + } + return method.call(values, predicate); + }; + function any(predicate) { + return predicateOnArray(Array.prototype.some, predicate, arguments); + } + is.any = any; + function all(predicate) { + return predicateOnArray(Array.prototype.every, predicate, arguments); + } + is.all = all; +})(is || (is = {})); +Object.defineProperties(is, { + class: { + value: is.class_ + }, + function: { + value: is.function_ + }, + null: { + value: is.null_ + } +}); +exports.default = is; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.js.map b/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.js.map new file mode 100644 index 0000000..5cb0e0c --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/source/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AAC3C,MAAM,aAAa,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAW,CAAC;AAClF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC;AACzE,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AAEvF,YAAY,KAAU;IACrB,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC;IACf,CAAC;IAED,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,SAAS,CAAC;IAClB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,CAAC;QACtE,CAAC;QAED,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC,CAAC;IAMF,aAAoB,SAAc;QACjC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACrE,CAAC;IAFe,MAAG,MAElB,CAAA;IAGD,aAAoB,SAAc;QACjC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACtE,CAAC;IAFe,MAAG,MAElB,CAAA;AAEF,CAAC,EA9KS,EAAE,KAAF,EAAE,QA8KX;AAID,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE;IAC3B,KAAK,EAAE;QACN,KAAK,EAAE,EAAE,CAAC,MAAM;KAChB;IACD,QAAQ,EAAE;QACT,KAAK,EAAE,EAAE,CAAC,SAAS;KACnB;IACD,IAAI,EAAE;QACL,KAAK,EAAE,EAAE,CAAC,KAAK;KACf;CACD,CAAC,CAAC;AAEH,kBAAe,EAAE,CAAC"}
\ No newline at end of file diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.d.ts b/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.d.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.d.ts diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.js b/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.js new file mode 100644 index 0000000..7a35b4d --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.js @@ -0,0 +1,622 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const util = require("util"); +const ava_1 = require("ava"); +const jsdom_1 = require("jsdom"); +const __1 = require(".."); +const isNode8orHigher = Number(process.versions.node.split('.')[0]) >= 8; +class ErrorSubclassFixture extends Error { +} +const document = jsdom_1.jsdom(); +const createDomElement = (el) => document.createElement(el); +const types = new Map([ + ['undefined', { + is: __1.default.undefined, + fixtures: [ + undefined + ] + }], + ['null', { + is: __1.default.null_, + fixtures: [ + null + ] + }], + ['string', { + is: __1.default.string, + fixtures: [ + '🦄', + 'hello world', + '' + ] + }], + ['number', { + is: __1.default.number, + fixtures: [ + 6, + 1.4, + 0, + -0, + Infinity, + -Infinity + ] + }], + ['boolean', { + is: __1.default.boolean, + fixtures: [ + true, false + ] + }], + ['symbol', { + is: __1.default.symbol, + fixtures: [ + Symbol('🦄') + ] + }], + ['array', { + is: __1.default.array, + fixtures: [ + [1, 2], + new Array(2) + ] + }], + ['function', { + is: __1.default.function_, + fixtures: [ + function foo() { }, + function () { }, + () => { }, + function () { + return __awaiter(this, void 0, void 0, function* () { }); + }, + function* () { } + ] + }], + ['buffer', { + is: __1.default.buffer, + fixtures: [ + Buffer.from('🦄') + ] + }], + ['object', { + is: __1.default.object, + fixtures: [ + { x: 1 }, + Object.create({ x: 1 }) + ] + }], + ['regExp', { + is: __1.default.regExp, + fixtures: [ + /\w/, + new RegExp('\\w') + ] + }], + ['date', { + is: __1.default.date, + fixtures: [ + new Date() + ] + }], + ['error', { + is: __1.default.error, + fixtures: [ + new Error('🦄'), + new ErrorSubclassFixture() + ] + }], + ['nativePromise', { + is: __1.default.nativePromise, + fixtures: [ + Promise.resolve(), + ] + }], + ['promise', { + is: __1.default.promise, + fixtures: [ + { then() { }, catch() { } } + ] + }], + ['generator', { + is: __1.default.generator, + fixtures: [ + (function* () { yield 4; })() + ] + }], + ['generatorFunction', { + is: __1.default.generatorFunction, + fixtures: [ + function* () { yield 4; } + ] + }], + ['asyncFunction', { + is: __1.default.asyncFunction, + fixtures: [ + function () { + return __awaiter(this, void 0, void 0, function* () { }); + }, + () => __awaiter(this, void 0, void 0, function* () { }) + ] + }], + ['map', { + is: __1.default.map, + fixtures: [ + new Map() + ] + }], + ['set', { + is: __1.default.set, + fixtures: [ + new Set() + ] + }], + ['weakSet', { + is: __1.default.weakSet, + fixtures: [ + new WeakSet() + ] + }], + ['weakMap', { + is: __1.default.weakMap, + fixtures: [ + new WeakMap() + ] + }], + ['int8Array', { + is: __1.default.int8Array, + fixtures: [ + new Int8Array(0) + ] + }], + ['uint8Array', { + is: __1.default.uint8Array, + fixtures: [ + new Uint8Array(0) + ] + }], + ['uint8ClampedArray', { + is: __1.default.uint8ClampedArray, + fixtures: [ + new Uint8ClampedArray(0) + ] + }], + ['int16Array', { + is: __1.default.int16Array, + fixtures: [ + new Int16Array(0) + ] + }], + ['uint16Array', { + is: __1.default.uint16Array, + fixtures: [ + new Uint16Array(0) + ] + }], + ['int32Array', { + is: __1.default.int32Array, + fixtures: [ + new Int32Array(0) + ] + }], + ['uint32Array', { + is: __1.default.uint32Array, + fixtures: [ + new Uint32Array(0) + ] + }], + ['float32Array', { + is: __1.default.float32Array, + fixtures: [ + new Float32Array(0) + ] + }], + ['float64Array', { + is: __1.default.float64Array, + fixtures: [ + new Float64Array(0) + ] + }], + ['arrayBuffer', { + is: __1.default.arrayBuffer, + fixtures: [ + new ArrayBuffer(10) + ] + }], + ['nan', { + is: __1.default.nan, + fixtures: [ + NaN, + Number.NaN + ] + }], + ['nullOrUndefined', { + is: __1.default.nullOrUndefined, + fixtures: [ + null, + undefined + ] + }], + ['plainObject', { + is: __1.default.plainObject, + fixtures: [ + { x: 1 }, + Object.create(null), + new Object() + ] + }], + ['integer', { + is: __1.default.integer, + fixtures: [ + 6 + ] + }], + ['safeInteger', { + is: __1.default.safeInteger, + fixtures: [ + Math.pow(2, 53) - 1, + -Math.pow(2, 53) + 1 + ] + }], + ['domElement', { + is: __1.default.domElement, + fixtures: [ + 'div', + 'input', + 'span', + 'img', + 'canvas', + 'script' + ].map(createDomElement) + } + ], ['non-domElements', { + is: value => !__1.default.domElement(value), + fixtures: [ + document.createTextNode('data'), + document.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"'), + document.createComment('This is a comment'), + document, + document.implementation.createDocumentType('svg:svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'), + document.createDocumentFragment() + ] + }], + ['infinite', { + is: __1.default.infinite, + fixtures: [ + Infinity, + -Infinity + ] + }] +]); +const testType = (t, type, exclude) => { + const testData = types.get(type); + if (testData === undefined) { + t.fail(`is.${type} not defined`); + return; + } + const { is } = testData; + for (const [key, { fixtures }] of types) { + if (exclude && exclude.indexOf(key) !== -1) { + continue; + } + const assert = key === type ? t.true.bind(t) : t.false.bind(t); + for (const fixture of fixtures) { + assert(is(fixture), `Value: ${util.inspect(fixture)}`); + } + } +}; +ava_1.default('is', t => { + t.is(__1.default(null), 'null'); + t.is(__1.default(undefined), 'undefined'); +}); +ava_1.default('is.undefined', t => { + testType(t, 'undefined', ['nullOrUndefined']); +}); +ava_1.default('is.null', t => { + testType(t, 'null', ['nullOrUndefined']); +}); +ava_1.default('is.string', t => { + testType(t, 'string'); +}); +ava_1.default('is.number', t => { + testType(t, 'number', ['nan', 'integer', 'safeInteger', 'infinite']); +}); +ava_1.default('is.boolean', t => { + testType(t, 'boolean'); +}); +ava_1.default('is.symbol', t => { + testType(t, 'symbol'); +}); +ava_1.default('is.array', t => { + testType(t, 'array'); +}); +ava_1.default('is.function', t => { + testType(t, 'function', ['generatorFunction', 'asyncFunction']); +}); +ava_1.default('is.buffer', t => { + testType(t, 'buffer'); +}); +ava_1.default('is.object', t => { + const testData = types.get('object'); + if (testData === undefined) { + t.fail('is.object not defined'); + return; + } + for (const el of testData.fixtures) { + t.true(__1.default.object(el)); + } +}); +ava_1.default('is.regExp', t => { + testType(t, 'regExp'); +}); +ava_1.default('is.date', t => { + testType(t, 'date'); +}); +ava_1.default('is.error', t => { + testType(t, 'error'); +}); +if (isNode8orHigher) { + ava_1.default('is.nativePromise', t => { + testType(t, 'nativePromise'); + }); + ava_1.default('is.promise', t => { + testType(t, 'promise', ['nativePromise']); + }); +} +ava_1.default('is.generator', t => { + testType(t, 'generator'); +}); +ava_1.default('is.generatorFunction', t => { + testType(t, 'generatorFunction', ['function']); +}); +ava_1.default('is.map', t => { + testType(t, 'map'); +}); +ava_1.default('is.set', t => { + testType(t, 'set'); +}); +ava_1.default('is.weakMap', t => { + testType(t, 'weakMap'); +}); +ava_1.default('is.weakSet', t => { + testType(t, 'weakSet'); +}); +ava_1.default('is.int8Array', t => { + testType(t, 'int8Array'); +}); +ava_1.default('is.uint8Array', t => { + testType(t, 'uint8Array', ['buffer']); +}); +ava_1.default('is.uint8ClampedArray', t => { + testType(t, 'uint8ClampedArray'); +}); +ava_1.default('is.int16Array', t => { + testType(t, 'int16Array'); +}); +ava_1.default('is.uint16Array', t => { + testType(t, 'uint16Array'); +}); +ava_1.default('is.int32Array', t => { + testType(t, 'int32Array'); +}); +ava_1.default('is.uint32Array', t => { + testType(t, 'uint32Array'); +}); +ava_1.default('is.float32Array', t => { + testType(t, 'float32Array'); +}); +ava_1.default('is.float64Array', t => { + testType(t, 'float64Array'); +}); +ava_1.default('is.arrayBuffer', t => { + testType(t, 'arrayBuffer'); +}); +ava_1.default('is.dataView', t => { + testType(t, 'arrayBuffer'); +}); +ava_1.default('is.truthy', t => { + t.true(__1.default.truthy('unicorn')); + t.true(__1.default.truthy('🦄')); + t.true(__1.default.truthy(new Set())); + t.true(__1.default.truthy(Symbol('🦄'))); + t.true(__1.default.truthy(true)); +}); +ava_1.default('is.falsy', t => { + t.true(__1.default.falsy(false)); + t.true(__1.default.falsy(0)); + t.true(__1.default.falsy('')); + t.true(__1.default.falsy(null)); + t.true(__1.default.falsy(undefined)); + t.true(__1.default.falsy(NaN)); +}); +ava_1.default('is.nan', t => { + testType(t, 'nan'); +}); +ava_1.default('is.nullOrUndefined', t => { + testType(t, 'nullOrUndefined', ['undefined', 'null']); +}); +ava_1.default('is.primitive', t => { + const primitives = [ + undefined, + null, + '🦄', + 6, + Infinity, + -Infinity, + true, + false, + Symbol('🦄') + ]; + for (const el of primitives) { + t.true(__1.default.primitive(el)); + } +}); +ava_1.default('is.integer', t => { + testType(t, 'integer', ['number', 'safeInteger']); + t.false(__1.default.integer(1.4)); +}); +ava_1.default('is.safeInteger', t => { + testType(t, 'safeInteger', ['number', 'integer']); + t.false(__1.default.safeInteger(Math.pow(2, 53))); + t.false(__1.default.safeInteger(-Math.pow(2, 53))); +}); +ava_1.default('is.plainObject', t => { + testType(t, 'plainObject', ['object', 'promise']); +}); +ava_1.default('is.iterable', t => { + t.true(__1.default.iterable('')); + t.true(__1.default.iterable([])); + t.true(__1.default.iterable(new Map())); + t.false(__1.default.iterable(null)); + t.false(__1.default.iterable(undefined)); + t.false(__1.default.iterable(0)); + t.false(__1.default.iterable(NaN)); + t.false(__1.default.iterable(Infinity)); + t.false(__1.default.iterable({})); +}); +ava_1.default('is.class', t => { + class Foo { + } + const classDeclarations = [ + Foo, + class Bar extends Foo { + } + ]; + for (const x of classDeclarations) { + t.true(__1.default.class_(x)); + } +}); +ava_1.default('is.typedArray', t => { + const typedArrays = [ + new Int8Array(0), + new Uint8Array(0), + new Uint8ClampedArray(0), + new Uint16Array(0), + new Int32Array(0), + new Uint32Array(0), + new Float32Array(0), + new Float64Array(0) + ]; + for (const el of typedArrays) { + t.true(__1.default.typedArray(el)); + } + t.false(__1.default.typedArray(new ArrayBuffer(1))); + t.false(__1.default.typedArray([])); + t.false(__1.default.typedArray({})); +}); +ava_1.default('is.arrayLike', t => { + (() => { + t.true(__1.default.arrayLike(arguments)); + })(); + t.true(__1.default.arrayLike([])); + t.true(__1.default.arrayLike('unicorn')); + t.false(__1.default.arrayLike({})); + t.false(__1.default.arrayLike(() => { })); + t.false(__1.default.arrayLike(new Map())); +}); +ava_1.default('is.inRange', t => { + const x = 3; + t.true(__1.default.inRange(x, [0, 5])); + t.true(__1.default.inRange(x, [5, 0])); + t.true(__1.default.inRange(x, [-5, 5])); + t.true(__1.default.inRange(x, [5, -5])); + t.false(__1.default.inRange(x, [4, 8])); + t.true(__1.default.inRange(-7, [-5, -10])); + t.true(__1.default.inRange(-5, [-5, -10])); + t.true(__1.default.inRange(-10, [-5, -10])); + t.true(__1.default.inRange(x, 10)); + t.true(__1.default.inRange(0, 0)); + t.true(__1.default.inRange(-2, -3)); + t.false(__1.default.inRange(x, 2)); + t.false(__1.default.inRange(-3, -2)); + t.throws(() => { + __1.default.inRange(0, []); + }); + t.throws(() => { + __1.default.inRange(0, [5]); + }); + t.throws(() => { + __1.default.inRange(0, [1, 2, 3]); + }); +}); +ava_1.default('is.domElement', t => { + testType(t, 'domElement'); + t.false(__1.default.domElement({ nodeType: 1, nodeName: 'div' })); +}); +ava_1.default('is.infinite', t => { + testType(t, 'infinite', ['number']); +}); +ava_1.default('is.even', t => { + for (const el of [-6, 2, 4]) { + t.true(__1.default.even(el)); + } + for (const el of [-3, 1, 5]) { + t.false(__1.default.even(el)); + } +}); +ava_1.default('is.odd', t => { + for (const el of [-5, 7, 13]) { + t.true(__1.default.odd(el)); + } + for (const el of [-8, 8, 10]) { + t.false(__1.default.odd(el)); + } +}); +ava_1.default('is.empty', t => { + t.true(__1.default.empty(null)); + t.true(__1.default.empty(undefined)); + t.true(__1.default.empty(false)); + t.false(__1.default.empty(true)); + t.true(__1.default.empty('')); + t.false(__1.default.empty('🦄')); + t.true(__1.default.empty([])); + t.false(__1.default.empty(['🦄'])); + t.true(__1.default.empty({})); + t.false(__1.default.empty({ unicorn: '🦄' })); + const tempMap = new Map(); + t.true(__1.default.empty(tempMap)); + tempMap.set('unicorn', '🦄'); + t.false(__1.default.empty(tempMap)); + const tempSet = new Set(); + t.true(__1.default.empty(tempSet)); + tempSet.add(1); + t.false(__1.default.empty(tempSet)); +}); +ava_1.default('is.emptyOrWhitespace', t => { + t.true(__1.default.emptyOrWhitespace('')); + t.true(__1.default.emptyOrWhitespace(' ')); + t.false(__1.default.emptyOrWhitespace('🦄')); + t.false(__1.default.emptyOrWhitespace('unicorn')); +}); +ava_1.default('is.any', t => { + t.true(__1.default.any(__1.default.string, {}, true, '🦄')); + t.true(__1.default.any(__1.default.object, false, {}, 'unicorns')); + t.false(__1.default.any(__1.default.boolean, '🦄', [], 3)); + t.false(__1.default.any(__1.default.integer, true, 'lol', {})); + t.throws(() => { + __1.default.any(null, true); + }); + t.throws(() => { + __1.default.any(__1.default.string); + }); +}); +ava_1.default('is.all', t => { + t.true(__1.default.all(__1.default.object, {}, new Set(), new Map())); + t.true(__1.default.all(__1.default.boolean, true, false)); + t.false(__1.default.all(__1.default.string, '🦄', [])); + t.false(__1.default.all(__1.default.set, new Map(), {})); + t.throws(() => { + __1.default.all(null, true); + }); + t.throws(() => { + __1.default.all(__1.default.string); + }); +}); +//# sourceMappingURL=test.js.map
\ No newline at end of file diff --git a/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.js.map b/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.js.map new file mode 100644 index 0000000..ab9ec15 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/dist/source/tests/test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../source/tests/test.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,6BAA6B;AAC7B,6BAA+C;AAC/C,iCAA4B;AAC5B,0BAAmB;AAEnB,MAAM,eAAe,GAAG,MAAM,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C,IAAI,CAAC,WAAC,CAAC,GAAG,CAAC,WAAC,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,KAAK,CAAC,WAAC,CAAC,GAAG,CAAC,WAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,KAAK,CAAC,WAAC,CAAC,GAAG,CAAC,WAAC,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAErC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE;QACb,WAAC,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE;QACb,WAAC,CAAC,GAAG,CAAC,WAAC,CAAC,MAAM,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/download/node_modules/@sindresorhus/is/license b/node_modules/download/node_modules/@sindresorhus/is/license new file mode 100644 index 0000000..e7af2f7 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/download/node_modules/@sindresorhus/is/package.json b/node_modules/download/node_modules/@sindresorhus/is/package.json new file mode 100644 index 0000000..c4a3a24 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/package.json @@ -0,0 +1,62 @@ +{ + "name": "@sindresorhus/is", + "version": "0.7.0", + "description": "Type check values: `is.string('🦄') //=> true`", + "license": "MIT", + "repository": "sindresorhus/is", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "publishConfig": { + "access": "public" + }, + "main": "dist/index.js", + "engines": { + "node": ">=4" + }, + "scripts": { + "lint": "tslint --format stylish --project .", + "build": "tsc", + "test": "npm run lint && npm run build && ava dist/tests", + "prepublish": "npm run build && del dist/tests" + }, + "files": [ + "dist" + ], + "keywords": [ + "type", + "types", + "is", + "check", + "checking", + "validate", + "validation", + "utility", + "util", + "typeof", + "instanceof", + "object", + "assert", + "assertion", + "test", + "kind", + "primitive", + "verify", + "compare" + ], + "devDependencies": { + "@types/jsdom": "^2.0.31", + "@types/node": "^8.0.47", + "@types/tempy": "^0.1.0", + "ava": "*", + "del-cli": "^1.1.0", + "jsdom": "^9.12.0", + "tempy": "^0.2.1", + "tslint": "^5.8.0", + "tslint-xo": "^0.3.0", + "typescript": "^2.6.1" + }, + "types": "dist/index.d.ts" +} diff --git a/node_modules/download/node_modules/@sindresorhus/is/readme.md b/node_modules/download/node_modules/@sindresorhus/is/readme.md new file mode 100644 index 0000000..67fad06 --- /dev/null +++ b/node_modules/download/node_modules/@sindresorhus/is/readme.md @@ -0,0 +1,323 @@ +# is [![Build Status](https://travis-ci.org/sindresorhus/is.svg?branch=master)](https://travis-ci.org/sindresorhus/is) + +> Type check values: `is.string('🦄') //=> true` + +<img src="header.gif" width="182" align="right"> + + +## Install + +``` +$ npm install @sindresorhus/is +``` + + +## Usage + +```js +const is = require('@sindresorhus/is'); + +is('🦄'); +//=> 'string' + +is(new Map()); +//=> 'Map' + +is.number(6); +//=> true +``` + + +## API + +### is(value) + +Returns the type of `value`. + +Primitives are lowercase and object types are camelcase. + +Example: + +- `'undefined'` +- `'null'` +- `'string'` +- `'symbol'` +- `'Array'` +- `'Function'` +- `'Object'` + +Note: It will throw if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`. + +### is.{method} + +All the below methods accept a value and returns a boolean for whether the value is of the desired type. + +#### Primitives + +##### .undefined(value) +##### .null(value) +##### .string(value) +##### .number(value) +##### .boolean(value) +##### .symbol(value) + +#### Built-in types + +##### .array(value) +##### .function(value) +##### .buffer(value) +##### .object(value) + +Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions). + +##### .regExp(value) +##### .date(value) +##### .error(value) +##### .nativePromise(value) +##### .promise(value) + +Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too. + +##### .generator(value) + +Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`. + +##### .generatorFunction(value) + +##### .asyncFunction(value) + +Returns `true` for any `async` function that can be called with the `await` operator. + +```js +is.asyncFunction(async () => {}); +// => true + +is.asyncFunction(() => {}); +// => false +``` + +##### .boundFunction(value) + +Returns `true` for any `bound` function. + +```js +is.boundFunction(() => {}); +// => true + +is.boundFunction(function () {}.bind(null)); +// => true + +is.boundFunction(function () {}); +// => false +``` + +##### .map(value) +##### .set(value) +##### .weakMap(value) +##### .weakSet(value) + +#### Typed arrays + +##### .int8Array(value) +##### .uint8Array(value) +##### .uint8ClampedArray(value) +##### .int16Array(value) +##### .uint16Array(value) +##### .int32Array(value) +##### .uint32Array(value) +##### .float32Array(value) +##### .float64Array(value) + +#### Structured data + +##### .arrayBuffer(value) +##### .sharedArrayBuffer(value) +##### .dataView(value) + +#### Miscellaneous + +##### .directInstanceOf(value, class) + +Returns `true` if `value` is a direct instance of `class`. + +```js +is.directInstanceOf(new Error(), Error); +//=> true + +class UnicornError extends Error {}; + +is.directInstanceOf(new UnicornError(), Error); +//=> false +``` + +##### .truthy(value) + +Returns `true` for all values that evaluate to true in a boolean context: + +```js +is.truthy('🦄'); +//=> true + +is.truthy(undefined); +//=> false +``` + +##### .falsy(value) + +Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`. + +##### .nan(value) +##### .nullOrUndefined(value) +##### .primitive(value) + +JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`. + +##### .integer(value) + +##### .safeInteger(value) + +Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger). + +##### .plainObject(value) + +An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`. + +##### .iterable(value) +##### .class(value) + +Returns `true` for instances created by a ES2015 class. + +##### .typedArray(value) + +##### .arrayLike(value) + +A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0. + +```js +is.arrayLike(document.forms); +//=> true + +function () { + is.arrayLike(arguments); + //=> true +} +``` + +##### .inRange(value, range) + +Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order. + +```js +is.inRange(3, [0, 5]); +is.inRange(3, [5, 0]); +is.inRange(0, [-2, 2]); +``` + +##### .inRange(value, upperBound) + +Check if `value` (number) is in the range of `0` to `upperBound`. + +```js +is.inRange(3, 10); +``` + +##### .domElement(value) + +Returns `true` if `value` is a DOM Element. + +##### .nodeStream(value) + +Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html). + +```js +const fs = require('fs'); +is.nodeStream(fs.createReadStream('unicorn.png')); +//=> true +``` + +##### .infinite(value) + +Check if `value` is `Infinity` or `-Infinity`. + +##### .even(value) + +Returns `true` if `value` is an even integer. + +##### .odd(value) + +Returns `true` if `value` is an odd integer. + +##### .empty(value) + +Returns `true` if `value` is falsy or an empty string, array, object, map, or set. + +##### .emptyOrWhitespace(value) + +Returns `true` if `is.empty(value)` or a string that is all whitespace. + + +##### .any(predicate, ...values) + +Returns `true` if **any** of the input `values` returns true in the `predicate`: + +```js +is.any(is.string, {}, true, '🦄'); +//=> true + +is.any(is.boolean, 'unicorns', [], new Map()); +//=> false +``` + +##### .all(predicate, ...values) + +Returns `true` if **all** of the input `values` returns true in the `predicate`: + +```js +is.all(is.object, {}, new Map(), new Set()); +//=> true + +is.all(is.string, '🦄', [], 'unicorns'); +//=> false +``` + +## FAQ + +### Why yet another type checking module? + +There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs: + +- Includes both type methods and ability to get the type +- Types of primitives returned as lowercase and object types as camelcase +- Covers all built-ins +- Unsurprising behavior +- Well-maintained +- Comprehensive test suite + +For the ones I found, pick 3 of these. + +The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive. + + +## Related + +- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream +- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable +- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array +- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address +- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted +- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor +- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty +- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data +- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji + + +## Created by + +- [Sindre Sorhus](https://github.com/sindresorhus) +- [Giora Guttsait](https://github.com/gioragutt) +- [Brandon Smith](https://github.com/brandon93s) + + +## License + +MIT diff --git a/node_modules/download/node_modules/cacheable-request/LICENSE b/node_modules/download/node_modules/cacheable-request/LICENSE new file mode 100644 index 0000000..f27ee9b --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Luke Childs + +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. diff --git a/node_modules/download/node_modules/cacheable-request/README.md b/node_modules/download/node_modules/cacheable-request/README.md new file mode 100644 index 0000000..84a5568 --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/README.md @@ -0,0 +1,190 @@ +# cacheable-request + +> Wrap native HTTP requests with RFC compliant cache support + +[![Build Status](https://travis-ci.org/lukechilds/cacheable-request.svg?branch=master)](https://travis-ci.org/lukechilds/cacheable-request) +[![Coverage Status](https://coveralls.io/repos/github/lukechilds/cacheable-request/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/cacheable-request?branch=master) +[![npm](https://img.shields.io/npm/dm/cacheable-request.svg)](https://www.npmjs.com/package/cacheable-request) +[![npm](https://img.shields.io/npm/v/cacheable-request.svg)](https://www.npmjs.com/package/cacheable-request) + +[RFC 7234](http://httpwg.org/specs/rfc7234.html) compliant HTTP caching for native Node.js HTTP/HTTPS requests. Caching works out of the box in memory or is easily pluggable with a wide range of storage adapters. + +**Note:** This is a low level wrapper around the core HTTP modules, it's not a high level request library. + +## Features + +- Only stores cacheable responses as defined by RFC 7234 +- Fresh cache entries are served directly from cache +- Stale cache entries are revalidated with `If-None-Match`/`If-Modified-Since` headers +- 304 responses from revalidation requests use cached body +- Updates `Age` header on cached responses +- Can completely bypass cache on a per request basis +- In memory cache by default +- Official support for Redis, MongoDB, SQLite, PostgreSQL and MySQL storage adapters +- Easily plug in your own or third-party storage adapters +- If DB connection fails, cache is automatically bypassed ([disabled by default](#optsautomaticfailover)) +- Adds cache support to any existing HTTP code with minimal changes +- Uses [http-cache-semantics](https://github.com/pornel/http-cache-semantics) internally for HTTP RFC 7234 compliance + +## Install + +```shell +npm install --save cacheable-request +``` + +## Usage + +```js +const http = require('http'); +const CacheableRequest = require('cacheable-request'); + +// Then instead of +const req = http.request('http://example.com', cb); +req.end(); + +// You can do +const cacheableRequest = new CacheableRequest(http.request); +const cacheReq = cacheableRequest('http://example.com', cb); +cacheReq.on('request', req => req.end()); +// Future requests to 'example.com' will be returned from cache if still valid + +// You pass in any other http.request API compatible method to be wrapped with cache support: +const cacheableRequest = new CacheableRequest(https.request); +const cacheableRequest = new CacheableRequest(electron.net); +``` + +## Storage Adapters + +`cacheable-request` uses [Keyv](https://github.com/lukechilds/keyv) to support a wide range of storage adapters. + +For example, to use Redis as a cache backend, you just need to install the official Redis Keyv storage adapter: + +``` +npm install --save @keyv/redis +``` + +And then you can pass `CacheableRequest` your connection string: + +```js +const cacheableRequest = new CacheableRequest(http.request, 'redis://user:pass@localhost:6379'); +``` + +[View all official Keyv storage adapters.](https://github.com/lukechilds/keyv#official-storage-adapters) + +Keyv also supports anything that follows the Map API so it's easy to write your own storage adapter or use a third-party solution. + +e.g The following are all valid storage adapters + +```js +const storageAdapter = new Map(); +// or +const storageAdapter = require('./my-storage-adapter'); +// or +const QuickLRU = require('quick-lru'); +const storageAdapter = new QuickLRU({ maxSize: 1000 }); + +const cacheableRequest = new CacheableRequest(http.request, storageAdapter); +``` + +View the [Keyv docs](https://github.com/lukechilds/keyv) for more information on how to use storage adapters. + +## API + +### new cacheableRequest(request, [storageAdapter]) + +Returns the provided request function wrapped with cache support. + +#### request + +Type: `function` + +Request function to wrap with cache support. Should be [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) or a similar API compatible request function. + +#### storageAdapter + +Type: `Keyv storage adapter`<br> +Default: `new Map()` + +A [Keyv](https://github.com/lukechilds/keyv) storage adapter instance, or connection string if using with an official Keyv storage adapter. + +### Instance + +#### cacheableRequest(opts, [cb]) + +Returns an event emitter. + +##### opts + +Type: `object`, `string` + +Any of the default request functions options plus: + +###### opts.cache + +Type: `boolean`<br> +Default: `true` + +If the cache should be used. Setting this to false will completely bypass the cache for the current request. + +###### opts.strictTtl + +Type: `boolean`<br> +Default: `false` + +If set to `false`, after a cached resource's TTL expires it is kept in the cache and will be revalidated on the next request with `If-None-Match`/`If-Modified-Since` headers. + +If set to `true` once a cached resource has expired it is deleted and will have to be re-requested. + +###### opts.automaticFailover + +Type: `boolean`<br> +Default: `false` + +When set to `true`, if the DB connection fails we will automatically fallback to a network request. DB errors will still be emitted to notify you of the problem even though the request callback may succeed. + +##### cb + +Type: `function` + +The callback function which will receive the response as an argument. + +The response can be either a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage) or a [responselike object](https://github.com/lukechilds/responselike). The response will also have a `fromCache` property set with a boolean value. + +##### .on('request', request) + +`request` event to get the request object of the request. + +**Note:** This event will only fire if an HTTP request is actually made, not when a response is retrieved from cache. However, you should always handle the `request` event to end the request and handle any potential request errors. + +##### .on('response', response) + +`response` event to get the response object from the HTTP request or cache. + +##### .on('error', error) + +`error` event emitted in case of an error with the cache. + +Errors emitted here will be an instance of `CacheableRequest.RequestError` or `CacheableRequest.CacheError`. You will only ever receive a `RequestError` if the request function throws (normally caused by invalid user input). Normal request errors should be handled inside the `request` event. + +To properly handle all error scenarios you should use the following pattern: + +```js +cacheableRequest('example.com', cb) + .on('error', err => { + if (err instanceof CacheableRequest.CacheError) { + handleCacheError(err); // Cache error + } else if (err instanceof CacheableRequest.RequestError) { + handleRequestError(err); // Request function thrown + } + }) + .on('request', req => { + req.on('error', handleRequestError); // Request error emitted + req.end(); + }); +``` + +**Note:** Database connection errors are emitted here, however `cacheable-request` will attempt to re-request the resource and bypass the cache on a connection error. Therefore a database connection error doesn't necessarily mean the request won't be fulfilled. + +## License + +MIT © Luke Childs diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/buffer-stream.js b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/buffer-stream.js new file mode 100644 index 0000000..ae45d3d --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/buffer-stream.js @@ -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; +}; diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/index.js b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/index.js new file mode 100644 index 0000000..2dc5ee9 --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/index.js @@ -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})); diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/license b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/package.json b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/package.json new file mode 100644 index 0000000..2f2adf0 --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/package.json @@ -0,0 +1,48 @@ +{ + "name": "get-stream", + "version": "3.0.0", + "description": "Get a stream as a string, buffer, or array", + "license": "MIT", + "repository": "sindresorhus/get-stream", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js", + "buffer-stream.js" + ], + "keywords": [ + "get", + "stream", + "promise", + "concat", + "string", + "str", + "text", + "buffer", + "read", + "data", + "consume", + "readable", + "readablestream", + "array", + "object", + "obj" + ], + "devDependencies": { + "ava": "*", + "into-stream": "^3.0.0", + "xo": "*" + }, + "xo": { + "esnext": true + } +} diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/readme.md b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/readme.md new file mode 100644 index 0000000..73b188f --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/get-stream/readme.md @@ -0,0 +1,117 @@ +# get-stream [![Build Status](https://travis-ci.org/sindresorhus/get-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stream) + +> Get a stream as a string, buffer, or array + + +## Install + +``` +$ npm install --save get-stream +``` + + +## Usage + +```js +const fs = require('fs'); +const getStream = require('get-stream'); +const stream = fs.createReadStream('unicorn.txt'); + +getStream(stream).then(str => { + console.log(str); + /* + ,,))))))));, + __)))))))))))))), + \|/ -\(((((''''((((((((. + -*-==//////(('' . `)))))), + /|\ ))| o ;-. '((((( ,(, + ( `| / ) ;))))' ,_))^;(~ + | | | ,))((((_ _____------~~~-. %,;(;(>';'~ + o_); ; )))(((` ~---~ `:: \ %%~~)(v;(`('~ + ; ''''```` `: `:::|\,__,%% );`'; ~ + | _ ) / `:|`----' `-' + ______/\/~ | / / + /~;;.____/;;' / ___--,-( `;;;/ + / // _;______;'------~~~~~ /;;/\ / + // | | / ; \;;,\ + (<_ | ; /',/-----' _> + \_| ||_ //~;~~~~~~~~~ + `\_| (,~~ + \~\ + ~~ + */ +}); +``` + + +## API + +The methods returns a promise that resolves when the `end` event fires on the stream, indicating that there is no more data to be read. The stream is switched to flowing mode. + +### getStream(stream, [options]) + +Get the `stream` as a string. + +#### options + +##### encoding + +Type: `string`<br> +Default: `utf8` + +[Encoding](https://nodejs.org/api/buffer.html#buffer_buffer) of the incoming stream. + +##### maxBuffer + +Type: `number`<br> +Default: `Infinity` + +Maximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected. + +### getStream.buffer(stream, [options]) + +Get the `stream` as a buffer. + +It honors the `maxBuffer` option as above, but it refers to byte length rather than string length. + +### getStream.array(stream, [options]) + +Get the `stream` as an array of values. + +It honors both the `maxBuffer` and `encoding` options. The behavior changes slightly based on the encoding chosen: + +- When `encoding` is unset, it assumes an [object mode stream](https://nodesource.com/blog/understanding-object-streams/) and collects values emitted from `stream` unmodified. In this case `maxBuffer` refers to the number of items in the array (not the sum of their sizes). + +- When `encoding` is set to `buffer`, it collects an array of buffers. `maxBuffer` refers to the summed byte lengths of every buffer in the array. + +- When `encoding` is set to anything else, it collects an array of strings. `maxBuffer` refers to the summed character lengths of every string in the array. + + +## Errors + +If the input stream emits an `error` event, the promise will be rejected with the error. The buffered data will be attached to the `bufferedData` property of the error. + +```js +getStream(streamThatErrorsAtTheEnd('unicorn')) + .catch(err => { + console.log(err.bufferedData); + //=> 'unicorn' + }); +``` + + +## FAQ + +### How is this different from [`concat-stream`](https://github.com/maxogden/concat-stream)? + +This module accepts a stream instead of being one and returns a promise instead of using a callback. The API is simpler and it only supports returning a string, buffer, or array. It doesn't have a fragile type inference. You explicitly choose what you want. And it doesn't depend on the huge `readable-stream` package. + + +## Related + +- [get-stdin](https://github.com/sindresorhus/get-stdin) - Get stdin as a string or buffer + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/index.js b/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/index.js new file mode 100644 index 0000000..b8d8898 --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/index.js @@ -0,0 +1,11 @@ +'use strict'; +module.exports = function (obj) { + var ret = {}; + var keys = Object.keys(Object(obj)); + + for (var i = 0; i < keys.length; i++) { + ret[keys[i].toLowerCase()] = obj[keys[i]]; + } + + return ret; +}; diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/package.json b/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/package.json new file mode 100644 index 0000000..7e4e396 --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/package.json @@ -0,0 +1,35 @@ +{ + "name": "lowercase-keys", + "version": "1.0.0", + "description": "Lowercase the keys of an object", + "license": "MIT", + "repository": "sindresorhus/lowercase-keys", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "node test.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "object", + "assign", + "extend", + "properties", + "lowercase", + "lower-case", + "case", + "keys", + "key" + ], + "devDependencies": { + "ava": "0.0.4" + } +} diff --git a/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/readme.md b/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/readme.md new file mode 100644 index 0000000..dc65770 --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/node_modules/lowercase-keys/readme.md @@ -0,0 +1,33 @@ +# lowercase-keys [![Build Status](https://travis-ci.org/sindresorhus/lowercase-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/lowercase-keys) + +> Lowercase the keys of an object + + +## Install + +``` +$ npm install --save lowercase-keys +``` + + +## Usage + +```js +var lowercaseKeys = require('lowercase-keys'); + +lowercaseKeys({FOO: true, bAr: false}); +//=> {foo: true, bar: false} +``` + + +## API + +### lowercaseKeys(object) + +Lowercases the keys and returns a new object. + + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/download/node_modules/cacheable-request/package.json b/node_modules/download/node_modules/cacheable-request/package.json new file mode 100644 index 0000000..0448312 --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/package.json @@ -0,0 +1,57 @@ +{ + "name": "cacheable-request", + "version": "2.1.4", + "description": "Wrap native HTTP requests with RFC compliant cache support", + "main": "src/index.js", + "scripts": { + "test": "xo && nyc ava", + "coverage": "nyc report --reporter=text-lcov | coveralls" + }, + "xo": { + "extends": "xo-lukechilds" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/lukechilds/cacheable-request.git" + }, + "keywords": [ + "HTTP", + "HTTPS", + "cache", + "caching", + "layer", + "cacheable", + "RFC 7234", + "RFC", + "7234", + "compliant" + ], + "author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)", + "license": "MIT", + "bugs": { + "url": "https://github.com/lukechilds/cacheable-request/issues" + }, + "homepage": "https://github.com/lukechilds/cacheable-request", + "dependencies": { + "clone-response": "1.0.2", + "get-stream": "3.0.0", + "http-cache-semantics": "3.8.1", + "keyv": "3.0.0", + "lowercase-keys": "1.0.0", + "normalize-url": "2.0.1", + "responselike": "1.0.2" + }, + "devDependencies": { + "@keyv/sqlite": "^1.2.6", + "ava": "^0.24.0", + "coveralls": "^3.0.0", + "create-test-server": "^2.0.0", + "delay": "^2.0.0", + "eslint-config-xo-lukechilds": "^1.0.0", + "nyc": "^11.0.2", + "pify": "^3.0.0", + "sqlite3": "^3.1.9", + "this": "^1.0.2", + "xo": "^0.19.0" + } +} diff --git a/node_modules/download/node_modules/cacheable-request/src/index.js b/node_modules/download/node_modules/cacheable-request/src/index.js new file mode 100644 index 0000000..1935b2d --- /dev/null +++ b/node_modules/download/node_modules/cacheable-request/src/index.js @@ -0,0 +1,155 @@ +'use strict'; + +const EventEmitter = require('events'); +const urlLib = require('url'); +const normalizeUrl = require('normalize-url'); +const getStream = require('get-stream'); +const CachePolicy = require('http-cache-semantics'); +const Response = require('responselike'); +const lowercaseKeys = require('lowercase-keys'); +const cloneResponse = require('clone-response'); +const Keyv = require('keyv'); + +class CacheableRequest { + constructor(request, cacheAdapter) { + if (typeof request !== 'function') { + throw new TypeError('Parameter `request` must be a function'); + } + + this.cache = new Keyv({ + uri: typeof cacheAdapter === 'string' && cacheAdapter, + store: typeof cacheAdapter !== 'string' && cacheAdapter, + namespace: 'cacheable-request' + }); + + return this.createCacheableRequest(request); + } + + createCacheableRequest(request) { + return (opts, cb) => { + if (typeof opts === 'string') { + opts = urlLib.parse(opts); + } + opts = Object.assign({ + headers: {}, + method: 'GET', + cache: true, + strictTtl: false, + automaticFailover: false + }, opts); + opts.headers = lowercaseKeys(opts.headers); + + const ee = new EventEmitter(); + const url = normalizeUrl(urlLib.format(opts)); + const key = `${opts.method}:${url}`; + let revalidate = false; + let madeRequest = false; + + const makeRequest = opts => { + madeRequest = true; + const handler = response => { + if (revalidate) { + const revalidatedPolicy = CachePolicy.fromObject(revalidate.cachePolicy).revalidatedPolicy(opts, response); + if (!revalidatedPolicy.modified) { + const headers = revalidatedPolicy.policy.responseHeaders(); + response = new Response(response.statusCode, headers, revalidate.body, revalidate.url); + response.cachePolicy = revalidatedPolicy.policy; + response.fromCache = true; + } + } + + if (!response.fromCache) { + response.cachePolicy = new CachePolicy(opts, response); + response.fromCache = false; + } + + let clonedResponse; + if (opts.cache && response.cachePolicy.storable()) { + clonedResponse = cloneResponse(response); + getStream.buffer(response) + .then(body => { + const value = { + cachePolicy: response.cachePolicy.toObject(), + url: response.url, + statusCode: response.fromCache ? revalidate.statusCode : response.statusCode, + body + }; + const ttl = opts.strictTtl ? response.cachePolicy.timeToLive() : undefined; + return this.cache.set(key, value, ttl); + }) + .catch(err => ee.emit('error', new CacheableRequest.CacheError(err))); + } else if (opts.cache && revalidate) { + this.cache.delete(key) + .catch(err => ee.emit('error', new CacheableRequest.CacheError(err))); + } + + ee.emit('response', clonedResponse || response); + if (typeof cb === 'function') { + cb(clonedResponse || response); + } + }; + + try { + const req = request(opts, handler); + ee.emit('request', req); + } catch (err) { + ee.emit('error', new CacheableRequest.RequestError(err)); + } + }; + + const get = opts => Promise.resolve() + .then(() => opts.cache ? this.cache.get(key) : undefined) + .then(cacheEntry => { + if (typeof cacheEntry === 'undefined') { + return makeRequest(opts); + } + + const policy = CachePolicy.fromObject(cacheEntry.cachePolicy); + if (policy.satisfiesWithoutRevalidation(opts)) { + const headers = policy.responseHeaders(); + const response = new Response(cacheEntry.statusCode, headers, cacheEntry.body, cacheEntry.url); + response.cachePolicy = policy; + response.fromCache = true; + + ee.emit('response', response); + if (typeof cb === 'function') { + cb(response); + } + } else { + revalidate = cacheEntry; + opts.headers = policy.revalidationHeaders(opts); + makeRequest(opts); + } + }); + + this.cache.on('error', err => ee.emit('error', new CacheableRequest.CacheError(err))); + + get(opts).catch(err => { + if (opts.automaticFailover && !madeRequest) { + makeRequest(opts); + } + ee.emit('error', new CacheableRequest.CacheError(err)); + }); + + return ee; + }; + } +} + +CacheableRequest.RequestError = class extends Error { + constructor(err) { + super(err.message); + this.name = 'RequestError'; + Object.assign(this, err); + } +}; + +CacheableRequest.CacheError = class extends Error { + constructor(err) { + super(err.message); + this.name = 'CacheError'; + Object.assign(this, err); + } +}; + +module.exports = CacheableRequest; diff --git a/node_modules/download/node_modules/decompress-response/index.js b/node_modules/download/node_modules/decompress-response/index.js new file mode 100644 index 0000000..d8acd4a --- /dev/null +++ b/node_modules/download/node_modules/decompress-response/index.js @@ -0,0 +1,29 @@ +'use strict'; +const PassThrough = require('stream').PassThrough; +const zlib = require('zlib'); +const mimicResponse = require('mimic-response'); + +module.exports = response => { + // TODO: Use Array#includes when targeting Node.js 6 + if (['gzip', 'deflate'].indexOf(response.headers['content-encoding']) === -1) { + return response; + } + + const unzip = zlib.createUnzip(); + const stream = new PassThrough(); + + mimicResponse(response, stream); + + unzip.on('error', err => { + if (err.code === 'Z_BUF_ERROR') { + stream.end(); + return; + } + + stream.emit('error', err); + }); + + response.pipe(unzip).pipe(stream); + + return stream; +}; diff --git a/node_modules/download/node_modules/decompress-response/license b/node_modules/download/node_modules/decompress-response/license new file mode 100644 index 0000000..32a16ce --- /dev/null +++ b/node_modules/download/node_modules/decompress-response/license @@ -0,0 +1,21 @@ +`The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/download/node_modules/decompress-response/package.json b/node_modules/download/node_modules/decompress-response/package.json new file mode 100644 index 0000000..3574dc2 --- /dev/null +++ b/node_modules/download/node_modules/decompress-response/package.json @@ -0,0 +1,53 @@ +{ + "name": "decompress-response", + "version": "3.3.0", + "description": "Decompress a HTTP response if needed", + "license": "MIT", + "repository": "sindresorhus/decompress-response", + "maintainers": [ + { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + { + "name": "Vsevolod Strukchinsky", + "email": "floatdrop@gmail.com", + "url": "github.com/floatdrop" + } + ], + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "decompress", + "response", + "http", + "https", + "zlib", + "gzip", + "zip", + "deflate", + "unzip", + "ungzip", + "incoming", + "message", + "stream", + "compressed" + ], + "dependencies": { + "mimic-response": "^1.0.0" + }, + "devDependencies": { + "ava": "*", + "get-stream": "^3.0.0", + "pify": "^3.0.0", + "xo": "*" + } +} diff --git a/node_modules/download/node_modules/decompress-response/readme.md b/node_modules/download/node_modules/decompress-response/readme.md new file mode 100644 index 0000000..1b98767 --- /dev/null +++ b/node_modules/download/node_modules/decompress-response/readme.md @@ -0,0 +1,31 @@ +# decompress-response [![Build Status](https://travis-ci.org/sindresorhus/decompress-response.svg?branch=master)](https://travis-ci.org/sindresorhus/decompress-response) + +> Decompress a HTTP response if needed + +Decompresses the [response](https://nodejs.org/api/http.html#http_class_http_incomingmessage) from [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) if it's gzipped or deflated, otherwise just passes it through. + +Used by [`got`](https://github.com/sindresorhus/got). + + +## Install + +``` +$ npm install decompress-response +``` + + +## Usage + +```js +const http = require('http'); +const decompressResponse = require('decompress-response'); + +http.get('http://sindresorhus.com', response => { + response = decompressResponse(response); +}); +``` + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/node_modules/got/errors.js b/node_modules/download/node_modules/got/errors.js new file mode 100644 index 0000000..ad83388 --- /dev/null +++ b/node_modules/download/node_modules/got/errors.js @@ -0,0 +1,92 @@ +'use strict'; +const urlLib = require('url'); +const http = require('http'); +const PCancelable = require('p-cancelable'); +const is = require('@sindresorhus/is'); + +class GotError extends Error { + constructor(message, error, opts) { + super(message); + Error.captureStackTrace(this, this.constructor); + this.name = 'GotError'; + + if (!is.undefined(error.code)) { + this.code = error.code; + } + + Object.assign(this, { + host: opts.host, + hostname: opts.hostname, + method: opts.method, + path: opts.path, + protocol: opts.protocol, + url: opts.href + }); + } +} + +module.exports.GotError = GotError; + +module.exports.CacheError = class extends GotError { + constructor(error, opts) { + super(error.message, error, opts); + this.name = 'CacheError'; + } +}; + +module.exports.RequestError = class extends GotError { + constructor(error, opts) { + super(error.message, error, opts); + this.name = 'RequestError'; + } +}; + +module.exports.ReadError = class extends GotError { + constructor(error, opts) { + super(error.message, error, opts); + this.name = 'ReadError'; + } +}; + +module.exports.ParseError = class extends GotError { + constructor(error, statusCode, opts, data) { + super(`${error.message} in "${urlLib.format(opts)}": \n${data.slice(0, 77)}...`, error, opts); + this.name = 'ParseError'; + this.statusCode = statusCode; + this.statusMessage = http.STATUS_CODES[this.statusCode]; + } +}; + +module.exports.HTTPError = class extends GotError { + constructor(statusCode, statusMessage, headers, opts) { + if (statusMessage) { + statusMessage = statusMessage.replace(/\r?\n/g, ' ').trim(); + } else { + statusMessage = http.STATUS_CODES[statusCode]; + } + super(`Response code ${statusCode} (${statusMessage})`, {}, opts); + this.name = 'HTTPError'; + this.statusCode = statusCode; + this.statusMessage = statusMessage; + this.headers = headers; + } +}; + +module.exports.MaxRedirectsError = class extends GotError { + constructor(statusCode, redirectUrls, opts) { + super('Redirected 10 times. Aborting.', {}, opts); + this.name = 'MaxRedirectsError'; + this.statusCode = statusCode; + this.statusMessage = http.STATUS_CODES[this.statusCode]; + this.redirectUrls = redirectUrls; + } +}; + +module.exports.UnsupportedProtocolError = class extends GotError { + constructor(opts) { + super(`Unsupported protocol "${opts.protocol}"`, {}, opts); + this.name = 'UnsupportedProtocolError'; + } +}; + +module.exports.CancelError = PCancelable.CancelError; diff --git a/node_modules/download/node_modules/got/index.js b/node_modules/download/node_modules/got/index.js new file mode 100644 index 0000000..9d83b77 --- /dev/null +++ b/node_modules/download/node_modules/got/index.js @@ -0,0 +1,675 @@ +'use strict'; +const EventEmitter = require('events'); +const http = require('http'); +const https = require('https'); +const PassThrough = require('stream').PassThrough; +const Transform = require('stream').Transform; +const urlLib = require('url'); +const fs = require('fs'); +const querystring = require('querystring'); +const CacheableRequest = require('cacheable-request'); +const duplexer3 = require('duplexer3'); +const intoStream = require('into-stream'); +const is = require('@sindresorhus/is'); +const getStream = require('get-stream'); +const timedOut = require('timed-out'); +const urlParseLax = require('url-parse-lax'); +const urlToOptions = require('url-to-options'); +const lowercaseKeys = require('lowercase-keys'); +const decompressResponse = require('decompress-response'); +const mimicResponse = require('mimic-response'); +const isRetryAllowed = require('is-retry-allowed'); +const isURL = require('isurl'); +const PCancelable = require('p-cancelable'); +const pTimeout = require('p-timeout'); +const pify = require('pify'); +const Buffer = require('safe-buffer').Buffer; +const pkg = require('./package.json'); +const errors = require('./errors'); + +const getMethodRedirectCodes = new Set([300, 301, 302, 303, 304, 305, 307, 308]); +const allMethodRedirectCodes = new Set([300, 303, 307, 308]); + +const isFormData = body => is.nodeStream(body) && is.function(body.getBoundary); + +const getBodySize = opts => { + const body = opts.body; + + if (opts.headers['content-length']) { + return Number(opts.headers['content-length']); + } + + if (!body && !opts.stream) { + return 0; + } + + if (is.string(body)) { + return Buffer.byteLength(body); + } + + if (isFormData(body)) { + return pify(body.getLength.bind(body))(); + } + + if (body instanceof fs.ReadStream) { + return pify(fs.stat)(body.path).then(stat => stat.size); + } + + if (is.nodeStream(body) && is.buffer(body._buffer)) { + return body._buffer.length; + } + + return null; +}; + +function requestAsEventEmitter(opts) { + opts = opts || {}; + + const ee = new EventEmitter(); + const requestUrl = opts.href || urlLib.resolve(urlLib.format(opts), opts.path); + const redirects = []; + const agents = is.object(opts.agent) ? opts.agent : null; + let retryCount = 0; + let redirectUrl; + let uploadBodySize; + let uploaded = 0; + + const get = opts => { + if (opts.protocol !== 'http:' && opts.protocol !== 'https:') { + ee.emit('error', new got.UnsupportedProtocolError(opts)); + return; + } + + let fn = opts.protocol === 'https:' ? https : http; + + if (agents) { + const protocolName = opts.protocol === 'https:' ? 'https' : 'http'; + opts.agent = agents[protocolName] || opts.agent; + } + + if (opts.useElectronNet && process.versions.electron) { + const electron = require('electron'); + fn = electron.net || electron.remote.net; + } + + let progressInterval; + + const cacheableRequest = new CacheableRequest(fn.request, opts.cache); + const cacheReq = cacheableRequest(opts, res => { + clearInterval(progressInterval); + + ee.emit('uploadProgress', { + percent: 1, + transferred: uploaded, + total: uploadBodySize + }); + + const statusCode = res.statusCode; + + res.url = redirectUrl || requestUrl; + res.requestUrl = requestUrl; + + const followRedirect = opts.followRedirect && 'location' in res.headers; + const redirectGet = followRedirect && getMethodRedirectCodes.has(statusCode); + const redirectAll = followRedirect && allMethodRedirectCodes.has(statusCode); + + if (redirectAll || (redirectGet && (opts.method === 'GET' || opts.method === 'HEAD'))) { + res.resume(); + + if (statusCode === 303) { + // Server responded with "see other", indicating that the resource exists at another location, + // and the client should request it from that location via GET or HEAD. + opts.method = 'GET'; + } + + if (redirects.length >= 10) { + ee.emit('error', new got.MaxRedirectsError(statusCode, redirects, opts), null, res); + return; + } + + const bufferString = Buffer.from(res.headers.location, 'binary').toString(); + + redirectUrl = urlLib.resolve(urlLib.format(opts), bufferString); + + redirects.push(redirectUrl); + + const redirectOpts = Object.assign({}, opts, urlLib.parse(redirectUrl)); + + ee.emit('redirect', res, redirectOpts); + + get(redirectOpts); + + return; + } + + setImmediate(() => { + try { + getResponse(res, opts, ee, redirects); + } catch (e) { + ee.emit('error', e); + } + }); + }); + + cacheReq.on('error', err => { + if (err instanceof CacheableRequest.RequestError) { + ee.emit('error', new got.RequestError(err, opts)); + } else { + ee.emit('error', new got.CacheError(err, opts)); + } + }); + + cacheReq.once('request', req => { + let aborted = false; + req.once('abort', _ => { + aborted = true; + }); + + req.once('error', err => { + clearInterval(progressInterval); + + if (aborted) { + return; + } + + const backoff = opts.retries(++retryCount, err); + + if (backoff) { + setTimeout(get, backoff, opts); + return; + } + + ee.emit('error', new got.RequestError(err, opts)); + }); + + ee.once('request', req => { + ee.emit('uploadProgress', { + percent: 0, + transferred: 0, + total: uploadBodySize + }); + + const socket = req.connection; + if (socket) { + // `._connecting` was the old property which was made public in node v6.1.0 + const isConnecting = socket.connecting === undefined ? socket._connecting : socket.connecting; + + const onSocketConnect = () => { + const uploadEventFrequency = 150; + + progressInterval = setInterval(() => { + if (socket.destroyed) { + clearInterval(progressInterval); + return; + } + + const lastUploaded = uploaded; + const headersSize = req._header ? Buffer.byteLength(req._header) : 0; + uploaded = socket.bytesWritten - headersSize; + + // Prevent the known issue of `bytesWritten` being larger than body size + if (uploadBodySize && uploaded > uploadBodySize) { + uploaded = uploadBodySize; + } + + // Don't emit events with unchanged progress and + // prevent last event from being emitted, because + // it's emitted when `response` is emitted + if (uploaded === lastUploaded || uploaded === uploadBodySize) { + return; + } + + ee.emit('uploadProgress', { + percent: uploadBodySize ? uploaded / uploadBodySize : 0, + transferred: uploaded, + total: uploadBodySize + }); + }, uploadEventFrequency); + }; + + // Only subscribe to 'connect' event if we're actually connecting a new + // socket, otherwise if we're already connected (because this is a + // keep-alive connection) do not bother. This is important since we won't + // get a 'connect' event for an already connected socket. + if (isConnecting) { + socket.once('connect', onSocketConnect); + } else { + onSocketConnect(); + } + } + }); + + if (opts.gotTimeout) { + clearInterval(progressInterval); + timedOut(req, opts.gotTimeout); + } + + setImmediate(() => { + ee.emit('request', req); + }); + }); + }; + + setImmediate(() => { + Promise.resolve(getBodySize(opts)) + .then(size => { + uploadBodySize = size; + + if ( + is.undefined(opts.headers['content-length']) && + is.undefined(opts.headers['transfer-encoding']) && + isFormData(opts.body) + ) { + opts.headers['content-length'] = size; + } + + get(opts); + }) + .catch(err => { + ee.emit('error', err); + }); + }); + + return ee; +} + +function getResponse(res, opts, ee, redirects) { + const downloadBodySize = Number(res.headers['content-length']) || null; + let downloaded = 0; + + const progressStream = new Transform({ + transform(chunk, encoding, callback) { + downloaded += chunk.length; + + const percent = downloadBodySize ? downloaded / downloadBodySize : 0; + + // Let flush() be responsible for emitting the last event + if (percent < 1) { + ee.emit('downloadProgress', { + percent, + transferred: downloaded, + total: downloadBodySize + }); + } + + callback(null, chunk); + }, + + flush(callback) { + ee.emit('downloadProgress', { + percent: 1, + transferred: downloaded, + total: downloadBodySize + }); + + callback(); + } + }); + + mimicResponse(res, progressStream); + progressStream.redirectUrls = redirects; + + const response = opts.decompress === true && + is.function(decompressResponse) && + opts.method !== 'HEAD' ? decompressResponse(progressStream) : progressStream; + + if (!opts.decompress && ['gzip', 'deflate'].indexOf(res.headers['content-encoding']) !== -1) { + opts.encoding = null; + } + + ee.emit('response', response); + + ee.emit('downloadProgress', { + percent: 0, + transferred: 0, + total: downloadBodySize + }); + + res.pipe(progressStream); +} + +function asPromise(opts) { + const timeoutFn = requestPromise => opts.gotTimeout && opts.gotTimeout.request ? + pTimeout(requestPromise, opts.gotTimeout.request, new got.RequestError({message: 'Request timed out', code: 'ETIMEDOUT'}, opts)) : + requestPromise; + + const proxy = new EventEmitter(); + + const cancelable = new PCancelable((resolve, reject, onCancel) => { + const ee = requestAsEventEmitter(opts); + let cancelOnRequest = false; + + onCancel(() => { + cancelOnRequest = true; + }); + + ee.on('request', req => { + if (cancelOnRequest) { + req.abort(); + } + + onCancel(() => { + req.abort(); + }); + + if (is.nodeStream(opts.body)) { + opts.body.pipe(req); + opts.body = undefined; + return; + } + + req.end(opts.body); + }); + + ee.on('response', res => { + const stream = is.null(opts.encoding) ? 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 (err) { + if (statusCode >= 200 && statusCode < 300) { + throw new got.ParseError(err, statusCode, opts, data); + } + } + } + + if (opts.throwHttpErrors && statusCode !== 304 && (statusCode < 200 || statusCode > limitStatusCode)) { + throw new got.HTTPError(statusCode, res.statusMessage, res.headers, opts); + } + + resolve(res); + }) + .catch(err => { + Object.defineProperty(err, 'response', {value: res}); + reject(err); + }); + }); + + ee.once('error', reject); + ee.on('redirect', proxy.emit.bind(proxy, 'redirect')); + ee.on('uploadProgress', proxy.emit.bind(proxy, 'uploadProgress')); + ee.on('downloadProgress', proxy.emit.bind(proxy, 'downloadProgress')); + }); + + // Preserve backwards-compatibility + // TODO: Remove this in the next major version + Object.defineProperty(cancelable, 'canceled', { + get() { + return cancelable.isCanceled; + } + }); + + const promise = timeoutFn(cancelable); + + promise.cancel = cancelable.cancel.bind(cancelable); + + promise.on = (name, fn) => { + proxy.on(name, fn); + return promise; + }; + + return promise; +} + +function asStream(opts) { + opts.stream = true; + + const input = new PassThrough(); + const output = new PassThrough(); + const proxy = duplexer3(input, output); + let timeout; + + if (opts.gotTimeout && opts.gotTimeout.request) { + timeout = setTimeout(() => { + proxy.emit('error', new got.RequestError({message: 'Request timed out', code: 'ETIMEDOUT'}, opts)); + }, opts.gotTimeout.request); + } + + if (opts.json) { + throw new Error('Got can not be used as a stream when the `json` option is used'); + } + + if (opts.body) { + proxy.write = () => { + throw new Error('Got\'s stream is not writable when the `body` option is used'); + }; + } + + const ee = requestAsEventEmitter(opts); + + ee.on('request', req => { + proxy.emit('request', req); + + if (is.nodeStream(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 => { + clearTimeout(timeout); + + const statusCode = res.statusCode; + + res.on('error', err => { + proxy.emit('error', new got.ReadError(err, opts)); + }); + + res.pipe(output); + + if (opts.throwHttpErrors && statusCode !== 304 && (statusCode < 200 || statusCode > 299)) { + proxy.emit('error', new got.HTTPError(statusCode, res.statusMessage, res.headers, opts), null, res); + return; + } + + proxy.emit('response', res); + }); + + ee.on('error', proxy.emit.bind(proxy, 'error')); + ee.on('redirect', proxy.emit.bind(proxy, 'redirect')); + ee.on('uploadProgress', proxy.emit.bind(proxy, 'uploadProgress')); + ee.on('downloadProgress', proxy.emit.bind(proxy, 'downloadProgress')); + + return proxy; +} + +function normalizeArguments(url, opts) { + if (!is.string(url) && !is.object(url)) { + throw new TypeError(`Parameter \`url\` must be a string or object, not ${is(url)}`); + } else if (is.string(url)) { + url = url.replace(/^unix:/, 'http://$&'); + + try { + decodeURI(url); + } catch (err) { + throw new Error('Parameter `url` must contain valid UTF-8 character sequences'); + } + + url = urlParseLax(url); + if (url.auth) { + throw new Error('Basic authentication must be done with the `auth` option'); + } + } else if (isURL.lenient(url)) { + url = urlToOptions(url); + } + + opts = Object.assign( + { + path: '', + retries: 2, + cache: false, + decompress: true, + useElectronNet: false, + throwHttpErrors: true + }, + url, + { + protocol: url.protocol || 'http:' // Override both null/undefined with default protocol + }, + opts + ); + + const headers = lowercaseKeys(opts.headers); + for (const key of Object.keys(headers)) { + if (is.nullOrUndefined(headers[key])) { + delete headers[key]; + } + } + + opts.headers = Object.assign({ + 'user-agent': `${pkg.name}/${pkg.version} (https://github.com/sindresorhus/got)` + }, headers); + + if (opts.decompress && is.undefined(opts.headers['accept-encoding'])) { + opts.headers['accept-encoding'] = 'gzip, deflate'; + } + + const query = opts.query; + + if (query) { + if (!is.string(query)) { + opts.query = querystring.stringify(query); + } + + opts.path = `${opts.path.split('?')[0]}?${opts.query}`; + delete opts.query; + } + + if (opts.json && is.undefined(opts.headers.accept)) { + opts.headers.accept = 'application/json'; + } + + const body = opts.body; + if (is.nullOrUndefined(body)) { + opts.method = (opts.method || 'GET').toUpperCase(); + } else { + const headers = opts.headers; + if (!is.nodeStream(body) && !is.string(body) && !is.buffer(body) && !(opts.form || opts.json)) { + throw new TypeError('The `body` option must be a stream.Readable, string, Buffer or plain Object'); + } + + const canBodyBeStringified = is.plainObject(body) || is.array(body); + if ((opts.form || opts.json) && !canBodyBeStringified) { + throw new TypeError('The `body` option must be a plain Object or Array when the `form` or `json` option is used'); + } + + if (isFormData(body)) { + // Special case for https://github.com/form-data/form-data + headers['content-type'] = headers['content-type'] || `multipart/form-data; boundary=${body.getBoundary()}`; + } else if (opts.form && canBodyBeStringified) { + headers['content-type'] = headers['content-type'] || 'application/x-www-form-urlencoded'; + opts.body = querystring.stringify(body); + } else if (opts.json && canBodyBeStringified) { + headers['content-type'] = headers['content-type'] || 'application/json'; + opts.body = JSON.stringify(body); + } + + if (is.undefined(headers['content-length']) && is.undefined(headers['transfer-encoding']) && !is.nodeStream(body)) { + const length = is.string(opts.body) ? Buffer.byteLength(opts.body) : opts.body.length; + headers['content-length'] = length; + } + + // Convert buffer to stream to receive upload progress events + // see https://github.com/sindresorhus/got/pull/322 + if (is.buffer(body)) { + opts.body = intoStream(body); + opts.body._buffer = body; + } + + opts.method = (opts.method || 'POST').toUpperCase(); + } + + if (opts.hostname === 'unix') { + const matches = /(.+?):(.+)/.exec(opts.path); + + if (matches) { + opts.socketPath = matches[1]; + opts.path = matches[2]; + opts.host = null; + } + } + + if (!is.function(opts.retries)) { + 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 (is.undefined(opts.followRedirect)) { + opts.followRedirect = true; + } + + if (opts.timeout) { + if (is.number(opts.timeout)) { + opts.gotTimeout = {request: opts.timeout}; + } else { + opts.gotTimeout = opts.timeout; + } + delete opts.timeout; + } + + return opts; +} + +function got(url, opts) { + try { + const normalizedArgs = normalizeArguments(url, opts); + + if (normalizedArgs.stream) { + return asStream(normalizedArgs); + } + + return asPromise(normalizedArgs); + } catch (err) { + return Promise.reject(err); + } +} + +got.stream = (url, opts) => asStream(normalizeArguments(url, opts)); + +const methods = [ + 'get', + 'post', + 'put', + 'patch', + 'head', + 'delete' +]; + +for (const method of methods) { + got[method] = (url, opts) => got(url, Object.assign({}, opts, {method})); + got.stream[method] = (url, opts) => got.stream(url, Object.assign({}, opts, {method})); +} + +Object.assign(got, errors); + +module.exports = got; diff --git a/node_modules/download/node_modules/got/license b/node_modules/download/node_modules/got/license new file mode 100644 index 0000000..e7af2f7 --- /dev/null +++ b/node_modules/download/node_modules/got/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/download/node_modules/got/node_modules/get-stream/buffer-stream.js b/node_modules/download/node_modules/got/node_modules/get-stream/buffer-stream.js new file mode 100644 index 0000000..ae45d3d --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/get-stream/buffer-stream.js @@ -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; +}; diff --git a/node_modules/download/node_modules/got/node_modules/get-stream/index.js b/node_modules/download/node_modules/got/node_modules/get-stream/index.js new file mode 100644 index 0000000..2dc5ee9 --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/get-stream/index.js @@ -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})); diff --git a/node_modules/download/node_modules/got/node_modules/get-stream/license b/node_modules/download/node_modules/got/node_modules/get-stream/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/get-stream/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/download/node_modules/got/node_modules/get-stream/package.json b/node_modules/download/node_modules/got/node_modules/get-stream/package.json new file mode 100644 index 0000000..2f2adf0 --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/get-stream/package.json @@ -0,0 +1,48 @@ +{ + "name": "get-stream", + "version": "3.0.0", + "description": "Get a stream as a string, buffer, or array", + "license": "MIT", + "repository": "sindresorhus/get-stream", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js", + "buffer-stream.js" + ], + "keywords": [ + "get", + "stream", + "promise", + "concat", + "string", + "str", + "text", + "buffer", + "read", + "data", + "consume", + "readable", + "readablestream", + "array", + "object", + "obj" + ], + "devDependencies": { + "ava": "*", + "into-stream": "^3.0.0", + "xo": "*" + }, + "xo": { + "esnext": true + } +} diff --git a/node_modules/download/node_modules/got/node_modules/get-stream/readme.md b/node_modules/download/node_modules/got/node_modules/get-stream/readme.md new file mode 100644 index 0000000..73b188f --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/get-stream/readme.md @@ -0,0 +1,117 @@ +# get-stream [![Build Status](https://travis-ci.org/sindresorhus/get-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stream) + +> Get a stream as a string, buffer, or array + + +## Install + +``` +$ npm install --save get-stream +``` + + +## Usage + +```js +const fs = require('fs'); +const getStream = require('get-stream'); +const stream = fs.createReadStream('unicorn.txt'); + +getStream(stream).then(str => { + console.log(str); + /* + ,,))))))));, + __)))))))))))))), + \|/ -\(((((''''((((((((. + -*-==//////(('' . `)))))), + /|\ ))| o ;-. '((((( ,(, + ( `| / ) ;))))' ,_))^;(~ + | | | ,))((((_ _____------~~~-. %,;(;(>';'~ + o_); ; )))(((` ~---~ `:: \ %%~~)(v;(`('~ + ; ''''```` `: `:::|\,__,%% );`'; ~ + | _ ) / `:|`----' `-' + ______/\/~ | / / + /~;;.____/;;' / ___--,-( `;;;/ + / // _;______;'------~~~~~ /;;/\ / + // | | / ; \;;,\ + (<_ | ; /',/-----' _> + \_| ||_ //~;~~~~~~~~~ + `\_| (,~~ + \~\ + ~~ + */ +}); +``` + + +## API + +The methods returns a promise that resolves when the `end` event fires on the stream, indicating that there is no more data to be read. The stream is switched to flowing mode. + +### getStream(stream, [options]) + +Get the `stream` as a string. + +#### options + +##### encoding + +Type: `string`<br> +Default: `utf8` + +[Encoding](https://nodejs.org/api/buffer.html#buffer_buffer) of the incoming stream. + +##### maxBuffer + +Type: `number`<br> +Default: `Infinity` + +Maximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected. + +### getStream.buffer(stream, [options]) + +Get the `stream` as a buffer. + +It honors the `maxBuffer` option as above, but it refers to byte length rather than string length. + +### getStream.array(stream, [options]) + +Get the `stream` as an array of values. + +It honors both the `maxBuffer` and `encoding` options. The behavior changes slightly based on the encoding chosen: + +- When `encoding` is unset, it assumes an [object mode stream](https://nodesource.com/blog/understanding-object-streams/) and collects values emitted from `stream` unmodified. In this case `maxBuffer` refers to the number of items in the array (not the sum of their sizes). + +- When `encoding` is set to `buffer`, it collects an array of buffers. `maxBuffer` refers to the summed byte lengths of every buffer in the array. + +- When `encoding` is set to anything else, it collects an array of strings. `maxBuffer` refers to the summed character lengths of every string in the array. + + +## Errors + +If the input stream emits an `error` event, the promise will be rejected with the error. The buffered data will be attached to the `bufferedData` property of the error. + +```js +getStream(streamThatErrorsAtTheEnd('unicorn')) + .catch(err => { + console.log(err.bufferedData); + //=> 'unicorn' + }); +``` + + +## FAQ + +### How is this different from [`concat-stream`](https://github.com/maxogden/concat-stream)? + +This module accepts a stream instead of being one and returns a promise instead of using a callback. The API is simpler and it only supports returning a string, buffer, or array. It doesn't have a fragile type inference. You explicitly choose what you want. And it doesn't depend on the huge `readable-stream` package. + + +## Related + +- [get-stdin](https://github.com/sindresorhus/get-stdin) - Get stdin as a string or buffer + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/node_modules/got/node_modules/pify/index.js b/node_modules/download/node_modules/got/node_modules/pify/index.js new file mode 100644 index 0000000..1dee43a --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/pify/index.js @@ -0,0 +1,84 @@ +'use strict'; + +const processFn = (fn, opts) => function () { + const P = opts.promiseModule; + const args = new Array(arguments.length); + + for (let i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + + return new P((resolve, reject) => { + if (opts.errorFirst) { + args.push(function (err, result) { + if (opts.multiArgs) { + const results = new Array(arguments.length - 1); + + for (let i = 1; i < arguments.length; i++) { + results[i - 1] = arguments[i]; + } + + if (err) { + results.unshift(err); + reject(results); + } else { + resolve(results); + } + } else if (err) { + reject(err); + } else { + resolve(result); + } + }); + } else { + args.push(function (result) { + if (opts.multiArgs) { + const results = new Array(arguments.length - 1); + + for (let i = 0; i < arguments.length; i++) { + results[i] = arguments[i]; + } + + resolve(results); + } else { + resolve(result); + } + }); + } + + fn.apply(this, args); + }); +}; + +module.exports = (obj, opts) => { + opts = Object.assign({ + exclude: [/.+(Sync|Stream)$/], + errorFirst: true, + promiseModule: Promise + }, opts); + + const filter = key => { + const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key); + return opts.include ? opts.include.some(match) : !opts.exclude.some(match); + }; + + let ret; + if (typeof obj === 'function') { + ret = function () { + if (opts.excludeMain) { + return obj.apply(this, arguments); + } + + return processFn(obj, opts).apply(this, arguments); + }; + } else { + ret = Object.create(Object.getPrototypeOf(obj)); + } + + for (const key in obj) { // eslint-disable-line guard-for-in + const x = obj[key]; + ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x; + } + + return ret; +}; diff --git a/node_modules/download/node_modules/got/node_modules/pify/license b/node_modules/download/node_modules/got/node_modules/pify/license new file mode 100644 index 0000000..e7af2f7 --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/pify/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/download/node_modules/got/node_modules/pify/package.json b/node_modules/download/node_modules/got/node_modules/pify/package.json new file mode 100644 index 0000000..468d857 --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/pify/package.json @@ -0,0 +1,51 @@ +{ + "name": "pify", + "version": "3.0.0", + "description": "Promisify a callback-style function", + "license": "MIT", + "repository": "sindresorhus/pify", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava && npm run optimization-test", + "optimization-test": "node --allow-natives-syntax optimization-test.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "promise", + "promises", + "promisify", + "all", + "denodify", + "denodeify", + "callback", + "cb", + "node", + "then", + "thenify", + "convert", + "transform", + "wrap", + "wrapper", + "bind", + "to", + "async", + "await", + "es2015", + "bluebird" + ], + "devDependencies": { + "ava": "*", + "pinkie-promise": "^2.0.0", + "v8-natives": "^1.0.0", + "xo": "*" + } +} diff --git a/node_modules/download/node_modules/got/node_modules/pify/readme.md b/node_modules/download/node_modules/got/node_modules/pify/readme.md new file mode 100644 index 0000000..376ca4e --- /dev/null +++ b/node_modules/download/node_modules/got/node_modules/pify/readme.md @@ -0,0 +1,131 @@ +# pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify) + +> Promisify a callback-style function + + +## Install + +``` +$ npm install --save pify +``` + + +## Usage + +```js +const fs = require('fs'); +const pify = require('pify'); + +// Promisify a single function +pify(fs.readFile)('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); + +// Promisify all methods in a module +pify(fs).readFile('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); +``` + + +## API + +### pify(input, [options]) + +Returns a `Promise` wrapped version of the supplied function or module. + +#### input + +Type: `Function` `Object` + +Callback-style function or module whose methods you want to promisify. + +#### options + +##### multiArgs + +Type: `boolean`<br> +Default: `false` + +By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. This also applies to rejections, where it returns an array of all the callback arguments, including the error. + +```js +const request = require('request'); +const pify = require('pify'); + +pify(request, {multiArgs: true})('https://sindresorhus.com').then(result => { + const [httpResponse, body] = result; +}); +``` + +##### include + +Type: `string[]` `RegExp[]` + +Methods in a module to promisify. Remaining methods will be left untouched. + +##### exclude + +Type: `string[]` `RegExp[]`<br> +Default: `[/.+(Sync|Stream)$/]` + +Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default. + +##### excludeMain + +Type: `boolean`<br> +Default: `false` + +If given module is a function itself, it will be promisified. Turn this option on if you want to promisify only methods of the module. + +```js +const pify = require('pify'); + +function fn() { + return true; +} + +fn.method = (data, callback) => { + setImmediate(() => { + callback(null, data); + }); +}; + +// Promisify methods but not `fn()` +const promiseFn = pify(fn, {excludeMain: true}); + +if (promiseFn()) { + promiseFn.method('hi').then(data => { + console.log(data); + }); +} +``` + +##### errorFirst + +Type: `boolean`<br> +Default: `true` + +Whether the callback has an error as the first argument. You'll want to set this to `false` if you're dealing with an API that doesn't have an error as the first argument, like `fs.exists()`, some browser APIs, Chrome Extension APIs, etc. + +##### promiseModule + +Type: `Function` + +Custom promise module to use instead of the native one. + +Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill. + + +## Related + +- [p-event](https://github.com/sindresorhus/p-event) - Promisify an event by waiting for it to be emitted +- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently +- [More…](https://github.com/sindresorhus/promise-fun) + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/node_modules/got/package.json b/node_modules/download/node_modules/got/package.json new file mode 100644 index 0000000..78f94a8 --- /dev/null +++ b/node_modules/download/node_modules/got/package.json @@ -0,0 +1,95 @@ +{ + "name": "got", + "version": "8.3.2", + "description": "Simplified HTTP requests", + "license": "MIT", + "repository": "sindresorhus/got", + "maintainers": [ + { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + { + "name": "Vsevolod Strukchinsky", + "email": "floatdrop@gmail.com", + "url": "github.com/floatdrop" + }, + { + "name": "Alexander Tesfamichael", + "email": "alex.tesfamichael@gmail.com", + "url": "alextes.me" + } + ], + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && nyc ava", + "coveralls": "nyc report --reporter=text-lcov | coveralls" + }, + "files": [ + "index.js", + "errors.js" + ], + "keywords": [ + "http", + "https", + "get", + "got", + "url", + "uri", + "request", + "util", + "utility", + "simple", + "curl", + "wget", + "fetch", + "net", + "network", + "electron" + ], + "dependencies": { + "@sindresorhus/is": "^0.7.0", + "cacheable-request": "^2.1.1", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "into-stream": "^3.1.0", + "is-retry-allowed": "^1.1.0", + "isurl": "^1.0.0-alpha5", + "lowercase-keys": "^1.0.0", + "mimic-response": "^1.0.0", + "p-cancelable": "^0.4.0", + "p-timeout": "^2.0.1", + "pify": "^3.0.0", + "safe-buffer": "^5.1.1", + "timed-out": "^4.0.1", + "url-parse-lax": "^3.0.0", + "url-to-options": "^1.0.1" + }, + "devDependencies": { + "ava": "^0.25.0", + "coveralls": "^3.0.0", + "form-data": "^2.1.1", + "get-port": "^3.0.0", + "nyc": "^11.0.2", + "p-event": "^1.3.0", + "pem": "^1.4.4", + "proxyquire": "^1.8.0", + "sinon": "^4.0.0", + "slow-stream": "0.0.4", + "tempfile": "^2.0.0", + "tempy": "^0.2.1", + "universal-url": "1.0.0-alpha", + "xo": "^0.20.0" + }, + "ava": { + "concurrency": 4 + }, + "browser": { + "decompress-response": false, + "electron": false + } +} diff --git a/node_modules/download/node_modules/got/readme.md b/node_modules/download/node_modules/got/readme.md new file mode 100644 index 0000000..2347077 --- /dev/null +++ b/node_modules/download/node_modules/got/readme.md @@ -0,0 +1,650 @@ +<div align="center"> + <br> + <br> + <img width="360" src="media/logo.svg" alt="Got"> + <br> + <br> + <br> + <p align="center">Huge thanks to <a href="https://moxy.studio"><img src="https://sindresorhus.com/assets/thanks/moxy-logo.svg" width="150"></a> for sponsoring me! + </p> + <br> + <br> +</div> + +> Simplified HTTP requests + +[![Build Status](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/got/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/got?branch=master) [![Downloads](https://img.shields.io/npm/dm/got.svg)](https://npmjs.com/got) + +A nicer interface to the built-in [`http`](http://nodejs.org/api/http.html) module. + +Created because [`request`](https://github.com/request/request) is bloated *(several megabytes!)*. + + +## Highlights + +- [Promise & stream API](#api) +- [Request cancelation](#aborting-the-request) +- [RFC compliant caching](#cache-adapters) +- [Follows redirects](#followredirect) +- [Retries on network failure](#retries) +- [Progress events](#onuploadprogress-progress) +- [Handles gzip/deflate](#decompress) +- [Timeout handling](#timeout) +- [Errors with metadata](#errors) +- [JSON mode](#json) +- [WHATWG URL support](#url) +- [Electron support](#useelectronnet) + + +## Install + +``` +$ npm install got +``` + +<a href="https://www.patreon.com/sindresorhus"> + <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160"> +</a> + + +## Usage + +```js +const got = require('got'); + +(async () => { + try { + const response = await got('sindresorhus.com'); + console.log(response.body); + //=> '<!doctype html> ...' + } catch (error) { + console.log(error.response.body); + //=> 'Internal server error ...' + } +})(); +``` + +###### Streams + +```js +const fs = require('fs'); +const got = require('got'); + +got.stream('sindresorhus.com').pipe(fs.createWriteStream('index.html')); + +// For POST, PUT, and PATCH methods `got.stream` returns a `stream.Writable` +fs.createReadStream('index.html').pipe(got.stream.post('sindresorhus.com')); +``` + + +### API + +It's a `GET` request by default, but can be changed by using different methods or in the `options`. + +#### got(url, [options]) + +Returns a Promise for a `response` object with a `body` property, a `url` property with the request URL or the final URL after redirects, and a `requestUrl` property with the original request URL. + +The response object will normally be a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage), however if returned from the cache it will be a [responselike object](https://github.com/lukechilds/responselike) which behaves in the same way. + +The response will also have a `fromCache` property set with a boolean value. + +##### url + +Type: `string` `Object` + +The URL to request as simple string, a [`http.request` options](https://nodejs.org/api/http.html#http_http_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url). + +Properties from `options` will override properties in the parsed `url`. + +If no protocol is specified, it will default to `https`. + +##### options + +Type: `Object` + +Any of the [`http.request`](http://nodejs.org/api/http.html#http_http_request_options_callback) options. + +###### stream + +Type: `boolean`<br> +Default: `false` + +Returns a `Stream` instead of a `Promise`. This is equivalent to calling `got.stream(url, [options])`. + +###### body + +Type: `string` `Buffer` `stream.Readable` + +*This is mutually exclusive with stream mode.* + +Body that will be sent with a `POST` request. + +If present in `options` and `options.method` is not set, `options.method` will be set to `POST`. + +If `content-length` or `transfer-encoding` is not set in `options.headers` and `body` is a string or buffer, `content-length` will be set to the body length. + +###### encoding + +Type: `string` `null`<br> +Default: `'utf8'` + +[Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data. If `null`, the body is returned as a [`Buffer`](https://nodejs.org/api/buffer.html) (binary data). + +###### form + +Type: `boolean`<br> +Default: `false` + +*This is mutually exclusive with stream mode.* + +If set to `true` and `Content-Type` header is not set, it will be set to `application/x-www-form-urlencoded`. + +`body` must be a plain object or array and will be stringified. + +###### json + +Type: `boolean`<br> +Default: `false` + +*This is mutually exclusive with stream mode.* + +If set to `true` and `Content-Type` header is not set, it will be set to `application/json`. + +Parse response body with `JSON.parse` and set `accept` header to `application/json`. If used in conjunction with the `form` option, the `body` will the stringified as querystring and the response parsed as JSON. + +`body` must be a plain object or array and will be stringified. + +###### query + +Type: `string` `Object`<br> + +Query string object that will be added to the request URL. This will override the query string in `url`. + +###### timeout + +Type: `number` `Object` + +Milliseconds to wait for the server to end the response before aborting request with `ETIMEDOUT` error. + +This also accepts an object with separate `connect`, `socket`, and `request` fields for connection, socket, and entire request timeouts. + +###### retries + +Type: `number` `Function`<br> +Default: `2` + +Number of request retries when network errors happens. Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.random() * 100`, where `retry` is attempt number (starts from 0). + +Option accepts `function` with `retry` and `error` arguments. Function must return delay in milliseconds (`0` return value cancels retry). + +**Note:** if `retries` is `number`, `ENOTFOUND` and `ENETUNREACH` error will not be retried (see full list in [`is-retry-allowed`](https://github.com/floatdrop/is-retry-allowed/blob/master/index.js#L12) module). + +###### followRedirect + +Type: `boolean`<br> +Default: `true` + +Defines if redirect responses should be followed automatically. + +Note that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), got will automatically +request the resource pointed to in the location header via `GET`. This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4). + +###### decompress + +Type: `boolean`<br> +Default: `true` + +Decompress the response automatically. This will set the `accept-encoding` header to `gzip, deflate` unless you set it yourself. + +If this is disabled, a compressed response is returned as a `Buffer`. This may be useful if you want to handle decompression yourself or stream the raw compressed data. + +###### cache + +Type: `Object`<br> +Default: `false` + +[Cache adapter instance](#cache-adapters) for storing cached data. + +###### useElectronNet + +Type: `boolean`<br> +Default: `false` + +When used in Electron, Got will use [`electron.net`](https://electronjs.org/docs/api/net/) instead of the Node.js `http` module. According to the Electron docs, it should be fully compatible, but it's not entirely. See [#315](https://github.com/sindresorhus/got/issues/315). + +###### throwHttpErrors + +Type: `boolean`<br> +Default: `true` + +Determines if a `got.HTTPError` is thrown for error responses (non-2xx status codes). + +If this is disabled, requests that encounter an error status code will be resolved with the `response` instead of throwing. This may be useful if you are checking for resource availability and are expecting error responses. + +#### Streams + +#### got.stream(url, [options]) + +`stream` method will return Duplex stream with additional events: + +##### .on('request', request) + +`request` event to get the request object of the request. + +**Tip**: You can use `request` event to abort request: + +```js +got.stream('github.com') + .on('request', req => setTimeout(() => req.abort(), 50)); +``` + +##### .on('response', response) + +`response` event to get the response object of the final request. + +##### .on('redirect', response, nextOptions) + +`redirect` event to get the response object of a redirect. The second argument is options for the next request to the redirect location. + +##### .on('uploadProgress', progress) +##### .on('downloadProgress', progress) + +Progress events for uploading (sending request) and downloading (receiving response). The `progress` argument is an object like: + +```js +{ + percent: 0.1, + transferred: 1024, + total: 10240 +} +``` + +If it's not possible to retrieve the body size (can happen when streaming), `total` will be `null`. + +**Note**: Progress events can also be used with promises. + +```js +(async () => { + const response = await got('sindresorhus.com') + .on('downloadProgress', progress => { + // Report download progress + }) + .on('uploadProgress', progress => { + // Report upload progress + }); + + console.log(response); +})(); +``` + +##### .on('error', error, body, response) + +`error` event emitted in case of protocol error (like `ENOTFOUND` etc.) or status error (4xx or 5xx). The second argument is the body of the server response in case of status error. The third argument is response object. + +#### got.get(url, [options]) +#### got.post(url, [options]) +#### got.put(url, [options]) +#### got.patch(url, [options]) +#### got.head(url, [options]) +#### got.delete(url, [options]) + +Sets `options.method` to the method name and makes a request. + + +## Errors + +Each error contains (if available) `statusCode`, `statusMessage`, `host`, `hostname`, `method`, `path`, `protocol` and `url` properties to make debugging easier. + +In Promise mode, the `response` is attached to the error. + +#### got.CacheError + +When a cache method fails, for example if the database goes down, or there's a filesystem error. + +#### got.RequestError + +When a request fails. Contains a `code` property with error class code, like `ECONNREFUSED`. + +#### got.ReadError + +When reading from response stream fails. + +#### got.ParseError + +When `json` option is enabled, server response code is 2xx, and `JSON.parse` fails. + +#### got.HTTPError + +When server response code is not 2xx. Includes `statusCode`, `statusMessage`, and `redirectUrls` properties. + +#### got.MaxRedirectsError + +When server redirects you more than 10 times. Includes a `redirectUrls` property, which is an array of the URLs Got was redirected to before giving up. + +#### got.UnsupportedProtocolError + +When given an unsupported protocol. + +#### got.CancelError + +When the request is aborted with `.cancel()`. + + +## Aborting the request + +The promise returned by Got has a [`.cancel()`](https://github.com/sindresorhus/p-cancelable) method which, when called, aborts the request. + +```js +(async () => { + const request = got(url, options); + + … + + // In another part of the code + if (something) { + request.cancel(); + } + + … + + try { + await request; + } catch (error) { + if (request.isCanceled) { // Or `error instanceof got.CancelError` + // Handle cancelation + } + + // Handle other errors + } +})(); +``` + +<a name="cache-adapters"></a> +## Cache + +Got implements [RFC 7234](http://httpwg.org/specs/rfc7234.html) compliant HTTP caching which works out of the box in memory or is easily pluggable with a wide range of storage adapters. Fresh cache entries are served directly from cache and stale cache entries are revalidated with `If-None-Match`/`If-Modified-Since` headers. You can read more about the underlying cache behaviour in the `cacheable-request` [documentation](https://github.com/lukechilds/cacheable-request). + +You can use the JavaScript `Map` type as an in memory cache: + +```js +const got = require('got'); +const map = new Map(); + +(async () => { + let response = await got('sindresorhus.com', {cache: map}); + console.log(response.fromCache); + //=> false + + response = await got('sindresorhus.com', {cache: map}); + console.log(response.fromCache); + //=> true +})(); +``` + +Got uses [Keyv](https://github.com/lukechilds/keyv) internally to support a wide range of storage adapters. For something more scalable you could use an [official Keyv storage adapter](https://github.com/lukechilds/keyv#official-storage-adapters): + +``` +$ npm install @keyv/redis +``` + +```js +const got = require('got'); +const KeyvRedis = require('@keyv/redis'); + +const redis = new KeyvRedis('redis://user:pass@localhost:6379'); + +got('sindresorhus.com', {cache: redis}); +``` + +Got supports anything that follows the Map API, so it's easy to write your own storage adapter or use a third-party solution. + +For example, the following are all valid storage adapters: + +```js +const storageAdapter = new Map(); +// or +const storageAdapter = require('./my-storage-adapter'); +// or +const QuickLRU = require('quick-lru'); +const storageAdapter = new QuickLRU({maxSize: 1000}); + +got('sindresorhus.com', {cache: storageAdapter}); +``` + +View the [Keyv docs](https://github.com/lukechilds/keyv) for more information on how to use storage adapters. + + +## Proxies + +You can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the `agent` option to work with proxies: + +```js +const got = require('got'); +const tunnel = require('tunnel'); + +got('sindresorhus.com', { + agent: tunnel.httpOverHttp({ + proxy: { + host: 'localhost' + } + }) +}); +``` + +If you require different agents for different protocols, you can pass a map of agents to the `agent` option. This is necessary because a request to one protocol might redirect to another. In such a scenario, `got` will switch over to the right protocol agent for you. + +```js +const got = require('got'); +const HttpAgent = require('agentkeepalive'); +const HttpsAgent = HttpAgent.HttpsAgent; + +got('sindresorhus.com', { + agent: { + http: new HttpAgent(), + https: new HttpsAgent() + } +}); +``` + + +## Cookies + +You can use the [`cookie`](https://github.com/jshttp/cookie) module to include cookies in a request: + +```js +const got = require('got'); +const cookie = require('cookie'); + +got('google.com', { + headers: { + cookie: cookie.serialize('foo', 'bar') + } +}); +``` + + +## Form data + +You can use the [`form-data`](https://github.com/form-data/form-data) module to create POST request with form data: + +```js +const fs = require('fs'); +const got = require('got'); +const FormData = require('form-data'); +const form = new FormData(); + +form.append('my_file', fs.createReadStream('/foo/bar.jpg')); + +got.post('google.com', { + body: form +}); +``` + + +## OAuth + +You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create a signed OAuth request: + +```js +const got = require('got'); +const crypto = require('crypto'); +const OAuth = require('oauth-1.0a'); + +const oauth = OAuth({ + consumer: { + key: process.env.CONSUMER_KEY, + secret: process.env.CONSUMER_SECRET + }, + signature_method: 'HMAC-SHA1', + hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64') +}); + +const token = { + key: process.env.ACCESS_TOKEN, + secret: process.env.ACCESS_TOKEN_SECRET +}; + +const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json'; + +got(url, { + headers: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)), + json: true +}); +``` + + +## Unix Domain Sockets + +Requests can also be sent via [unix domain sockets](http://serverfault.com/questions/124517/whats-the-difference-between-unix-socket-and-tcp-ip-socket). Use the following URL scheme: `PROTOCOL://unix:SOCKET:PATH`. + +- `PROTOCOL` - `http` or `https` *(optional)* +- `SOCKET` - absolute path to a unix domain socket, e.g. `/var/run/docker.sock` +- `PATH` - request path, e.g. `/v2/keys` + +```js +got('http://unix:/var/run/docker.sock:/containers/json'); + +// or without protocol (http by default) +got('unix:/var/run/docker.sock:/containers/json'); +``` + +## AWS + +Requests to AWS services need to have their headers signed. This can be accomplished by using the [`aws4`](https://www.npmjs.com/package/aws4) package. This is an example for querying an ["Elasticsearch Service"](https://aws.amazon.com/elasticsearch-service/) host with a signed request. + +```js +const url = require('url'); +const AWS = require('aws-sdk'); +const aws4 = require('aws4'); +const got = require('got'); +const config = require('./config'); + +// Reads keys from the environment or `~/.aws/credentials`. Could be a plain object. +const awsConfig = new AWS.Config({ region: config.region }); + +function request(uri, options) { + const awsOpts = { + region: awsConfig.region, + headers: { + accept: 'application/json', + 'content-type': 'application/json' + }, + method: 'GET', + json: true + }; + + // We need to parse the URL before passing it to `got` so `aws4` can sign the request + const opts = Object.assign(url.parse(uri), awsOpts, options); + aws4.sign(opts, awsConfig.credentials); + + return got(opts); +} + +request(`https://${config.host}/production/users/1`); + +request(`https://${config.host}/production/`, { + // All usual `got` options +}); +``` + + +## Testing + +You can test your requests by using the [`nock`](https://github.com/node-nock/nock) module to mock an endpoint: + +```js +const got = require('got'); +const nock = require('nock'); + +nock('https://sindresorhus.com') + .get('/') + .reply(200, 'Hello world!'); + +(async () => { + const response = await got('sindresorhus.com'); + console.log(response.body); + //=> 'Hello world!' +})(); +``` + +If you need real integration tests you can use [`create-test-server`](https://github.com/lukechilds/create-test-server): + +```js +const got = require('got'); +const createTestServer = require('create-test-server'); + +(async () => { + const server = await createTestServer(); + server.get('/', 'Hello world!'); + + const response = await got(server.url); + console.log(response.body); + //=> 'Hello world!' + + await server.close(); +})(); +``` + + +## Tips + +### User Agent + +It's a good idea to set the `'user-agent'` header so the provider can more easily see how their resource is used. By default, it's the URL to this repo. + +```js +const got = require('got'); +const pkg = require('./package.json'); + +got('sindresorhus.com', { + headers: { + 'user-agent': `my-module/${pkg.version} (https://github.com/username/my-module)` + } +}); +``` + +### 304 Responses + +Bear in mind, if you send an `if-modified-since` header and receive a `304 Not Modified` response, the body will be empty. It's your responsibility to cache and retrieve the body contents. + + +## Related + +- [gh-got](https://github.com/sindresorhus/gh-got) - Got convenience wrapper to interact with the GitHub API +- [gl-got](https://github.com/singapore/gl-got) - Got convenience wrapper to interact with the GitLab API +- [travis-got](https://github.com/samverschueren/travis-got) - Got convenience wrapper to interact with the Travis API +- [graphql-got](https://github.com/kevva/graphql-got) - Got convenience wrapper to interact with GraphQL +- [GotQL](https://github.com/khaosdoctor/gotql) - Got convenience wrapper to interact with GraphQL using JSON-parsed queries instead of strings + + +## Created by + +[![Sindre Sorhus](https://github.com/sindresorhus.png?size=100)](https://sindresorhus.com) | [![Vsevolod Strukchinsky](https://github.com/floatdrop.png?size=100)](https://github.com/floatdrop) | [![Alexander Tesfamichael](https://github.com/AlexTes.png?size=100)](https://github.com/AlexTes) | [![Luke Childs](https://github.com/lukechilds.png?size=100)](https://github.com/lukechilds) +---|---|---|--- +[Sindre Sorhus](https://sindresorhus.com) | [Vsevolod Strukchinsky](https://github.com/floatdrop) | [Alexander Tesfamichael](https://alextes.me) | [Luke Childs](https://github.com/lukechilds) + + +## License + +MIT diff --git a/node_modules/download/node_modules/http-cache-semantics/README.md b/node_modules/download/node_modules/http-cache-semantics/README.md new file mode 100644 index 0000000..99069fc --- /dev/null +++ b/node_modules/download/node_modules/http-cache-semantics/README.md @@ -0,0 +1,177 @@ +# Can I cache this? [![Build Status](https://travis-ci.org/pornel/http-cache-semantics.svg?branch=master)](https://travis-ci.org/pornel/http-cache-semantics) + +`CachePolicy` tells when responses can be reused from a cache, taking into account [HTTP RFC 7234](http://httpwg.org/specs/rfc7234.html) rules for user agents and shared caches. It's aware of many tricky details such as the `Vary` header, proxy revalidation, and authenticated responses. + +## Usage + +Cacheability of an HTTP response depends on how it was requested, so both `request` and `response` are required to create the policy. + +```js +const policy = new CachePolicy(request, response, options); + +if (!policy.storable()) { + // throw the response away, it's not usable at all + return; +} + +// Cache the data AND the policy object in your cache +// (this is pseudocode, roll your own cache (lru-cache package works)) +letsPretendThisIsSomeCache.set(request.url, {policy, response}, policy.timeToLive()); +``` + +```js +// And later, when you receive a new request: +const {policy, response} = letsPretendThisIsSomeCache.get(newRequest.url); + +// It's not enough that it exists in the cache, it has to match the new request, too: +if (policy && policy.satisfiesWithoutRevalidation(newRequest)) { + // OK, the previous response can be used to respond to the `newRequest`. + // Response headers have to be updated, e.g. to add Age and remove uncacheable headers. + response.headers = policy.responseHeaders(); + return response; +} +``` + +It may be surprising, but it's not enough for an HTTP response to be [fresh](#yo-fresh) to satisfy a request. It may need to match request headers specified in `Vary`. Even a matching fresh response may still not be usable if the new request restricted cacheability, etc. + +The key method is `satisfiesWithoutRevalidation(newRequest)`, which checks whether the `newRequest` is compatible with the original request and whether all caching conditions are met. + +### Constructor options + +Request and response must have a `headers` property with all header names in lower case. `url`, `status` and `method` are optional (defaults are any URL, status `200`, and `GET` method). + +```js +const request = { + url: '/', + method: 'GET', + headers: { + accept: '*/*', + }, +}; + +const response = { + status: 200, + headers: { + 'cache-control': 'public, max-age=7234', + }, +}; + +const options = { + shared: true, + cacheHeuristic: 0.1, + immutableMinTimeToLive: 24*3600*1000, // 24h + ignoreCargoCult: false, +}; +``` + +If `options.shared` is `true` (default), then the response is evaluated from a perspective of a shared cache (i.e. `private` is not cacheable and `s-maxage` is respected). If `options.shared` is `false`, then the response is evaluated from a perspective of a single-user cache (i.e. `private` is cacheable and `s-maxage` is ignored). + +`options.cacheHeuristic` is a fraction of response's age that is used as a fallback cache duration. The default is 0.1 (10%), e.g. if a file hasn't been modified for 100 days, it'll be cached for 100*0.1 = 10 days. + +`options.immutableMinTimeToLive` is a number of milliseconds to assume as the default time to cache responses with `Cache-Control: immutable`. Note that [per RFC](http://httpwg.org/http-extensions/immutable.html) these can become stale, so `max-age` still overrides the default. + +If `options.ignoreCargoCult` is true, common anti-cache directives will be completely ignored if the non-standard `pre-check` and `post-check` directives are present. These two useless directives are most commonly found in bad StackOverflow answers and PHP's "session limiter" defaults. + +### `storable()` + +Returns `true` if the response can be stored in a cache. If it's `false` then you MUST NOT store either the request or the response. + +### `satisfiesWithoutRevalidation(newRequest)` + +This is the most important method. Use this method to check whether the cached response is still fresh in the context of the new request. + +If it returns `true`, then the given `request` matches the original response this cache policy has been created with, and the response can be reused without contacting the server. Note that the old response can't be returned without being updated, see `responseHeaders()`. + +If it returns `false`, then the response may not be matching at all (e.g. it's for a different URL or method), or may require to be refreshed first (see `revalidationHeaders()`). + +### `responseHeaders()` + +Returns updated, filtered set of response headers to return to clients receiving the cached response. This function is necessary, because proxies MUST always remove hop-by-hop headers (such as `TE` and `Connection`) and update response's `Age` to avoid doubling cache time. + +```js +cachedResponse.headers = cachePolicy.responseHeaders(cachedResponse); +``` + +### `timeToLive()` + +Returns approximate time in *milliseconds* until the response becomes stale (i.e. not fresh). + +After that time (when `timeToLive() <= 0`) the response might not be usable without revalidation. However, there are exceptions, e.g. a client can explicitly allow stale responses, so always check with `satisfiesWithoutRevalidation()`. + +### `toObject()`/`fromObject(json)` + +Chances are you'll want to store the `CachePolicy` object along with the cached response. `obj = policy.toObject()` gives a plain JSON-serializable object. `policy = CachePolicy.fromObject(obj)` creates an instance from it. + +### Refreshing stale cache (revalidation) + +When a cached response has expired, it can be made fresh again by making a request to the origin server. The server may respond with status 304 (Not Modified) without sending the response body again, saving bandwidth. + +The following methods help perform the update efficiently and correctly. + +#### `revalidationHeaders(newRequest)` + +Returns updated, filtered set of request headers to send to the origin server to check if the cached response can be reused. These headers allow the origin server to return status 304 indicating the response is still fresh. All headers unrelated to caching are passed through as-is. + +Use this method when updating cache from the origin server. + +```js +updateRequest.headers = cachePolicy.revalidationHeaders(updateRequest); +``` + +#### `revalidatedPolicy(revalidationRequest, revalidationResponse)` + +Use this method to update the cache after receiving a new response from the origin server. It returns an object with two keys: + +* `policy` — A new `CachePolicy` with HTTP headers updated from `revalidationResponse`. You can always replace the old cached `CachePolicy` with the new one. +* `modified` — Boolean indicating whether the response body has changed. + * If `false`, then a valid 304 Not Modified response has been received, and you can reuse the old cached response body. + * If `true`, you should use new response's body (if present), or make another request to the origin server without any conditional headers (i.e. don't use `revalidationHeaders()` this time) to get the new resource. + +```js +// When serving requests from cache: +const {oldPolicy, oldResponse} = letsPretendThisIsSomeCache.get(newRequest.url); + +if (!oldPolicy.satisfiesWithoutRevalidation(newRequest)) { + // Change the request to ask the origin server if the cached response can be used + newRequest.headers = oldPolicy.revalidationHeaders(newRequest); + + // Send request to the origin server. The server may respond with status 304 + const newResponse = await makeRequest(newResponse); + + // Create updated policy and combined response from the old and new data + const {policy, modified} = oldPolicy.revalidatedPolicy(newRequest, newResponse); + const response = modified ? newResponse : oldResponse; + + // Update the cache with the newer/fresher response + letsPretendThisIsSomeCache.set(newRequest.url, {policy, response}, policy.timeToLive()); + + // And proceed returning cached response as usual + response.headers = policy.responseHeaders(); + return response; +} +``` + +# Yo, FRESH + +![satisfiesWithoutRevalidation](fresh.jpg) + +## Used by + +* [ImageOptim API](https://imageoptim.com/api), [make-fetch-happen](https://github.com/zkat/make-fetch-happen), [cacheable-request](https://www.npmjs.com/package/cacheable-request), [npm/registry-fetch](https://github.com/npm/registry-fetch), [etc.](https://github.com/pornel/http-cache-semantics/network/dependents) + +## Implemented + +* `Cache-Control` response header with all the quirks. +* `Expires` with check for bad clocks. +* `Pragma` response header. +* `Age` response header. +* `Vary` response header. +* Default cacheability of statuses and methods. +* Requests for stale data. +* Filtering of hop-by-hop headers. +* Basic revalidation request + +## Unimplemented + +* Merging of range requests, If-Range (but correctly supports them as non-cacheable) +* Revalidation of multiple representations diff --git a/node_modules/download/node_modules/http-cache-semantics/node4/index.js b/node_modules/download/node_modules/http-cache-semantics/node4/index.js new file mode 100644 index 0000000..bcdaebe --- /dev/null +++ b/node_modules/download/node_modules/http-cache-semantics/node4/index.js @@ -0,0 +1,559 @@ +'use strict'; +// rfc7231 6.1 + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var statusCodeCacheableByDefault = [200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501]; + +// This implementation does not understand partial responses (206) +var understoodStatuses = [200, 203, 204, 300, 301, 302, 303, 307, 308, 404, 405, 410, 414, 501]; + +var hopByHopHeaders = { 'connection': true, 'keep-alive': true, 'proxy-authenticate': true, 'proxy-authorization': true, 'te': true, 'trailer': true, 'transfer-encoding': true, 'upgrade': true }; +var excludedFromRevalidationUpdate = { + // Since the old body is reused, it doesn't make sense to change properties of the body + 'content-length': true, 'content-encoding': true, 'transfer-encoding': true, + 'content-range': true +}; + +function parseCacheControl(header) { + var cc = {}; + if (!header) return cc; + + // TODO: When there is more than one value present for a given directive (e.g., two Expires header fields, multiple Cache-Control: max-age directives), + // the directive's value is considered invalid. Caches are encouraged to consider responses that have invalid freshness information to be stale + var parts = header.trim().split(/\s*,\s*/); // TODO: lame parsing + for (var _iterator = parts, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var part = _ref; + + var _part$split = part.split(/\s*=\s*/, 2), + k = _part$split[0], + v = _part$split[1]; + + cc[k] = v === undefined ? true : v.replace(/^"|"$/g, ''); // TODO: lame unquoting + } + + return cc; +} + +function formatCacheControl(cc) { + var parts = []; + for (var k in cc) { + var v = cc[k]; + parts.push(v === true ? k : k + '=' + v); + } + if (!parts.length) { + return undefined; + } + return parts.join(', '); +} + +module.exports = function () { + function CachePolicy(req, res) { + var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + shared = _ref2.shared, + cacheHeuristic = _ref2.cacheHeuristic, + immutableMinTimeToLive = _ref2.immutableMinTimeToLive, + ignoreCargoCult = _ref2.ignoreCargoCult, + _fromObject = _ref2._fromObject; + + _classCallCheck(this, CachePolicy); + + if (_fromObject) { + this._fromObject(_fromObject); + return; + } + + if (!res || !res.headers) { + throw Error("Response headers missing"); + } + this._assertRequestHasHeaders(req); + + this._responseTime = this.now(); + this._isShared = shared !== false; + this._cacheHeuristic = undefined !== cacheHeuristic ? cacheHeuristic : 0.1; // 10% matches IE + this._immutableMinTtl = undefined !== immutableMinTimeToLive ? immutableMinTimeToLive : 24 * 3600 * 1000; + + this._status = 'status' in res ? res.status : 200; + this._resHeaders = res.headers; + this._rescc = parseCacheControl(res.headers['cache-control']); + this._method = 'method' in req ? req.method : 'GET'; + this._url = req.url; + this._host = req.headers.host; + this._noAuthorization = !req.headers.authorization; + this._reqHeaders = res.headers.vary ? req.headers : null; // Don't keep all request headers if they won't be used + this._reqcc = parseCacheControl(req.headers['cache-control']); + + // Assume that if someone uses legacy, non-standard uncecessary options they don't understand caching, + // so there's no point stricly adhering to the blindly copy&pasted directives. + if (ignoreCargoCult && "pre-check" in this._rescc && "post-check" in this._rescc) { + delete this._rescc['pre-check']; + delete this._rescc['post-check']; + delete this._rescc['no-cache']; + delete this._rescc['no-store']; + delete this._rescc['must-revalidate']; + this._resHeaders = Object.assign({}, this._resHeaders, { 'cache-control': formatCacheControl(this._rescc) }); + delete this._resHeaders.expires; + delete this._resHeaders.pragma; + } + + // When the Cache-Control header field is not present in a request, caches MUST consider the no-cache request pragma-directive + // as having the same effect as if "Cache-Control: no-cache" were present (see Section 5.2.1). + if (!res.headers['cache-control'] && /no-cache/.test(res.headers.pragma)) { + this._rescc['no-cache'] = true; + } + } + + CachePolicy.prototype.now = function now() { + return Date.now(); + }; + + CachePolicy.prototype.storable = function storable() { + // The "no-store" request directive indicates that a cache MUST NOT store any part of either this request or any response to it. + return !!(!this._reqcc['no-store'] && ( + // A cache MUST NOT store a response to any request, unless: + // The request method is understood by the cache and defined as being cacheable, and + 'GET' === this._method || 'HEAD' === this._method || 'POST' === this._method && this._hasExplicitExpiration()) && + // the response status code is understood by the cache, and + understoodStatuses.indexOf(this._status) !== -1 && + // the "no-store" cache directive does not appear in request or response header fields, and + !this._rescc['no-store'] && ( + // the "private" response directive does not appear in the response, if the cache is shared, and + !this._isShared || !this._rescc.private) && ( + // the Authorization header field does not appear in the request, if the cache is shared, + !this._isShared || this._noAuthorization || this._allowsStoringAuthenticated()) && ( + // the response either: + + // contains an Expires header field, or + this._resHeaders.expires || + // contains a max-age response directive, or + // contains a s-maxage response directive and the cache is shared, or + // contains a public response directive. + this._rescc.public || this._rescc['max-age'] || this._rescc['s-maxage'] || + // has a status code that is defined as cacheable by default + statusCodeCacheableByDefault.indexOf(this._status) !== -1)); + }; + + CachePolicy.prototype._hasExplicitExpiration = function _hasExplicitExpiration() { + // 4.2.1 Calculating Freshness Lifetime + return this._isShared && this._rescc['s-maxage'] || this._rescc['max-age'] || this._resHeaders.expires; + }; + + CachePolicy.prototype._assertRequestHasHeaders = function _assertRequestHasHeaders(req) { + if (!req || !req.headers) { + throw Error("Request headers missing"); + } + }; + + CachePolicy.prototype.satisfiesWithoutRevalidation = function satisfiesWithoutRevalidation(req) { + this._assertRequestHasHeaders(req); + + // When presented with a request, a cache MUST NOT reuse a stored response, unless: + // the presented request does not contain the no-cache pragma (Section 5.4), nor the no-cache cache directive, + // unless the stored response is successfully validated (Section 4.3), and + var requestCC = parseCacheControl(req.headers['cache-control']); + if (requestCC['no-cache'] || /no-cache/.test(req.headers.pragma)) { + return false; + } + + if (requestCC['max-age'] && this.age() > requestCC['max-age']) { + return false; + } + + if (requestCC['min-fresh'] && this.timeToLive() < 1000 * requestCC['min-fresh']) { + return false; + } + + // the stored response is either: + // fresh, or allowed to be served stale + if (this.stale()) { + var allowsStale = requestCC['max-stale'] && !this._rescc['must-revalidate'] && (true === requestCC['max-stale'] || requestCC['max-stale'] > this.age() - this.maxAge()); + if (!allowsStale) { + return false; + } + } + + return this._requestMatches(req, false); + }; + + CachePolicy.prototype._requestMatches = function _requestMatches(req, allowHeadMethod) { + // The presented effective request URI and that of the stored response match, and + return (!this._url || this._url === req.url) && this._host === req.headers.host && ( + // the request method associated with the stored response allows it to be used for the presented request, and + !req.method || this._method === req.method || allowHeadMethod && 'HEAD' === req.method) && + // selecting header fields nominated by the stored response (if any) match those presented, and + this._varyMatches(req); + }; + + CachePolicy.prototype._allowsStoringAuthenticated = function _allowsStoringAuthenticated() { + // following Cache-Control response directives (Section 5.2.2) have such an effect: must-revalidate, public, and s-maxage. + return this._rescc['must-revalidate'] || this._rescc.public || this._rescc['s-maxage']; + }; + + CachePolicy.prototype._varyMatches = function _varyMatches(req) { + if (!this._resHeaders.vary) { + return true; + } + + // A Vary header field-value of "*" always fails to match + if (this._resHeaders.vary === '*') { + return false; + } + + var fields = this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/); + for (var _iterator2 = fields, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref3; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref3 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref3 = _i2.value; + } + + var name = _ref3; + + if (req.headers[name] !== this._reqHeaders[name]) return false; + } + return true; + }; + + CachePolicy.prototype._copyWithoutHopByHopHeaders = function _copyWithoutHopByHopHeaders(inHeaders) { + var headers = {}; + for (var name in inHeaders) { + if (hopByHopHeaders[name]) continue; + headers[name] = inHeaders[name]; + } + // 9.1. Connection + if (inHeaders.connection) { + var tokens = inHeaders.connection.trim().split(/\s*,\s*/); + for (var _iterator3 = tokens, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { + var _ref4; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref4 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref4 = _i3.value; + } + + var _name = _ref4; + + delete headers[_name]; + } + } + if (headers.warning) { + var warnings = headers.warning.split(/,/).filter(function (warning) { + return !/^\s*1[0-9][0-9]/.test(warning); + }); + if (!warnings.length) { + delete headers.warning; + } else { + headers.warning = warnings.join(',').trim(); + } + } + return headers; + }; + + CachePolicy.prototype.responseHeaders = function responseHeaders() { + var headers = this._copyWithoutHopByHopHeaders(this._resHeaders); + var age = this.age(); + + // A cache SHOULD generate 113 warning if it heuristically chose a freshness + // lifetime greater than 24 hours and the response's age is greater than 24 hours. + if (age > 3600 * 24 && !this._hasExplicitExpiration() && this.maxAge() > 3600 * 24) { + headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"'; + } + headers.age = `${Math.round(age)}`; + return headers; + }; + + /** + * Value of the Date response header or current time if Date was demed invalid + * @return timestamp + */ + + + CachePolicy.prototype.date = function date() { + var dateValue = Date.parse(this._resHeaders.date); + var maxClockDrift = 8 * 3600 * 1000; + if (Number.isNaN(dateValue) || dateValue < this._responseTime - maxClockDrift || dateValue > this._responseTime + maxClockDrift) { + return this._responseTime; + } + return dateValue; + }; + + /** + * Value of the Age header, in seconds, updated for the current time. + * May be fractional. + * + * @return Number + */ + + + CachePolicy.prototype.age = function age() { + var age = Math.max(0, (this._responseTime - this.date()) / 1000); + if (this._resHeaders.age) { + var ageValue = this._ageValue(); + if (ageValue > age) age = ageValue; + } + + var residentTime = (this.now() - this._responseTime) / 1000; + return age + residentTime; + }; + + CachePolicy.prototype._ageValue = function _ageValue() { + var ageValue = parseInt(this._resHeaders.age); + return isFinite(ageValue) ? ageValue : 0; + }; + + /** + * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`. + * + * For an up-to-date value, see `timeToLive()`. + * + * @return Number + */ + + + CachePolicy.prototype.maxAge = function maxAge() { + if (!this.storable() || this._rescc['no-cache']) { + return 0; + } + + // Shared responses with cookies are cacheable according to the RFC, but IMHO it'd be unwise to do so by default + // so this implementation requires explicit opt-in via public header + if (this._isShared && this._resHeaders['set-cookie'] && !this._rescc.public && !this._rescc.immutable) { + return 0; + } + + if (this._resHeaders.vary === '*') { + return 0; + } + + if (this._isShared) { + if (this._rescc['proxy-revalidate']) { + return 0; + } + // if a response includes the s-maxage directive, a shared cache recipient MUST ignore the Expires field. + if (this._rescc['s-maxage']) { + return parseInt(this._rescc['s-maxage'], 10); + } + } + + // If a response includes a Cache-Control field with the max-age directive, a recipient MUST ignore the Expires field. + if (this._rescc['max-age']) { + return parseInt(this._rescc['max-age'], 10); + } + + var defaultMinTtl = this._rescc.immutable ? this._immutableMinTtl : 0; + + var dateValue = this.date(); + if (this._resHeaders.expires) { + var expires = Date.parse(this._resHeaders.expires); + // A cache recipient MUST interpret invalid date formats, especially the value "0", as representing a time in the past (i.e., "already expired"). + if (Number.isNaN(expires) || expires < dateValue) { + return 0; + } + return Math.max(defaultMinTtl, (expires - dateValue) / 1000); + } + + if (this._resHeaders['last-modified']) { + var lastModified = Date.parse(this._resHeaders['last-modified']); + if (isFinite(lastModified) && dateValue > lastModified) { + return Math.max(defaultMinTtl, (dateValue - lastModified) / 1000 * this._cacheHeuristic); + } + } + + return defaultMinTtl; + }; + + CachePolicy.prototype.timeToLive = function timeToLive() { + return Math.max(0, this.maxAge() - this.age()) * 1000; + }; + + CachePolicy.prototype.stale = function stale() { + return this.maxAge() <= this.age(); + }; + + CachePolicy.fromObject = function fromObject(obj) { + return new this(undefined, undefined, { _fromObject: obj }); + }; + + CachePolicy.prototype._fromObject = function _fromObject(obj) { + if (this._responseTime) throw Error("Reinitialized"); + if (!obj || obj.v !== 1) throw Error("Invalid serialization"); + + this._responseTime = obj.t; + this._isShared = obj.sh; + this._cacheHeuristic = obj.ch; + this._immutableMinTtl = obj.imm !== undefined ? obj.imm : 24 * 3600 * 1000; + this._status = obj.st; + this._resHeaders = obj.resh; + this._rescc = obj.rescc; + this._method = obj.m; + this._url = obj.u; + this._host = obj.h; + this._noAuthorization = obj.a; + this._reqHeaders = obj.reqh; + this._reqcc = obj.reqcc; + }; + + CachePolicy.prototype.toObject = function toObject() { + return { + v: 1, + t: this._responseTime, + sh: this._isShared, + ch: this._cacheHeuristic, + imm: this._immutableMinTtl, + st: this._status, + resh: this._resHeaders, + rescc: this._rescc, + m: this._method, + u: this._url, + h: this._host, + a: this._noAuthorization, + reqh: this._reqHeaders, + reqcc: this._reqcc + }; + }; + + /** + * Headers for sending to the origin server to revalidate stale response. + * Allows server to return 304 to allow reuse of the previous response. + * + * Hop by hop headers are always stripped. + * Revalidation headers may be added or removed, depending on request. + */ + + + CachePolicy.prototype.revalidationHeaders = function revalidationHeaders(incomingReq) { + this._assertRequestHasHeaders(incomingReq); + var headers = this._copyWithoutHopByHopHeaders(incomingReq.headers); + + // This implementation does not understand range requests + delete headers['if-range']; + + if (!this._requestMatches(incomingReq, true) || !this.storable()) { + // revalidation allowed via HEAD + // not for the same resource, or wasn't allowed to be cached anyway + delete headers['if-none-match']; + delete headers['if-modified-since']; + return headers; + } + + /* MUST send that entity-tag in any cache validation request (using If-Match or If-None-Match) if an entity-tag has been provided by the origin server. */ + if (this._resHeaders.etag) { + headers['if-none-match'] = headers['if-none-match'] ? `${headers['if-none-match']}, ${this._resHeaders.etag}` : this._resHeaders.etag; + } + + // Clients MAY issue simple (non-subrange) GET requests with either weak validators or strong validators. Clients MUST NOT use weak validators in other forms of request. + var forbidsWeakValidators = headers['accept-ranges'] || headers['if-match'] || headers['if-unmodified-since'] || this._method && this._method != 'GET'; + + /* SHOULD send the Last-Modified value in non-subrange cache validation requests (using If-Modified-Since) if only a Last-Modified value has been provided by the origin server. + Note: This implementation does not understand partial responses (206) */ + if (forbidsWeakValidators) { + delete headers['if-modified-since']; + + if (headers['if-none-match']) { + var etags = headers['if-none-match'].split(/,/).filter(function (etag) { + return !/^\s*W\//.test(etag); + }); + if (!etags.length) { + delete headers['if-none-match']; + } else { + headers['if-none-match'] = etags.join(',').trim(); + } + } + } else if (this._resHeaders['last-modified'] && !headers['if-modified-since']) { + headers['if-modified-since'] = this._resHeaders['last-modified']; + } + + return headers; + }; + + /** + * Creates new CachePolicy with information combined from the previews response, + * and the new revalidation response. + * + * Returns {policy, modified} where modified is a boolean indicating + * whether the response body has been modified, and old cached body can't be used. + * + * @return {Object} {policy: CachePolicy, modified: Boolean} + */ + + + CachePolicy.prototype.revalidatedPolicy = function revalidatedPolicy(request, response) { + this._assertRequestHasHeaders(request); + if (!response || !response.headers) { + throw Error("Response headers missing"); + } + + // These aren't going to be supported exactly, since one CachePolicy object + // doesn't know about all the other cached objects. + var matches = false; + if (response.status !== undefined && response.status != 304) { + matches = false; + } else if (response.headers.etag && !/^\s*W\//.test(response.headers.etag)) { + // "All of the stored responses with the same strong validator are selected. + // If none of the stored responses contain the same strong validator, + // then the cache MUST NOT use the new response to update any stored responses." + matches = this._resHeaders.etag && this._resHeaders.etag.replace(/^\s*W\//, '') === response.headers.etag; + } else if (this._resHeaders.etag && response.headers.etag) { + // "If the new response contains a weak validator and that validator corresponds + // to one of the cache's stored responses, + // then the most recent of those matching stored responses is selected for update." + matches = this._resHeaders.etag.replace(/^\s*W\//, '') === response.headers.etag.replace(/^\s*W\//, ''); + } else if (this._resHeaders['last-modified']) { + matches = this._resHeaders['last-modified'] === response.headers['last-modified']; + } else { + // If the new response does not include any form of validator (such as in the case where + // a client generates an If-Modified-Since request from a source other than the Last-Modified + // response header field), and there is only one stored response, and that stored response also + // lacks a validator, then that stored response is selected for update. + if (!this._resHeaders.etag && !this._resHeaders['last-modified'] && !response.headers.etag && !response.headers['last-modified']) { + matches = true; + } + } + + if (!matches) { + return { + policy: new this.constructor(request, response), + modified: true + }; + } + + // use other header fields provided in the 304 (Not Modified) response to replace all instances + // of the corresponding header fields in the stored response. + var headers = {}; + for (var k in this._resHeaders) { + headers[k] = k in response.headers && !excludedFromRevalidationUpdate[k] ? response.headers[k] : this._resHeaders[k]; + } + + var newResponse = Object.assign({}, response, { + status: this._status, + method: this._method, + headers + }); + return { + policy: new this.constructor(request, newResponse), + modified: false + }; + }; + + return CachePolicy; +}();
\ No newline at end of file diff --git a/node_modules/download/node_modules/http-cache-semantics/package.json b/node_modules/download/node_modules/http-cache-semantics/package.json new file mode 100644 index 0000000..2c96708 --- /dev/null +++ b/node_modules/download/node_modules/http-cache-semantics/package.json @@ -0,0 +1,22 @@ +{ + "name": "http-cache-semantics", + "version": "3.8.1", + "description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies", + "repository": "https://github.com/pornel/http-cache-semantics.git", + "main": "node4/index.js", + "scripts": { + "compile": "babel -d node4/ index.js; babel -d node4/test test", + "prepublish": "npm run compile", + "test": "npm run compile; mocha node4/test" + }, + "files": [ + "node4/index.js" + ], + "author": "Kornel Lesiński <kornel@geekhood.net> (https://kornel.ski/)", + "license": "BSD-2-Clause", + "devDependencies": { + "babel-cli": "^6.24.1", + "babel-preset-env": "^1.6.1", + "mocha": "^3.4.2" + } +} diff --git a/node_modules/download/node_modules/json-buffer/.npmignore b/node_modules/download/node_modules/json-buffer/.npmignore new file mode 100644 index 0000000..13abef4 --- /dev/null +++ b/node_modules/download/node_modules/json-buffer/.npmignore @@ -0,0 +1,3 @@ +node_modules +node_modules/* +npm_debug.log diff --git a/node_modules/download/node_modules/json-buffer/.travis.yml b/node_modules/download/node_modules/json-buffer/.travis.yml new file mode 100644 index 0000000..244b7e8 --- /dev/null +++ b/node_modules/download/node_modules/json-buffer/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - '0.10' diff --git a/node_modules/download/node_modules/json-buffer/LICENSE b/node_modules/download/node_modules/json-buffer/LICENSE new file mode 100644 index 0000000..b799ec0 --- /dev/null +++ b/node_modules/download/node_modules/json-buffer/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2013 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. diff --git a/node_modules/download/node_modules/json-buffer/README.md b/node_modules/download/node_modules/json-buffer/README.md new file mode 100644 index 0000000..43857bb --- /dev/null +++ b/node_modules/download/node_modules/json-buffer/README.md @@ -0,0 +1,24 @@ +# json-buffer + +JSON functions that can convert buffers! + +[![build status](https://secure.travis-ci.org/dominictarr/json-buffer.png)](http://travis-ci.org/dominictarr/json-buffer) + +[![testling badge](https://ci.testling.com/dominictarr/json-buffer.png)](https://ci.testling.com/dominictarr/json-buffer) + +JSON mangles buffers by converting to an array... +which isn't helpful. json-buffers converts to base64 instead, +and deconverts base64 to a buffer. + +``` js +var JSONB = require('json-buffer') +var Buffer = require('buffer').Buffer + +var str = JSONB.stringify(new Buffer('hello there!')) + +console.log(JSONB.parse(str)) //GET a BUFFER back +``` + +## License + +MIT diff --git a/node_modules/download/node_modules/json-buffer/index.js b/node_modules/download/node_modules/json-buffer/index.js new file mode 100644 index 0000000..9cafed8 --- /dev/null +++ b/node_modules/download/node_modules/json-buffer/index.js @@ -0,0 +1,58 @@ +//TODO: handle reviver/dehydrate function like normal +//and handle indentation, like normal. +//if anyone needs this... please send pull request. + +exports.stringify = function stringify (o) { + if('undefined' == typeof o) return o + + if(o && Buffer.isBuffer(o)) + return JSON.stringify(':base64:' + o.toString('base64')) + + if(o && o.toJSON) + o = o.toJSON() + + if(o && 'object' === typeof o) { + var s = '' + var array = Array.isArray(o) + s = array ? '[' : '{' + var first = true + + for(var k in o) { + var ignore = 'function' == typeof o[k] || (!array && 'undefined' === typeof o[k]) + if(Object.hasOwnProperty.call(o, k) && !ignore) { + if(!first) + s += ',' + first = false + if (array) { + if(o[k] == undefined) + s += 'null' + else + s += stringify(o[k]) + } else if (o[k] !== void(0)) { + s += stringify(k) + ':' + stringify(o[k]) + } + } + } + + s += array ? ']' : '}' + + return s + } else if ('string' === typeof o) { + return JSON.stringify(/^:/.test(o) ? ':' + o : o) + } else if ('undefined' === typeof o) { + return 'null'; + } else + return JSON.stringify(o) +} + +exports.parse = function (s) { + return JSON.parse(s, function (key, value) { + if('string' === typeof value) { + if(/^:base64:/.test(value)) + return new Buffer(value.substring(8), 'base64') + else + return /^:/.test(value) ? value.substring(1) : value + } + return value + }) +} diff --git a/node_modules/download/node_modules/json-buffer/package.json b/node_modules/download/node_modules/json-buffer/package.json new file mode 100644 index 0000000..035df50 --- /dev/null +++ b/node_modules/download/node_modules/json-buffer/package.json @@ -0,0 +1,34 @@ +{ + "name": "json-buffer", + "description": "JSON parse & stringify that supports binary via bops & base64", + "version": "3.0.0", + "homepage": "https://github.com/dominictarr/json-buffer", + "repository": { + "type": "git", + "url": "git://github.com/dominictarr/json-buffer.git" + }, + "devDependencies": { + "tape": "^4.6.3" + }, + "scripts": { + "test": "set -e; for t in test/*.js; do node $t; done" + }, + "author": "Dominic Tarr <dominic.tarr@gmail.com> (http://dominictarr.com)", + "license": "MIT", + "testling": { + "files": "test/*.js", + "browsers": [ + "ie/8..latest", + "firefox/17..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + } +} diff --git a/node_modules/download/node_modules/json-buffer/test/index.js b/node_modules/download/node_modules/json-buffer/test/index.js new file mode 100644 index 0000000..8351804 --- /dev/null +++ b/node_modules/download/node_modules/json-buffer/test/index.js @@ -0,0 +1,63 @@ + +var test = require('tape') +var _JSON = require('../') + +function clone (o) { + return JSON.parse(JSON.stringify(o)) +} + +var examples = { + simple: { foo: [], bar: {}, baz: new Buffer('some binary data') }, + just_buffer: new Buffer('JUST A BUFFER'), + all_types: { + string:'hello', + number: 3145, + null: null, + object: {}, + array: [], + boolean: true, + boolean2: false + }, + foo: new Buffer('foo'), + foo2: new Buffer('foo2'), + escape: { + buffer: new Buffer('x'), + string: _JSON.stringify(new Buffer('x')) + }, + escape2: { + buffer: new Buffer('x'), + string: ':base64:'+ new Buffer('x').toString('base64') + }, + undefined: { + empty: undefined, test: true + }, + undefined2: { + first: 1, empty: undefined, test: true + }, + undefinedArray: { + array: [undefined, 1, 'two'] + }, + fn: { + fn: function () {} + }, + undefined: undefined +} + +for(k in examples) +(function (value, k) { + test(k, function (t) { + var s = _JSON.stringify(value) + console.log('parse', s) + if(JSON.stringify(value) !== undefined) { + console.log(s) + var _value = _JSON.parse(s) + t.deepEqual(clone(_value), clone(value)) + } + else + t.equal(s, undefined) + t.end() + }) +})(examples[k], k) + + + diff --git a/node_modules/download/node_modules/keyv/LICENSE b/node_modules/download/node_modules/keyv/LICENSE new file mode 100644 index 0000000..f27ee9b --- /dev/null +++ b/node_modules/download/node_modules/keyv/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Luke Childs + +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. diff --git a/node_modules/download/node_modules/keyv/README.md b/node_modules/download/node_modules/keyv/README.md new file mode 100644 index 0000000..3c6d6d2 --- /dev/null +++ b/node_modules/download/node_modules/keyv/README.md @@ -0,0 +1,243 @@ +<h1 align="center"> + <img width="250" src="https://rawgit.com/lukechilds/keyv/master/media/logo.svg" alt="keyv"> + <br> + <br> +</h1> + +> Simple key-value storage with support for multiple backends + +[![Build Status](https://travis-ci.org/lukechilds/keyv.svg?branch=master)](https://travis-ci.org/lukechilds/keyv) +[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv?branch=master) +[![npm](https://img.shields.io/npm/v/keyv.svg)](https://www.npmjs.com/package/keyv) + +Keyv provides a consistent interface for key-value storage across multiple backends via storage adapters. It supports TTL based expiry, making it suitable as a cache or a persistent key-value store. + +## Features + +There are a few existing modules similar to Keyv, however Keyv is different because it: + +- Isn't bloated +- Has a simple Promise based API +- Suitable as a TTL based cache or persistent key-value store +- [Easily embeddable](#add-cache-support-to-your-module) inside another module +- Works with any storage that implements the [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) API +- Handles all JavaScript types (values can be `Buffer`/`null`/`undefined`) +- Supports namespaces +- Wide range of [**efficient, well tested**](#official-storage-adapters) storage adapters +- Connection errors are passed through (db failures won't kill your app) +- Supports the current active LTS version of Node.js or higher + +## Usage + +Install Keyv. + +``` +npm install --save keyv +``` + +By default everything is stored in memory, you can optionally also install a storage adapter. + +``` +npm install --save @keyv/redis +npm install --save @keyv/mongo +npm install --save @keyv/sqlite +npm install --save @keyv/postgres +npm install --save @keyv/mysql +``` + +Create a new Keyv instance, passing your connection string if applicable. Keyv will automatically load the correct storage adapter. + +```js +const Keyv = require('keyv'); + +// One of the following +const keyv = new Keyv(); +const keyv = new Keyv('redis://user:pass@localhost:6379'); +const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname'); +const keyv = new Keyv('sqlite://path/to/database.sqlite'); +const keyv = new Keyv('postgresql://user:pass@localhost:5432/dbname'); +const keyv = new Keyv('mysql://user:pass@localhost:3306/dbname'); + +// Handle DB connection errors +keyv.on('error' err => console.log('Connection Error', err)); + +await keyv.set('foo', 'expires in 1 second', 1000); // true +await keyv.set('foo', 'never expires'); // true +await keyv.get('foo'); // 'never expires' +await keyv.delete('foo'); // true +await keyv.clear(); // undefined +``` + +### Namespaces + +You can namespace your Keyv instance to avoid key collisions and allow you to clear only a certain namespace while using the same database. + +```js +const users = new Keyv('redis://user:pass@localhost:6379', { namespace: 'users' }); +const cache = new Keyv('redis://user:pass@localhost:6379', { namespace: 'cache' }); + +await users.set('foo', 'users'); // true +await cache.set('foo', 'cache'); // true +await users.get('foo'); // 'users' +await cache.get('foo'); // 'cache' +await users.clear(); // undefined +await users.get('foo'); // undefined +await cache.get('foo'); // 'cache' +``` + +## Official Storage Adapters + +The official storage adapters are covered by [over 150 integration tests](https://travis-ci.org/lukechilds/keyv/jobs/260418145) to guarantee consistent behaviour. They are lightweight, efficient wrappers over the DB clients making use of indexes and native TTLs where available. + +Database | Adapter | Native TTL | Status +---|---|---|--- +Redis | [@keyv/redis](https://github.com/lukechilds/keyv-redis) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-redis.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-redis) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-redis/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-redis?branch=master) +MongoDB | [@keyv/mongo](https://github.com/lukechilds/keyv-mongo) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-mongo.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mongo) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mongo/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mongo?branch=master) +SQLite | [@keyv/sqlite](https://github.com/lukechilds/keyv-sqlite) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-sqlite.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-sqlite) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-sqlite/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-sqlite?branch=master) +PostgreSQL | [@keyv/postgres](https://github.com/lukechilds/keyv-postgres) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-postgres.svg?branch=master)](https://travis-ci.org/lukechildskeyv-postgreskeyv) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-postgres/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-postgres?branch=master) +MySQL | [@keyv/mysql](https://github.com/lukechilds/keyv-mysql) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-mysql.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mysql) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mysql/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mysql?branch=master) + +## Third-party Storage Adapters + +You can also use third-party storage adapters or build your own. Keyv will wrap these storage adapters in TTL functionality and handle complex types internally. + +```js +const Keyv = require('keyv'); +const myAdapter = require('./my-storage-adapter'); + +const keyv = new Keyv({ store: myAdapter }); +``` + +Any store that follows the [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) api will work. + +```js +new Keyv({ store: new Map() }); +``` + +For example, [`quick-lru`](https://github.com/sindresorhus/quick-lru) is a completely unrelated module that implements the Map API. + +```js +const Keyv = require('keyv'); +const QuickLRU = require('quick-lru'); + +const lru = new QuickLRU({ maxSize: 1000 }); +const keyv = new Keyv({ store: lru }); +``` + +## Add Cache Support to your Module + +Keyv is designed to be easily embedded into other modules to add cache support. The recommended pattern is to expose a `cache` option in your modules options which is passed through to Keyv. Caching will work in memory by default and users have the option to also install a Keyv storage adapter and pass in a connection string, or any other storage that implements the `Map` API. + +You should also set a namespace for your module so you can safely call `.clear()` without clearing unrelated app data. + +Inside your module: + +```js +class AwesomeModule { + constructor(opts) { + this.cache = new Keyv({ + uri: typeof opts.cache === 'string' && opts.cache, + store: typeof opts.cache !== 'string' && opts.cache, + namespace: 'awesome-module' + }); + } +} +``` + +Now it can be consumed like this: + +```js +const AwesomeModule = require('awesome-module'); + +// Caches stuff in memory by default +const awesomeModule = new AwesomeModule(); + +// After npm install --save keyv-redis +const awesomeModule = new AwesomeModule({ cache: 'redis://localhost' }); + +// Some third-party module that implements the Map API +const awesomeModule = new AwesomeModule({ cache: some3rdPartyStore }); +``` + +## API + +### new Keyv([uri], [options]) + +Returns a new Keyv instance. + +The Keyv instance is also an `EventEmitter` that will emit an `'error'` event if the storage adapter connection fails. + +### uri + +Type: `String`<br> +Default: `undefined` + +The connection string URI. + +Merged into the options object as options.uri. + +### options + +Type: `Object` + +The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. + +#### options.namespace + +Type: `String`<br> +Default: `'keyv'` + +Namespace for the current instance. + +#### options.ttl + +Type: `Number`<br> +Default: `undefined` + +Default TTL. Can be overridden by specififying a TTL on `.set()`. + +#### options.store + +Type: `Storage adapter instance`<br> +Default: `new Map()` + +The storage adapter instance to be used by Keyv. + +#### options.adapter + +Type: `String`<br> +Default: `undefined` + +Specify an adapter to use. e.g `'redis'` or `'mongodb'`. + +### Instance + +Keys must always be strings. Values can be of any type. + +#### .set(key, value, [ttl]) + +Set a value. + +By default keys are persistent. You can set an expiry TTL in milliseconds. + +Returns `true`. + +#### .get(key) + +Returns the value. + +#### .delete(key) + +Deletes an entry. + +Returns `true` if the key existed, `false` if not. + +#### .clear() + +Delete all entries in the current namespace. + +Returns `undefined`. + +## License + +MIT © Luke Childs diff --git a/node_modules/download/node_modules/keyv/package.json b/node_modules/download/node_modules/keyv/package.json new file mode 100644 index 0000000..3962885 --- /dev/null +++ b/node_modules/download/node_modules/keyv/package.json @@ -0,0 +1,49 @@ +{ + "name": "keyv", + "version": "3.0.0", + "description": "Simple key-value storage with support for multiple backends", + "main": "src/index.js", + "scripts": { + "test": "xo && nyc ava test/keyv.js", + "test:full": "xo && nyc ava --serial", + "coverage": "nyc report --reporter=text-lcov | coveralls" + }, + "xo": { + "extends": "xo-lukechilds" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/lukechilds/keyv.git" + }, + "keywords": [ + "key", + "value", + "store", + "cache", + "ttl" + ], + "author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)", + "license": "MIT", + "bugs": { + "url": "https://github.com/lukechilds/keyv/issues" + }, + "homepage": "https://github.com/lukechilds/keyv", + "dependencies": { + "json-buffer": "3.0.0" + }, + "devDependencies": { + "ava": "^0.22.0", + "coveralls": "^3.0.0", + "eslint-config-xo-lukechilds": "^1.0.0", + "@keyv/mongo": "*", + "@keyv/mysql": "*", + "@keyv/postgres": "*", + "@keyv/redis": "*", + "@keyv/sqlite": "*", + "@keyv/test-suite": "*", + "nyc": "^11.0.3", + "this": "^1.0.2", + "timekeeper": "^2.0.0", + "xo": "^0.19.0" + } +} diff --git a/node_modules/download/node_modules/keyv/src/index.js b/node_modules/download/node_modules/keyv/src/index.js new file mode 100644 index 0000000..ab714b2 --- /dev/null +++ b/node_modules/download/node_modules/keyv/src/index.js @@ -0,0 +1,99 @@ +'use strict'; + +const EventEmitter = require('events'); +const JSONB = require('json-buffer'); + +const loadStore = opts => { + const adapters = { + redis: '@keyv/redis', + mongodb: '@keyv/mongo', + mongo: '@keyv/mongo', + sqlite: '@keyv/sqlite', + postgresql: '@keyv/postgres', + postgres: '@keyv/postgres', + mysql: '@keyv/mysql' + }; + if (opts.adapter || opts.uri) { + const adapter = opts.adapter || /^[^:]*/.exec(opts.uri)[0]; + return new (require(adapters[adapter]))(opts); + } + return new Map(); +}; + +class Keyv extends EventEmitter { + constructor(uri, opts) { + super(); + this.opts = Object.assign( + { namespace: 'keyv' }, + (typeof uri === 'string') ? { uri } : uri, + opts + ); + + if (!this.opts.store) { + const adapterOpts = Object.assign({}, this.opts); + this.opts.store = loadStore(adapterOpts); + } + + if (typeof this.opts.store.on === 'function') { + this.opts.store.on('error', err => this.emit('error', err)); + } + + this.opts.store.namespace = this.opts.namespace; + } + + _getKeyPrefix(key) { + return `${this.opts.namespace}:${key}`; + } + + get(key) { + key = this._getKeyPrefix(key); + const store = this.opts.store; + return Promise.resolve() + .then(() => store.get(key)) + .then(data => { + data = (typeof data === 'string') ? JSONB.parse(data) : data; + if (data === undefined) { + return undefined; + } + if (typeof data.expires === 'number' && Date.now() > data.expires) { + this.delete(key); + return undefined; + } + return data.value; + }); + } + + set(key, value, ttl) { + key = this._getKeyPrefix(key); + if (typeof ttl === 'undefined') { + ttl = this.opts.ttl; + } + if (ttl === 0) { + ttl = undefined; + } + const store = this.opts.store; + + return Promise.resolve() + .then(() => { + const expires = (typeof ttl === 'number') ? (Date.now() + ttl) : null; + value = { value, expires }; + return store.set(key, JSONB.stringify(value), ttl); + }) + .then(() => true); + } + + delete(key) { + key = this._getKeyPrefix(key); + const store = this.opts.store; + return Promise.resolve() + .then(() => store.delete(key)); + } + + clear() { + const store = this.opts.store; + return Promise.resolve() + .then(() => store.clear()); + } +} + +module.exports = Keyv; diff --git a/node_modules/download/node_modules/lowercase-keys/index.js b/node_modules/download/node_modules/lowercase-keys/index.js new file mode 100644 index 0000000..b8d8898 --- /dev/null +++ b/node_modules/download/node_modules/lowercase-keys/index.js @@ -0,0 +1,11 @@ +'use strict'; +module.exports = function (obj) { + var ret = {}; + var keys = Object.keys(Object(obj)); + + for (var i = 0; i < keys.length; i++) { + ret[keys[i].toLowerCase()] = obj[keys[i]]; + } + + return ret; +}; diff --git a/node_modules/download/node_modules/lowercase-keys/license b/node_modules/download/node_modules/lowercase-keys/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/node_modules/download/node_modules/lowercase-keys/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/download/node_modules/lowercase-keys/package.json b/node_modules/download/node_modules/lowercase-keys/package.json new file mode 100644 index 0000000..188af70 --- /dev/null +++ b/node_modules/download/node_modules/lowercase-keys/package.json @@ -0,0 +1,35 @@ +{ + "name": "lowercase-keys", + "version": "1.0.1", + "description": "Lowercase the keys of an object", + "license": "MIT", + "repository": "sindresorhus/lowercase-keys", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "object", + "assign", + "extend", + "properties", + "lowercase", + "lower-case", + "case", + "keys", + "key" + ], + "devDependencies": { + "ava": "*" + } +} diff --git a/node_modules/download/node_modules/lowercase-keys/readme.md b/node_modules/download/node_modules/lowercase-keys/readme.md new file mode 100644 index 0000000..dc65770 --- /dev/null +++ b/node_modules/download/node_modules/lowercase-keys/readme.md @@ -0,0 +1,33 @@ +# lowercase-keys [![Build Status](https://travis-ci.org/sindresorhus/lowercase-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/lowercase-keys) + +> Lowercase the keys of an object + + +## Install + +``` +$ npm install --save lowercase-keys +``` + + +## Usage + +```js +var lowercaseKeys = require('lowercase-keys'); + +lowercaseKeys({FOO: true, bAr: false}); +//=> {foo: true, bar: false} +``` + + +## API + +### lowercaseKeys(object) + +Lowercases the keys and returns a new object. + + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/download/node_modules/normalize-url/index.js b/node_modules/download/node_modules/normalize-url/index.js new file mode 100644 index 0000000..76d150a --- /dev/null +++ b/node_modules/download/node_modules/normalize-url/index.js @@ -0,0 +1,163 @@ +'use strict'; +const url = require('url'); +const punycode = require('punycode'); +const queryString = require('query-string'); +const prependHttp = require('prepend-http'); +const sortKeys = require('sort-keys'); + +const DEFAULT_PORTS = { + 'http:': 80, + 'https:': 443, + 'ftp:': 21 +}; + +// Protocols that always contain a `//`` bit +const slashedProtocol = { + http: true, + https: true, + ftp: true, + gopher: true, + file: true, + 'http:': true, + 'https:': true, + 'ftp:': true, + 'gopher:': true, + 'file:': true +}; + +function testParameter(name, filters) { + return filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name); +} + +module.exports = (str, opts) => { + opts = Object.assign({ + normalizeProtocol: true, + normalizeHttps: false, + stripFragment: true, + stripWWW: true, + removeQueryParameters: [/^utm_\w+/i], + removeTrailingSlash: true, + removeDirectoryIndex: false, + sortQueryParameters: true + }, opts); + + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + + const hasRelativeProtocol = str.startsWith('//'); + + // Prepend protocol + str = prependHttp(str.trim()).replace(/^\/\//, 'http://'); + + const urlObj = url.parse(str); + + if (opts.normalizeHttps && urlObj.protocol === 'https:') { + urlObj.protocol = 'http:'; + } + + if (!urlObj.hostname && !urlObj.pathname) { + throw new Error('Invalid URL'); + } + + // Prevent these from being used by `url.format` + delete urlObj.host; + delete urlObj.query; + + // Remove fragment + if (opts.stripFragment) { + delete urlObj.hash; + } + + // Remove default port + const port = DEFAULT_PORTS[urlObj.protocol]; + if (Number(urlObj.port) === port) { + delete urlObj.port; + } + + // Remove duplicate slashes + if (urlObj.pathname) { + urlObj.pathname = urlObj.pathname.replace(/\/{2,}/g, '/'); + } + + // Decode URI octets + if (urlObj.pathname) { + urlObj.pathname = decodeURI(urlObj.pathname); + } + + // Remove directory index + if (opts.removeDirectoryIndex === true) { + opts.removeDirectoryIndex = [/^index\.[a-z]+$/]; + } + + if (Array.isArray(opts.removeDirectoryIndex) && opts.removeDirectoryIndex.length > 0) { + let pathComponents = urlObj.pathname.split('/'); + const lastComponent = pathComponents[pathComponents.length - 1]; + + if (testParameter(lastComponent, opts.removeDirectoryIndex)) { + pathComponents = pathComponents.slice(0, pathComponents.length - 1); + urlObj.pathname = pathComponents.slice(1).join('/') + '/'; + } + } + + // Resolve relative paths, but only for slashed protocols + if (slashedProtocol[urlObj.protocol]) { + const domain = urlObj.protocol + '//' + urlObj.hostname; + const relative = url.resolve(domain, urlObj.pathname); + urlObj.pathname = relative.replace(domain, ''); + } + + if (urlObj.hostname) { + // IDN to Unicode + urlObj.hostname = punycode.toUnicode(urlObj.hostname).toLowerCase(); + + // Remove trailing dot + urlObj.hostname = urlObj.hostname.replace(/\.$/, ''); + + // Remove `www.` + if (opts.stripWWW) { + urlObj.hostname = urlObj.hostname.replace(/^www\./, ''); + } + } + + // Remove URL with empty query string + if (urlObj.search === '?') { + delete urlObj.search; + } + + const queryParameters = queryString.parse(urlObj.search); + + // Remove query unwanted parameters + if (Array.isArray(opts.removeQueryParameters)) { + for (const key in queryParameters) { + if (testParameter(key, opts.removeQueryParameters)) { + delete queryParameters[key]; + } + } + } + + // Sort query parameters + if (opts.sortQueryParameters) { + urlObj.search = queryString.stringify(sortKeys(queryParameters)); + } + + // Decode query parameters + if (urlObj.search !== null) { + urlObj.search = decodeURIComponent(urlObj.search); + } + + // Take advantage of many of the Node `url` normalizations + str = url.format(urlObj); + + // Remove ending `/` + if (opts.removeTrailingSlash || urlObj.pathname === '/') { + str = str.replace(/\/$/, ''); + } + + // Restore relative protocol, if applicable + if (hasRelativeProtocol && !opts.normalizeProtocol) { + str = str.replace(/^http:\/\//, '//'); + } + + return str; +}; diff --git a/node_modules/download/node_modules/normalize-url/license b/node_modules/download/node_modules/normalize-url/license new file mode 100644 index 0000000..e7af2f7 --- /dev/null +++ b/node_modules/download/node_modules/normalize-url/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/download/node_modules/normalize-url/package.json b/node_modules/download/node_modules/normalize-url/package.json new file mode 100644 index 0000000..c9d834c --- /dev/null +++ b/node_modules/download/node_modules/normalize-url/package.json @@ -0,0 +1,46 @@ +{ + "name": "normalize-url", + "version": "2.0.1", + "description": "Normalize a URL", + "license": "MIT", + "repository": "sindresorhus/normalize-url", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "normalize", + "url", + "uri", + "address", + "string", + "normalization", + "normalisation", + "query", + "querystring", + "unicode", + "simplify", + "strip", + "trim", + "canonical" + ], + "dependencies": { + "prepend-http": "^2.0.0", + "query-string": "^5.0.1", + "sort-keys": "^2.0.0" + }, + "devDependencies": { + "ava": "*", + "xo": "*" + } +} diff --git a/node_modules/download/node_modules/normalize-url/readme.md b/node_modules/download/node_modules/normalize-url/readme.md new file mode 100644 index 0000000..fceee8a --- /dev/null +++ b/node_modules/download/node_modules/normalize-url/readme.md @@ -0,0 +1,172 @@ +# normalize-url [![Build Status](https://travis-ci.org/sindresorhus/normalize-url.svg?branch=master)](https://travis-ci.org/sindresorhus/normalize-url) + +> [Normalize](https://en.wikipedia.org/wiki/URL_normalization) a URL + +Useful when you need to display, store, deduplicate, sort, compare, etc, URLs. + + +## Install + +``` +$ npm install normalize-url +``` + + +## Usage + +```js +const normalizeUrl = require('normalize-url'); + +normalizeUrl('sindresorhus.com'); +//=> 'http://sindresorhus.com' + +normalizeUrl('HTTP://xn--xample-hva.com:80/?b=bar&a=foo'); +//=> 'http://êxample.com/?a=foo&b=bar' +``` + + +## API + +### normalizeUrl(url, [options]) + +#### url + +Type: `string` + +URL to normalize. + +#### options + +Type: `Object` + +##### normalizeProtocol + +Type: `boolean`<br> +Default: `true` + +Prepend `http:` to the URL if it's protocol-relative. + +```js +normalizeUrl('//sindresorhus.com:80/'); +//=> 'http://sindresorhus.com' + +normalizeUrl('//sindresorhus.com:80/', {normalizeProtocol: false}); +//=> '//sindresorhus.com' +``` + +##### normalizeHttps + +Type: `boolean`<br> +Default: `false` + +Normalize `https:` URLs to `http:`. + +```js +normalizeUrl('https://sindresorhus.com:80/'); +//=> 'https://sindresorhus.com' + +normalizeUrl('https://sindresorhus.com:80/', {normalizeHttps: true}); +//=> 'http://sindresorhus.com' +``` + +##### stripFragment + +Type: `boolean`<br> +Default: `true` + +Remove the fragment at the end of the URL. + +```js +normalizeUrl('sindresorhus.com/about.html#contact'); +//=> 'http://sindresorhus.com/about.html' + +normalizeUrl('sindresorhus.com/about.html#contact', {stripFragment: false}); +//=> 'http://sindresorhus.com/about.html#contact' +``` + +##### stripWWW + +Type: `boolean`<br> +Default: `true` + +Remove `www.` from the URL. + +```js +normalizeUrl('http://www.sindresorhus.com/about.html#contact'); +//=> 'http://sindresorhus.com/about.html#contact' + +normalizeUrl('http://www.sindresorhus.com/about.html#contact', {stripWWW: false}); +//=> 'http://www.sindresorhus.com/about.html#contact' +``` + +##### removeQueryParameters + +Type: `Array<RegExp|string>`<br> +Default: `[/^utm_\w+/i]` + +Remove query parameters that matches any of the provided strings or regexes. + +```js +normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', { + removeQueryParameters: ['ref'] +}); +//=> 'http://sindresorhus.com/?foo=bar' +``` + +##### removeTrailingSlash + +Type: `boolean`<br> +Default: `true` + +Remove trailing slash. + +**Note:** Trailing slash is always removed if the URL doesn't have a pathname. + +```js +normalizeUrl('http://sindresorhus.com/redirect/'); +//=> 'http://sindresorhus.com/redirect' + +normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false}); +//=> 'http://sindresorhus.com/redirect/' + +normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false}); +//=> 'http://sindresorhus.com' +``` + +##### removeDirectoryIndex + +Type: `boolean` `Array<RegExp|string>`<br> +Default: `false` + +Remove the default directory index file from path that matches any of the provided strings or regexes. When `true`, the regex `/^index\.[a-z]+$/` is used. + +```js +normalizeUrl('www.sindresorhus.com/foo/default.php', { + removeDirectoryIndex: [/^default\.[a-z]+$/] +}); +//=> 'http://sindresorhus.com/foo' +``` + +##### sortQueryParameters + +Type: `boolean`<br> +Default: `true` + +Sort the query parameters alphabetically by key. + +```js +normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', { + sortQueryParameters: false +}); +//=> 'http://sindresorhus.com/?b=two&a=one&c=three' +``` + + +## Related + +- [compare-urls](https://github.com/sindresorhus/compare-urls) - Compare URLs by first normalizing them + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/node_modules/p-cancelable/index.js b/node_modules/download/node_modules/p-cancelable/index.js new file mode 100644 index 0000000..cdd0cfa --- /dev/null +++ b/node_modules/download/node_modules/p-cancelable/index.js @@ -0,0 +1,88 @@ +'use strict'; + +class CancelError extends Error { + constructor() { + super('Promise was canceled'); + this.name = 'CancelError'; + } + + get isCanceled() { + return true; + } +} + +class PCancelable { + static fn(userFn) { + return function () { + const args = [].slice.apply(arguments); + return new PCancelable((resolve, reject, onCancel) => { + args.push(onCancel); + userFn.apply(null, args).then(resolve, reject); + }); + }; + } + + constructor(executor) { + this._cancelHandlers = []; + this._isPending = true; + this._isCanceled = false; + + this._promise = new Promise((resolve, reject) => { + this._reject = reject; + + return executor( + value => { + this._isPending = false; + resolve(value); + }, + error => { + this._isPending = false; + reject(error); + }, + handler => { + this._cancelHandlers.push(handler); + } + ); + }); + } + + then(onFulfilled, onRejected) { + return this._promise.then(onFulfilled, onRejected); + } + + catch(onRejected) { + return this._promise.catch(onRejected); + } + + finally(onFinally) { + return this._promise.finally(onFinally); + } + + cancel() { + if (!this._isPending || this._isCanceled) { + return; + } + + if (this._cancelHandlers.length > 0) { + try { + for (const handler of this._cancelHandlers) { + handler(); + } + } catch (err) { + this._reject(err); + } + } + + this._isCanceled = true; + this._reject(new CancelError()); + } + + get isCanceled() { + return this._isCanceled; + } +} + +Object.setPrototypeOf(PCancelable.prototype, Promise.prototype); + +module.exports = PCancelable; +module.exports.CancelError = CancelError; diff --git a/node_modules/download/node_modules/p-cancelable/license b/node_modules/download/node_modules/p-cancelable/license new file mode 100644 index 0000000..e7af2f7 --- /dev/null +++ b/node_modules/download/node_modules/p-cancelable/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/download/node_modules/p-cancelable/package.json b/node_modules/download/node_modules/p-cancelable/package.json new file mode 100644 index 0000000..c17dff8 --- /dev/null +++ b/node_modules/download/node_modules/p-cancelable/package.json @@ -0,0 +1,47 @@ +{ + "name": "p-cancelable", + "version": "0.4.1", + "description": "Create a promise that can be canceled", + "license": "MIT", + "repository": "sindresorhus/p-cancelable", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "promise", + "cancelable", + "cancel", + "canceled", + "canceling", + "cancellable", + "cancellation", + "abort", + "abortable", + "aborting", + "cleanup", + "task", + "token", + "async", + "function", + "await", + "promises", + "bluebird" + ], + "devDependencies": { + "ava": "*", + "delay": "^2.0.0", + "promise.prototype.finally": "^3.1.0", + "xo": "*" + } +} diff --git a/node_modules/download/node_modules/p-cancelable/readme.md b/node_modules/download/node_modules/p-cancelable/readme.md new file mode 100644 index 0000000..62ec32e --- /dev/null +++ b/node_modules/download/node_modules/p-cancelable/readme.md @@ -0,0 +1,135 @@ +# p-cancelable [![Build Status](https://travis-ci.org/sindresorhus/p-cancelable.svg?branch=master)](https://travis-ci.org/sindresorhus/p-cancelable) + +> Create a promise that can be canceled + +Useful for animation, loading resources, long-running async computations, async iteration, etc. + + +## Install + +``` +$ npm install p-cancelable +``` + + +## Usage + +```js +const PCancelable = require('p-cancelable'); + +const cancelablePromise = new PCancelable((resolve, reject, onCancel) => { + const worker = new SomeLongRunningOperation(); + + onCancel(() => { + worker.close(); + }); + + worker.on('finish', resolve); + worker.on('error', reject); +}); + +cancelablePromise + .then(value => { + console.log('Operation finished successfully:', value); + }) + .catch(error => { + if (cancelablePromise.isCanceled) { + // Handle the cancelation here + console.log('Operation was canceled'); + return; + } + + throw error; + }); + +// Cancel the operation after 10 seconds +setTimeout(() => { + cancelablePromise.cancel(); +}, 10000); +``` + + +## API + +### new PCancelable(executor) + +Same as the [`Promise` constructor](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), but with an appended `onCancel` parameter in `executor`. + +`PCancelable` is a subclass of `Promise`. + +#### onCanceled(fn) + +Type: `Function` + +Accepts a function that is called when the promise is canceled. + +You're not required to call this function. You can call this function multiple times to add multiple cancel handlers. + +### PCancelable#cancel() + +Type: `Function` + +Cancel the promise. + +The cancellation is synchronous. Calling it after the promise has settled or multiple times does nothing. + +### PCancelable#isCanceled + +Type: `boolean` + +Whether the promise is canceled. + +### PCancelable.CancelError + +Type: `Error` + +Rejection reason when `.cancel()` is called. + +It includes a `.isCanceled` property for convenience. + +### PCancelable.fn(fn) + +Convenience method to make your promise-returning or async function cancelable. + +The function you specify will have `onCancel` appended to its parameters. + +```js +const fn = PCancelable.fn((input, onCancel) => { + const job = new Job(); + + onCancel(() => { + job.cleanup(); + }); + + return job.start(); //=> Promise +}); + +const promise = fn('input'); //=> PCancelable + +// … + +promise.cancel(); +``` + + +## FAQ + +### Cancelable vs. Cancellable + +[In American English, the verb cancel is usually inflected canceled and canceling—with one l.](http://grammarist.com/spelling/cancel/)<br>Both a [browser API](https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable) and the [Cancelable Promises proposal](https://github.com/tc39/proposal-cancelable-promises) use this spelling. + +### What about the official [Cancelable Promises proposal](https://github.com/tc39/proposal-cancelable-promises)? + +~~It's still an early draft and I don't really like its current direction. It complicates everything and will require deep changes in the ecosystem to adapt to it. And the way you have to use cancel tokens is verbose and convoluted. I much prefer the more pragmatic and less invasive approach in this module.~~ The proposal was withdrawn. + + +## Related + +- [p-progress](https://github.com/sindresorhus/p-progress) - Create a promise that reports progress +- [p-lazy](https://github.com/sindresorhus/p-lazy) - Create a lazy promise that defers execution until `.then()` or `.catch()` is called +- [More…](https://github.com/sindresorhus/promise-fun) + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/node_modules/pify/index.js b/node_modules/download/node_modules/pify/index.js new file mode 100644 index 0000000..df56221 --- /dev/null +++ b/node_modules/download/node_modules/pify/index.js @@ -0,0 +1,68 @@ +'use strict'; + +const processFn = (fn, options) => function (...args) { + const P = options.promiseModule; + + return new P((resolve, reject) => { + if (options.multiArgs) { + args.push((...result) => { + if (options.errorFirst) { + if (result[0]) { + reject(result); + } else { + result.shift(); + resolve(result); + } + } else { + resolve(result); + } + }); + } else if (options.errorFirst) { + args.push((error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); + } else { + args.push(resolve); + } + + fn.apply(this, args); + }); +}; + +module.exports = (input, options) => { + options = Object.assign({ + exclude: [/.+(Sync|Stream)$/], + errorFirst: true, + promiseModule: Promise + }, options); + + const objType = typeof input; + if (!(input !== null && (objType === 'object' || objType === 'function'))) { + throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${input === null ? 'null' : objType}\``); + } + + const filter = key => { + const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key); + return options.include ? options.include.some(match) : !options.exclude.some(match); + }; + + let ret; + if (objType === 'function') { + ret = function (...args) { + return options.excludeMain ? input(...args) : processFn(input, options).apply(this, args); + }; + } else { + ret = Object.create(Object.getPrototypeOf(input)); + } + + for (const key in input) { // eslint-disable-line guard-for-in + const property = input[key]; + ret[key] = typeof property === 'function' && filter(key) ? processFn(property, options) : property; + } + + return ret; +}; diff --git a/node_modules/download/node_modules/pify/license b/node_modules/download/node_modules/pify/license new file mode 100644 index 0000000..e7af2f7 --- /dev/null +++ b/node_modules/download/node_modules/pify/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/download/node_modules/pify/package.json b/node_modules/download/node_modules/pify/package.json new file mode 100644 index 0000000..a5468cd --- /dev/null +++ b/node_modules/download/node_modules/pify/package.json @@ -0,0 +1,51 @@ +{ + "name": "pify", + "version": "4.0.1", + "description": "Promisify a callback-style function", + "license": "MIT", + "repository": "sindresorhus/pify", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=6" + }, + "scripts": { + "test": "xo && ava", + "optimization-test": "node --allow-natives-syntax optimization-test.js" + }, + "files": [ + "index.js" + ], + "keywords": [ + "promise", + "promises", + "promisify", + "all", + "denodify", + "denodeify", + "callback", + "cb", + "node", + "then", + "thenify", + "convert", + "transform", + "wrap", + "wrapper", + "bind", + "to", + "async", + "await", + "es2015", + "bluebird" + ], + "devDependencies": { + "ava": "^0.25.0", + "pinkie-promise": "^2.0.0", + "v8-natives": "^1.1.0", + "xo": "^0.23.0" + } +} diff --git a/node_modules/download/node_modules/pify/readme.md b/node_modules/download/node_modules/pify/readme.md new file mode 100644 index 0000000..7ae3f1c --- /dev/null +++ b/node_modules/download/node_modules/pify/readme.md @@ -0,0 +1,145 @@ +# pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify) + +> Promisify a callback-style function + +--- + +<div align="center"> + <b> + <a href="https://tidelift.com/subscription/pkg/npm-pify?utm_source=npm-pify&utm_medium=referral&utm_campaign=readme">Get professional support for 'pify' with a Tidelift subscription</a> + </b> + <br> + <sub> + Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. + </sub> +</div> + +--- + + +## Install + +``` +$ npm install pify +``` + + +## Usage + +```js +const fs = require('fs'); +const pify = require('pify'); + +// Promisify a single function +pify(fs.readFile)('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); + +// Promisify all methods in a module +pify(fs).readFile('package.json', 'utf8').then(data => { + console.log(JSON.parse(data).name); + //=> 'pify' +}); +``` + + +## API + +### pify(input, [options]) + +Returns a `Promise` wrapped version of the supplied function or module. + +#### input + +Type: `Function` `Object` + +Callback-style function or module whose methods you want to promisify. + +#### options + +##### multiArgs + +Type: `boolean`<br> +Default: `false` + +By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. This also applies to rejections, where it returns an array of all the callback arguments, including the error. + +```js +const request = require('request'); +const pify = require('pify'); + +pify(request, {multiArgs: true})('https://sindresorhus.com').then(result => { + const [httpResponse, body] = result; +}); +``` + +##### include + +Type: `string[]` `RegExp[]` + +Methods in a module to promisify. Remaining methods will be left untouched. + +##### exclude + +Type: `string[]` `RegExp[]`<br> +Default: `[/.+(Sync|Stream)$/]` + +Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default. + +##### excludeMain + +Type: `boolean`<br> +Default: `false` + +If given module is a function itself, it will be promisified. Turn this option on if you want to promisify only methods of the module. + +```js +const pify = require('pify'); + +function fn() { + return true; +} + +fn.method = (data, callback) => { + setImmediate(() => { + callback(null, data); + }); +}; + +// Promisify methods but not `fn()` +const promiseFn = pify(fn, {excludeMain: true}); + +if (promiseFn()) { + promiseFn.method('hi').then(data => { + console.log(data); + }); +} +``` + +##### errorFirst + +Type: `boolean`<br> +Default: `true` + +Whether the callback has an error as the first argument. You'll want to set this to `false` if you're dealing with an API that doesn't have an error as the first argument, like `fs.exists()`, some browser APIs, Chrome Extension APIs, etc. + +##### promiseModule + +Type: `Function` + +Custom promise module to use instead of the native one. + +Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill. + + +## Related + +- [p-event](https://github.com/sindresorhus/p-event) - Promisify an event by waiting for it to be emitted +- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently +- [More…](https://github.com/sindresorhus/promise-fun) + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/node_modules/responselike/LICENSE b/node_modules/download/node_modules/responselike/LICENSE new file mode 100644 index 0000000..8829a00 --- /dev/null +++ b/node_modules/download/node_modules/responselike/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2017 Luke Childs + +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. diff --git a/node_modules/download/node_modules/responselike/README.md b/node_modules/download/node_modules/responselike/README.md new file mode 100644 index 0000000..6361931 --- /dev/null +++ b/node_modules/download/node_modules/responselike/README.md @@ -0,0 +1,77 @@ +# responselike + +> A response-like object for mocking a Node.js HTTP response stream + +[![Build Status](https://travis-ci.org/lukechilds/responselike.svg?branch=master)](https://travis-ci.org/lukechilds/responselike) +[![Coverage Status](https://coveralls.io/repos/github/lukechilds/responselike/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/responselike?branch=master) +[![npm](https://img.shields.io/npm/dm/responselike.svg)](https://www.npmjs.com/package/responselike) +[![npm](https://img.shields.io/npm/v/responselike.svg)](https://www.npmjs.com/package/responselike) + +Returns a streamable response object similar to a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage). Useful for formatting cached responses so they can be consumed by code expecting a real response. + +## Install + +```shell +npm install --save responselike +``` + +Or if you're just using for testing you'll want: + +```shell +npm install --save-dev responselike +``` + +## Usage + +```js +const Response = require('responselike'); + +const response = new Response(200, { foo: 'bar' }, Buffer.from('Hi!'), 'https://example.com'); + +response.statusCode; +// 200 +response.headers; +// { foo: 'bar' } +response.body; +// <Buffer 48 69 21> +response.url; +// 'https://example.com' + +response.pipe(process.stdout); +// Hi! +``` + + +## API + +### new Response(statusCode, headers, body, url) + +Returns a streamable response object similar to a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage). + +#### statusCode + +Type: `number` + +HTTP response status code. + +#### headers + +Type: `object` + +HTTP headers object. Keys will be automatically lowercased. + +#### body + +Type: `buffer` + +A Buffer containing the response body. The Buffer contents will be streamable but is also exposed directly as `response.body`. + +#### url + +Type: `string` + +Request URL string. + +## License + +MIT © Luke Childs diff --git a/node_modules/download/node_modules/responselike/package.json b/node_modules/download/node_modules/responselike/package.json new file mode 100644 index 0000000..520c8a1 --- /dev/null +++ b/node_modules/download/node_modules/responselike/package.json @@ -0,0 +1,38 @@ +{ + "name": "responselike", + "version": "1.0.2", + "description": "A response-like object for mocking a Node.js HTTP response stream", + "main": "src/index.js", + "scripts": { + "test": "xo && nyc ava", + "coverage": "nyc report --reporter=text-lcov | coveralls" + }, + "xo": { + "extends": "xo-lukechilds" + }, + "keywords": [ + "http", + "https", + "response", + "mock", + "request", + "responselike" + ], + "repository": { + "type": "git", + "url": "https://github.com/lukechilds/responselike.git" + }, + "author": "lukechilds", + "license": "MIT", + "devDependencies": { + "ava": "^0.22.0", + "coveralls": "^2.13.1", + "eslint-config-xo-lukechilds": "^1.0.0", + "get-stream": "^3.0.0", + "nyc": "^11.1.0", + "xo": "^0.19.0" + }, + "dependencies": { + "lowercase-keys": "^1.0.0" + } +} diff --git a/node_modules/download/node_modules/responselike/src/index.js b/node_modules/download/node_modules/responselike/src/index.js new file mode 100644 index 0000000..b17b481 --- /dev/null +++ b/node_modules/download/node_modules/responselike/src/index.js @@ -0,0 +1,34 @@ +'use strict'; + +const Readable = require('stream').Readable; +const lowercaseKeys = require('lowercase-keys'); + +class Response extends Readable { + constructor(statusCode, headers, body, url) { + if (typeof statusCode !== 'number') { + throw new TypeError('Argument `statusCode` should be a number'); + } + if (typeof headers !== 'object') { + throw new TypeError('Argument `headers` should be an object'); + } + if (!(body instanceof Buffer)) { + throw new TypeError('Argument `body` should be a buffer'); + } + if (typeof url !== 'string') { + throw new TypeError('Argument `url` should be a string'); + } + + super(); + this.statusCode = statusCode; + this.headers = lowercaseKeys(headers); + this.body = body; + this.url = url; + } + + _read() { + this.push(this.body); + this.push(null); + } +} + +module.exports = Response; diff --git a/node_modules/download/node_modules/sort-keys/index.js b/node_modules/download/node_modules/sort-keys/index.js new file mode 100644 index 0000000..53489d7 --- /dev/null +++ b/node_modules/download/node_modules/sort-keys/index.js @@ -0,0 +1,55 @@ +'use strict'; +const isPlainObj = require('is-plain-obj'); + +module.exports = (obj, opts) => { + if (!isPlainObj(obj)) { + throw new TypeError('Expected a plain object'); + } + + opts = opts || {}; + + // DEPRECATED + if (typeof opts === 'function') { + throw new TypeError('Specify the compare function as an option instead'); + } + + const deep = opts.deep; + const seenInput = []; + const seenOutput = []; + + const sortKeys = x => { + const seenIndex = seenInput.indexOf(x); + + if (seenIndex !== -1) { + return seenOutput[seenIndex]; + } + + const ret = {}; + const keys = Object.keys(x).sort(opts.compare); + + seenInput.push(x); + seenOutput.push(ret); + + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const val = x[key]; + + if (deep && Array.isArray(val)) { + const retArr = []; + + for (let j = 0; j < val.length; j++) { + retArr[j] = isPlainObj(val[j]) ? sortKeys(val[j]) : val[j]; + } + + ret[key] = retArr; + continue; + } + + ret[key] = deep && isPlainObj(val) ? sortKeys(val) : val; + } + + return ret; + }; + + return sortKeys(obj); +}; diff --git a/node_modules/download/node_modules/sort-keys/license b/node_modules/download/node_modules/sort-keys/license new file mode 100644 index 0000000..e7af2f7 --- /dev/null +++ b/node_modules/download/node_modules/sort-keys/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/download/node_modules/sort-keys/package.json b/node_modules/download/node_modules/sort-keys/package.json new file mode 100644 index 0000000..3da9c76 --- /dev/null +++ b/node_modules/download/node_modules/sort-keys/package.json @@ -0,0 +1,40 @@ +{ + "name": "sort-keys", + "version": "2.0.0", + "description": "Sort the keys of an object", + "license": "MIT", + "repository": "sindresorhus/sort-keys", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "sort", + "object", + "keys", + "obj", + "key", + "stable", + "deterministic", + "deep", + "recursive", + "recursively" + ], + "dependencies": { + "is-plain-obj": "^1.0.0" + }, + "devDependencies": { + "ava": "*", + "xo": "*" + } +} diff --git a/node_modules/download/node_modules/sort-keys/readme.md b/node_modules/download/node_modules/sort-keys/readme.md new file mode 100644 index 0000000..a671ffb --- /dev/null +++ b/node_modules/download/node_modules/sort-keys/readme.md @@ -0,0 +1,60 @@ +# sort-keys [![Build Status](https://travis-ci.org/sindresorhus/sort-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/sort-keys) + +> Sort the keys of an object + +Useful to get a deterministically ordered object, as the order of keys can vary between engines. + + +## Install + +``` +$ npm install --save sort-keys +``` + + +## Usage + +```js +const sortKeys = require('sort-keys'); + +sortKeys({c: 0, a: 0, b: 0}); +//=> {a: 0, b: 0, c: 0} + +sortKeys({b: {b: 0, a: 0}, a: 0}, {deep: true}); +//=> {a: 0, b: {a: 0, b: 0}} + +sortKeys({c: 0, a: 0, b: 0}, { + compare: (a, b) => -a.localeCompare(b) +}); +//=> {c: 0, b: 0, a: 0} +``` + + +## API + +### sortKeys(input, [options]) + +Returns a new object with sorted keys. + +#### input + +Type: `Object` + +#### options + +##### deep + +Type: `boolean` + +Recursively sort keys. + +##### compare + +Type: `Function` + +[Compare function.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/download/package.json b/node_modules/download/package.json new file mode 100644 index 0000000..0f45447 --- /dev/null +++ b/node_modules/download/package.json @@ -0,0 +1,50 @@ +{ + "name": "download", + "version": "8.0.0", + "description": "Download and extract files", + "license": "MIT", + "repository": "kevva/download", + "author": { + "email": "kevinmartensson@gmail.com", + "name": "Kevin Mårtensson", + "url": "github.com/kevva" + }, + "engines": { + "node": ">=10" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "download", + "extract", + "http", + "request", + "url" + ], + "dependencies": { + "archive-type": "^4.0.0", + "content-disposition": "^0.5.2", + "decompress": "^4.2.1", + "ext-name": "^5.0.0", + "file-type": "^11.1.0", + "filenamify": "^3.0.0", + "get-stream": "^4.1.0", + "got": "^8.3.1", + "make-dir": "^2.1.0", + "p-event": "^2.1.0", + "pify": "^4.0.1" + }, + "devDependencies": { + "ava": "^1.4.1", + "is-zip": "^1.0.0", + "nock": "^10.0.6", + "path-exists": "^3.0.0", + "random-buffer": "^0.1.0", + "rimraf": "^3.0.0", + "xo": "^0.24.0" + } +} diff --git a/node_modules/download/readme.md b/node_modules/download/readme.md new file mode 100644 index 0000000..892470f --- /dev/null +++ b/node_modules/download/readme.md @@ -0,0 +1,75 @@ +# download [![Build Status](https://travis-ci.org/kevva/download.svg?branch=master)](https://travis-ci.org/kevva/download) + +> Download and extract files + +*See [download-cli](https://github.com/kevva/download-cli) for the command-line version.* + + +## Install + +``` +$ npm install download +``` + + +## Usage + +```js +const fs = require('fs'); +const download = require('download'); + +(async () => { + await download('http://unicorn.com/foo.jpg', 'dist'); + + fs.writeFileSync('dist/foo.jpg', await download('http://unicorn.com/foo.jpg')); + + download('unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg')); + + await Promise.all([ + 'unicorn.com/foo.jpg', + 'cats.com/dancing.gif' + ].map(url => download(url, 'dist'))); +})(); +``` + +### Proxies + +To work with proxies, read the [`got documentation`](https://github.com/sindresorhus/got#proxies). + + +## API + +### download(url, destination?, options?) + +Returns both a `Promise<Buffer>` and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with [additional events](https://github.com/sindresorhus/got#streams-1). + +#### url + +Type: `string` + +URL to download. + +#### destination + +Type: `string` + +Path to where your file will be written. + +#### options + +Type: `Object` + +Same options as [`got`](https://github.com/sindresorhus/got#options) and [`decompress`](https://github.com/kevva/decompress#options) in addition to the ones below. + +##### extract + +Type: `boolean`<br> +Default: `false` + +If set to `true`, try extracting the file using [`decompress`](https://github.com/kevva/decompress). + +##### filename + +Type: `string` + +Name of the saved file. |