Cleanup
This commit is contained in:
2
app.js
2
app.js
@@ -9,8 +9,6 @@ const loaders = require("./loaders/index.js");
|
||||
async function startServer() {
|
||||
await loaders({
|
||||
expressApp: app,
|
||||
dbPass: dbPass,
|
||||
secret: cookiesSecret,
|
||||
});
|
||||
app.listen(port, (err) => {
|
||||
if (err) {
|
||||
|
||||
@@ -8,8 +8,6 @@ exports.dbHost = process.env.DB_HOST;
|
||||
exports.dbPort = process.env.DB_PORT;
|
||||
exports.dbName = process.env.DB_NAME;
|
||||
exports.cookiesSecret = process.env.COOKIES_SECRET;
|
||||
exports.jwtSecret = process.env.JWT_SECRET;
|
||||
exports.MAIL_PASS = process.env.MAIL_PASS;
|
||||
exports.s3_key = process.env.S3_KEY;
|
||||
exports.s3_secret = process.env.S3_SECRET;
|
||||
exports.appkey = process.env.APP_KEY
|
||||
exports.appkey = process.env.APP_KEY;
|
||||
|
||||
@@ -8,29 +8,27 @@ const routeUser = require("../routes/routeUser.js");
|
||||
const routeSearch = require("../routes/routeSearch.js");
|
||||
const routeImg = require("../routes/routeImg.js");
|
||||
const routeHealth = require("../routes/routeHealth.js");
|
||||
const routeAdmin = require("../routes/routeAdmin.js")
|
||||
const routeAdmin = require("../routes/routeAdmin.js");
|
||||
|
||||
const loadExpress = ({ app, secret }) => {
|
||||
const loadExpress = ({ app }) => {
|
||||
const limiter = rateLimiter({
|
||||
windowMs: 10 * 60 * 1000, //time window
|
||||
max: 100, //requests = a single IP for a time window
|
||||
});
|
||||
|
||||
app.use(cors({ exposedHeaders: "x-auth-token", origin: true, credentials: true }));
|
||||
app.use(
|
||||
cors({ exposedHeaders: "x-auth-token", origin: true, credentials: true })
|
||||
);
|
||||
app.use(helmet());
|
||||
app.use(limiter);
|
||||
app.use(bodyParser.json({ limit: "100kb" })); // limit JSON body payload size
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(function (err, req, res, next) {
|
||||
if (err) res.sendStatus(422);
|
||||
});
|
||||
app.use("/dish", routeDish);
|
||||
app.use("/restaurant", routeRestaurant);
|
||||
app.use("/img", routeImg);
|
||||
app.use("/user", routeUser);
|
||||
app.use("/search", routeSearch);
|
||||
app.use("/healthcheck", routeHealth);
|
||||
app.use("/00xc232", routeAdmin)
|
||||
|
||||
return app;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const expressLoader = require("./express.js");
|
||||
const mongooseLoader = require("./mongoose.js");
|
||||
|
||||
const loaders = async ({ expressApp, secret }) => {
|
||||
const mongoConnection = await mongooseLoader();
|
||||
console.log("Mongoose Loaded");
|
||||
await expressLoader({ app: expressApp, secret: secret });
|
||||
const loaders = async ({ expressApp }) => {
|
||||
await mongooseLoader();
|
||||
console.log("DB Connection Successful");
|
||||
await expressLoader({ app: expressApp });
|
||||
console.log("Express Initialized");
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
const mongoose = require("mongoose");
|
||||
const {
|
||||
dbPass,
|
||||
dbName,
|
||||
} = require("../config/index.js");
|
||||
const { dbPass, dbName } = require("../config/index.js");
|
||||
|
||||
const loadMongoose = async () => {
|
||||
const connection = await mongoose.connect(
|
||||
@@ -10,11 +7,14 @@ const loadMongoose = async () => {
|
||||
{
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
useFindAndModify: false
|
||||
useFindAndModify: false,
|
||||
},
|
||||
(err) => {
|
||||
if (err) console.log("Unable to connect :(");
|
||||
else console.log("Connected To Database");
|
||||
if (err) {
|
||||
console.log("Unable to connect :(");
|
||||
} else {
|
||||
console.log("DB Connected");
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -104,6 +104,8 @@ const restaurantSchema = mongoose.Schema({
|
||||
maxlength: 24,
|
||||
},
|
||||
hidden: Boolean,
|
||||
subscriptionActive: Boolean,
|
||||
subscriptionDue: Date,
|
||||
indexed: Date,
|
||||
categories: [String],
|
||||
dishes: [mongoose.Types.ObjectId],
|
||||
|
||||
132
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
132
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
@@ -1,132 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference lib="es2016" />
|
||||
/// <reference lib="es2017.sharedmemory" />
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
/// <reference lib="dom" />
|
||||
declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
||||
declare type Primitive = null | undefined | string | number | boolean | Symbol;
|
||||
export interface ArrayLike {
|
||||
length: number;
|
||||
}
|
||||
export interface Class<T = unknown> {
|
||||
new (...args: any[]): T;
|
||||
}
|
||||
declare type DomElement = object & {
|
||||
nodeType: 1;
|
||||
nodeName: string;
|
||||
};
|
||||
declare type NodeStream = object & {
|
||||
pipe: Function;
|
||||
};
|
||||
export declare const enum TypeName {
|
||||
null = "null",
|
||||
boolean = "boolean",
|
||||
undefined = "undefined",
|
||||
string = "string",
|
||||
number = "number",
|
||||
symbol = "symbol",
|
||||
Function = "Function",
|
||||
GeneratorFunction = "GeneratorFunction",
|
||||
AsyncFunction = "AsyncFunction",
|
||||
Observable = "Observable",
|
||||
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",
|
||||
URL = "URL"
|
||||
}
|
||||
declare function is(value: unknown): TypeName;
|
||||
declare namespace is {
|
||||
const undefined: (value: unknown) => value is undefined;
|
||||
const string: (value: unknown) => value is string;
|
||||
const number: (value: unknown) => value is number;
|
||||
const function_: (value: unknown) => value is Function;
|
||||
const null_: (value: unknown) => value is null;
|
||||
const class_: (value: unknown) => value is Class<unknown>;
|
||||
const boolean: (value: unknown) => value is boolean;
|
||||
const symbol: (value: unknown) => value is Symbol;
|
||||
const numericString: (value: unknown) => boolean;
|
||||
const array: (arg: any) => arg is any[];
|
||||
const buffer: (input: unknown) => input is Buffer;
|
||||
const nullOrUndefined: (value: unknown) => value is null | undefined;
|
||||
const object: (value: unknown) => value is object;
|
||||
const iterable: (value: unknown) => value is IterableIterator<unknown>;
|
||||
const asyncIterable: (value: unknown) => value is AsyncIterableIterator<unknown>;
|
||||
const generator: (value: unknown) => value is Generator;
|
||||
const nativePromise: (value: unknown) => value is Promise<unknown>;
|
||||
const promise: (value: unknown) => value is Promise<unknown>;
|
||||
const generatorFunction: (value: unknown) => value is GeneratorFunction;
|
||||
const asyncFunction: (value: unknown) => value is Function;
|
||||
const boundFunction: (value: unknown) => value is Function;
|
||||
const regExp: (value: unknown) => value is RegExp;
|
||||
const date: (value: unknown) => value is Date;
|
||||
const error: (value: unknown) => value is Error;
|
||||
const map: (value: unknown) => value is Map<unknown, unknown>;
|
||||
const set: (value: unknown) => value is Set<unknown>;
|
||||
const weakMap: (value: unknown) => value is WeakMap<object, unknown>;
|
||||
const weakSet: (value: unknown) => value is WeakSet<object>;
|
||||
const int8Array: (value: unknown) => value is Int8Array;
|
||||
const uint8Array: (value: unknown) => value is Uint8Array;
|
||||
const uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
|
||||
const int16Array: (value: unknown) => value is Int16Array;
|
||||
const uint16Array: (value: unknown) => value is Uint16Array;
|
||||
const int32Array: (value: unknown) => value is Int32Array;
|
||||
const uint32Array: (value: unknown) => value is Uint32Array;
|
||||
const float32Array: (value: unknown) => value is Float32Array;
|
||||
const float64Array: (value: unknown) => value is Float64Array;
|
||||
const arrayBuffer: (value: unknown) => value is ArrayBuffer;
|
||||
const sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
|
||||
const dataView: (value: unknown) => value is DataView;
|
||||
const directInstanceOf: <T>(instance: unknown, klass: Class<T>) => instance is T;
|
||||
const urlInstance: (value: unknown) => value is URL;
|
||||
const urlString: (value: unknown) => boolean;
|
||||
const truthy: (value: unknown) => boolean;
|
||||
const falsy: (value: unknown) => boolean;
|
||||
const nan: (value: unknown) => boolean;
|
||||
const primitive: (value: unknown) => value is Primitive;
|
||||
const integer: (value: unknown) => value is number;
|
||||
const safeInteger: (value: unknown) => value is number;
|
||||
const plainObject: (value: unknown) => boolean;
|
||||
const typedArray: (value: unknown) => value is TypedArray;
|
||||
const arrayLike: (value: unknown) => value is ArrayLike;
|
||||
const inRange: (value: number, range: number | number[]) => boolean;
|
||||
const domElement: (value: unknown) => value is DomElement;
|
||||
const observable: (value: unknown) => boolean;
|
||||
const nodeStream: (value: unknown) => value is NodeStream;
|
||||
const infinite: (value: unknown) => boolean;
|
||||
const even: (value: number) => boolean;
|
||||
const odd: (value: number) => boolean;
|
||||
const emptyArray: (value: unknown) => boolean;
|
||||
const nonEmptyArray: (value: unknown) => boolean;
|
||||
const emptyString: (value: unknown) => boolean;
|
||||
const nonEmptyString: (value: unknown) => boolean;
|
||||
const emptyStringOrWhitespace: (value: unknown) => boolean;
|
||||
const emptyObject: (value: unknown) => boolean;
|
||||
const nonEmptyObject: (value: unknown) => boolean;
|
||||
const emptySet: (value: unknown) => boolean;
|
||||
const nonEmptySet: (value: unknown) => boolean;
|
||||
const emptyMap: (value: unknown) => boolean;
|
||||
const nonEmptyMap: (value: unknown) => boolean;
|
||||
const any: (predicate: unknown, ...values: unknown[]) => boolean;
|
||||
const all: (predicate: unknown, ...values: unknown[]) => boolean;
|
||||
}
|
||||
export default is;
|
||||
245
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
245
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
@@ -1,245 +0,0 @@
|
||||
"use strict";
|
||||
/// <reference lib="es2016"/>
|
||||
/// <reference lib="es2017.sharedmemory"/>
|
||||
/// <reference lib="esnext.asynciterable"/>
|
||||
/// <reference lib="dom"/>
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// TODO: Use the `URL` global when targeting Node.js 10
|
||||
// tslint:disable-next-line
|
||||
const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL;
|
||||
const toString = Object.prototype.toString;
|
||||
const isOfType = (type) => (value) => typeof value === type;
|
||||
const isBuffer = (input) => !is.nullOrUndefined(input) && !is.nullOrUndefined(input.constructor) && is.function_(input.constructor.isBuffer) && input.constructor.isBuffer(input);
|
||||
const getObjectType = (value) => {
|
||||
const objectName = toString.call(value).slice(8, -1);
|
||||
if (objectName) {
|
||||
return objectName;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const isObjectOfType = (type) => (value) => getObjectType(value) === type;
|
||||
function is(value) {
|
||||
switch (value) {
|
||||
case null:
|
||||
return "null" /* null */;
|
||||
case true:
|
||||
case false:
|
||||
return "boolean" /* boolean */;
|
||||
default:
|
||||
}
|
||||
switch (typeof value) {
|
||||
case 'undefined':
|
||||
return "undefined" /* undefined */;
|
||||
case 'string':
|
||||
return "string" /* string */;
|
||||
case 'number':
|
||||
return "number" /* number */;
|
||||
case 'symbol':
|
||||
return "symbol" /* symbol */;
|
||||
default:
|
||||
}
|
||||
if (is.function_(value)) {
|
||||
return "Function" /* Function */;
|
||||
}
|
||||
if (is.observable(value)) {
|
||||
return "Observable" /* Observable */;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return "Array" /* Array */;
|
||||
}
|
||||
if (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) {
|
||||
// tslint:disable-next-line:strict-type-predicates
|
||||
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');
|
||||
// tslint:disable-next-line:strict-type-predicates
|
||||
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');
|
||||
// tslint:enable:variable-name
|
||||
is.numericString = (value) => is.string(value) && value.length > 0 && !Number.isNaN(Number(value));
|
||||
is.array = Array.isArray;
|
||||
is.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.asyncIterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.asyncIterator]);
|
||||
is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw);
|
||||
is.nativePromise = (value) => isObjectOfType("Promise" /* Promise */)(value);
|
||||
const hasPromiseAPI = (value) => !is.null_(value) &&
|
||||
isObject(value) &&
|
||||
is.function_(value.then) &&
|
||||
is.function_(value.catch);
|
||||
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
|
||||
is.generatorFunction = isObjectOfType("GeneratorFunction" /* GeneratorFunction */);
|
||||
is.asyncFunction = isObjectOfType("AsyncFunction" /* 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 = (value) => isObjectOfType("Map" /* Map */)(value);
|
||||
is.set = (value) => isObjectOfType("Set" /* Set */)(value);
|
||||
is.weakMap = (value) => isObjectOfType("WeakMap" /* WeakMap */)(value);
|
||||
is.weakSet = (value) => isObjectOfType("WeakSet" /* WeakSet */)(value);
|
||||
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 */);
|
||||
is.directInstanceOf = (instance, klass) => Object.getPrototypeOf(instance) === klass.prototype;
|
||||
is.urlInstance = (value) => isObjectOfType("URL" /* URL */)(value);
|
||||
is.urlString = (value) => {
|
||||
if (!is.string(value)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
new URLGlobal(value); // tslint:disable-line no-unused-expression
|
||||
return true;
|
||||
}
|
||||
catch (_a) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
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) {
|
||||
return value >= Math.min(...range) && value <= Math.max(...range);
|
||||
}
|
||||
throw new TypeError(`Invalid range: ${JSON.stringify(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.observable = (value) => {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
if (value[Symbol.observable] && value === value[Symbol.observable]()) {
|
||||
return true;
|
||||
}
|
||||
if (value['@@observable'] && value === value['@@observable']()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
is.nodeStream = (value) => !is.nullOrUndefined(value) && isObject(value) && is.function_(value.pipe) && !is.observable(value);
|
||||
is.infinite = (value) => value === Infinity || value === -Infinity;
|
||||
const isAbsoluteMod2 = (rem) => (value) => is.integer(value) && Math.abs(value % 2) === rem;
|
||||
is.even = isAbsoluteMod2(0);
|
||||
is.odd = isAbsoluteMod2(1);
|
||||
const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false;
|
||||
is.emptyArray = (value) => is.array(value) && value.length === 0;
|
||||
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
|
||||
is.emptyString = (value) => is.string(value) && value.length === 0;
|
||||
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
||||
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
|
||||
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
|
||||
is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0;
|
||||
is.emptySet = (value) => is.set(value) && value.size === 0;
|
||||
is.nonEmptySet = (value) => is.set(value) && value.size > 0;
|
||||
is.emptyMap = (value) => is.map(value) && value.size === 0;
|
||||
is.nonEmptyMap = (value) => is.map(value) && value.size > 0;
|
||||
const predicateOnArray = (method, predicate, values) => {
|
||||
if (is.function_(predicate) === false) {
|
||||
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
|
||||
}
|
||||
if (values.length === 0) {
|
||||
throw new TypeError('Invalid number of values');
|
||||
}
|
||||
return method.call(values, predicate);
|
||||
};
|
||||
// tslint:disable variable-name
|
||||
is.any = (predicate, ...values) => predicateOnArray(Array.prototype.some, predicate, values);
|
||||
is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values);
|
||||
// tslint:enable variable-name
|
||||
})(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;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@sindresorhus/is/dist/index.js.map
generated
vendored
1
node_modules/@sindresorhus/is/dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
9
node_modules/@sindresorhus/is/license
generated
vendored
9
node_modules/@sindresorhus/is/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
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.
|
||||
67
node_modules/@sindresorhus/is/package.json
generated
vendored
67
node_modules/@sindresorhus/is/package.json
generated
vendored
@@ -1,67 +0,0 @@
|
||||
{
|
||||
"name": "@sindresorhus/is",
|
||||
"version": "0.14.0",
|
||||
"description": "Type check values: `is.string('🦄') //=> true`",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"build": "del dist && 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": {
|
||||
"@sindresorhus/tsconfig": "^0.1.0",
|
||||
"@types/jsdom": "^11.12.0",
|
||||
"@types/node": "^10.12.10",
|
||||
"@types/tempy": "^0.2.0",
|
||||
"@types/zen-observable": "^0.8.0",
|
||||
"ava": "^0.25.0",
|
||||
"del-cli": "^1.1.0",
|
||||
"jsdom": "^11.6.2",
|
||||
"rxjs": "^6.3.3",
|
||||
"tempy": "^0.2.1",
|
||||
"tslint": "^5.9.1",
|
||||
"tslint-xo": "^0.10.0",
|
||||
"typescript": "^3.2.1",
|
||||
"zen-observable": "^0.8.8"
|
||||
},
|
||||
"types": "dist/index.d.ts"
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz"
|
||||
,"_integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ=="
|
||||
,"_from": "@sindresorhus/is@0.14.0"
|
||||
}
|
||||
451
node_modules/@sindresorhus/is/readme.md
generated
vendored
451
node_modules/@sindresorhus/is/readme.md
generated
vendored
@@ -1,451 +0,0 @@
|
||||
# is [](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
|
||||
```
|
||||
|
||||
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used to infer the correct type inside if-else statements.
|
||||
|
||||
```ts
|
||||
import is from '@sindresorhus/is';
|
||||
|
||||
const padLeft = (value: string, padding: string | number) => {
|
||||
if (is.number(padding)) {
|
||||
// `padding` is typed as `number`
|
||||
return Array(padding + 1).join(' ') + value;
|
||||
}
|
||||
|
||||
if (is.string(padding)) {
|
||||
// `padding` is typed as `string`
|
||||
return padding + value;
|
||||
}
|
||||
|
||||
throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);
|
||||
}
|
||||
|
||||
padLeft('🦄', 3);
|
||||
//=> ' 🦄'
|
||||
|
||||
padLeft('🦄', '🌈');
|
||||
//=> '🌈🦄'
|
||||
```
|
||||
|
||||
|
||||
## 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 an error 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).
|
||||
|
||||
##### .numericString(value)
|
||||
|
||||
Returns `true` for a string that represents a number. For example, `'42'` and `'-8'`.
|
||||
|
||||
Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.
|
||||
|
||||
##### .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)
|
||||
|
||||
#### Emptiness
|
||||
|
||||
##### .emptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is 0.
|
||||
|
||||
##### .nonEmptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is more than 0.
|
||||
|
||||
##### .emptyStringOrWhitespace(value)
|
||||
|
||||
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
||||
|
||||
##### .emptyArray(value)
|
||||
|
||||
Returns `true` if the value is an `Array` and the `.length` is 0.
|
||||
|
||||
##### .nonEmptyArray(value)
|
||||
|
||||
Returns `true` if the value is an `Array` and the `.length` is more than 0.
|
||||
|
||||
##### .emptyObject(value)
|
||||
|
||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
|
||||
|
||||
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
|
||||
|
||||
```js
|
||||
const object1 = {};
|
||||
|
||||
Object.defineProperty(object1, 'property1', {
|
||||
value: 42,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
is.emptyObject(object1);
|
||||
// => true
|
||||
```
|
||||
|
||||
##### .nonEmptyObject(value)
|
||||
|
||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.
|
||||
|
||||
##### .emptySet(value)
|
||||
|
||||
Returns `true` if the value is a `Set` and the `.size` is 0.
|
||||
|
||||
##### .nonEmptySet(Value)
|
||||
|
||||
Returns `true` if the value is a `Set` and the `.size` is more than 0.
|
||||
|
||||
##### .emptyMap(value)
|
||||
|
||||
Returns `true` if the value is a `Map` and the `.size` is 0.
|
||||
|
||||
##### .nonEmptyMap(value)
|
||||
|
||||
Returns `true` if the value is a `Map` and the `.size` is more than 0.
|
||||
|
||||
#### 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
|
||||
```
|
||||
|
||||
##### .urlInstance(value)
|
||||
|
||||
Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).
|
||||
|
||||
```js
|
||||
const url = new URL('https://example.com');
|
||||
|
||||
is.urlInstance(url);
|
||||
//=> true
|
||||
```
|
||||
|
||||
### .url(value)
|
||||
|
||||
Returns `true` if `value` is a URL string.
|
||||
|
||||
Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.
|
||||
|
||||
```js
|
||||
const url = 'https://example.com';
|
||||
|
||||
is.url(url);
|
||||
//=> true
|
||||
|
||||
is.url(new URL(url));
|
||||
//=> 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)
|
||||
##### .asyncIterable(value)
|
||||
##### .class(value)
|
||||
|
||||
Returns `true` for instances created by a 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 foo() {
|
||||
is.arrayLike(arguments);
|
||||
//=> true
|
||||
}
|
||||
foo();
|
||||
```
|
||||
|
||||
##### .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
|
||||
```
|
||||
|
||||
##### .observable(value)
|
||||
|
||||
Returns `true` if `value` is an `Observable`.
|
||||
|
||||
```js
|
||||
const {Observable} = require('rxjs');
|
||||
|
||||
is.observable(new Observable());
|
||||
//=> 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.
|
||||
|
||||
##### .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
|
||||
|
||||
- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans
|
||||
- [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
|
||||
21
node_modules/@szmarczak/http-timer/LICENSE
generated
vendored
21
node_modules/@szmarczak/http-timer/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Szymon Marczak
|
||||
|
||||
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.
|
||||
70
node_modules/@szmarczak/http-timer/README.md
generated
vendored
70
node_modules/@szmarczak/http-timer/README.md
generated
vendored
@@ -1,70 +0,0 @@
|
||||
# http-timer
|
||||
> Timings for HTTP requests
|
||||
|
||||
[](https://travis-ci.org/szmarczak/http-timer)
|
||||
[](https://coveralls.io/github/szmarczak/http-timer?branch=master)
|
||||
[](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
|
||||
|
||||
Inspired by the [`request` package](https://github.com/request/request).
|
||||
|
||||
## Usage
|
||||
```js
|
||||
'use strict';
|
||||
const https = require('https');
|
||||
const timer = require('@szmarczak/http-timer');
|
||||
|
||||
const request = https.get('https://httpbin.org/anything');
|
||||
const timings = timer(request);
|
||||
|
||||
request.on('response', response => {
|
||||
response.on('data', () => {}); // Consume the data somehow
|
||||
response.on('end', () => {
|
||||
console.log(timings);
|
||||
});
|
||||
});
|
||||
|
||||
// { start: 1535708511443,
|
||||
// socket: 1535708511444,
|
||||
// lookup: 1535708511444,
|
||||
// connect: 1535708511582,
|
||||
// upload: 1535708511887,
|
||||
// response: 1535708512037,
|
||||
// end: 1535708512040,
|
||||
// phases:
|
||||
// { wait: 1,
|
||||
// dns: 0,
|
||||
// tcp: 138,
|
||||
// request: 305,
|
||||
// firstByte: 150,
|
||||
// download: 3,
|
||||
// total: 597 } }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### timer(request)
|
||||
|
||||
Returns: `Object`
|
||||
|
||||
- `start` - Time when the request started.
|
||||
- `socket` - Time when a socket was assigned to the request.
|
||||
- `lookup` - Time when the DNS lookup finished.
|
||||
- `connect` - Time when the socket successfully connected.
|
||||
- `upload` - Time when the request finished uploading.
|
||||
- `response` - Time when the request fired the `response` event.
|
||||
- `end` - Time when the response fired the `end` event.
|
||||
- `error` - Time when the request fired the `error` event.
|
||||
- `phases`
|
||||
- `wait` - `timings.socket - timings.start`
|
||||
- `dns` - `timings.lookup - timings.socket`
|
||||
- `tcp` - `timings.connect - timings.lookup`
|
||||
- `request` - `timings.upload - timings.connect`
|
||||
- `firstByte` - `timings.response - timings.upload`
|
||||
- `download` - `timings.end - timings.response`
|
||||
- `total` - `timings.end - timings.start` or `timings.error - timings.start`
|
||||
|
||||
**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
51
node_modules/@szmarczak/http-timer/package.json
generated
vendored
51
node_modules/@szmarczak/http-timer/package.json
generated
vendored
@@ -1,51 +0,0 @@
|
||||
{
|
||||
"name": "@szmarczak/http-timer",
|
||||
"version": "1.1.2",
|
||||
"description": "Timings for HTTP requests",
|
||||
"main": "source",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava",
|
||||
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"files": [
|
||||
"source"
|
||||
],
|
||||
"keywords": [
|
||||
"http",
|
||||
"https",
|
||||
"timer",
|
||||
"timings"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/szmarczak/http-timer.git"
|
||||
},
|
||||
"author": "Szymon Marczak",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/szmarczak/http-timer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/szmarczak/http-timer#readme",
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/filename-case": "camelCase"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.25.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"p-event": "^2.1.0",
|
||||
"nyc": "^12.0.2",
|
||||
"xo": "^0.22.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"defer-to-connect": "^1.0.1"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz"
|
||||
,"_integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA=="
|
||||
,"_from": "@szmarczak/http-timer@1.1.2"
|
||||
}
|
||||
99
node_modules/@szmarczak/http-timer/source/index.js
generated
vendored
99
node_modules/@szmarczak/http-timer/source/index.js
generated
vendored
@@ -1,99 +0,0 @@
|
||||
'use strict';
|
||||
const deferToConnect = require('defer-to-connect');
|
||||
|
||||
module.exports = request => {
|
||||
const timings = {
|
||||
start: Date.now(),
|
||||
socket: null,
|
||||
lookup: null,
|
||||
connect: null,
|
||||
upload: null,
|
||||
response: null,
|
||||
end: null,
|
||||
error: null,
|
||||
phases: {
|
||||
wait: null,
|
||||
dns: null,
|
||||
tcp: null,
|
||||
request: null,
|
||||
firstByte: null,
|
||||
download: null,
|
||||
total: null
|
||||
}
|
||||
};
|
||||
|
||||
const handleError = origin => {
|
||||
const emit = origin.emit.bind(origin);
|
||||
origin.emit = (event, ...args) => {
|
||||
// Catches the `error` event
|
||||
if (event === 'error') {
|
||||
timings.error = Date.now();
|
||||
timings.phases.total = timings.error - timings.start;
|
||||
|
||||
origin.emit = emit;
|
||||
}
|
||||
|
||||
// Saves the original behavior
|
||||
return emit(event, ...args);
|
||||
};
|
||||
};
|
||||
|
||||
let uploadFinished = false;
|
||||
const onUpload = () => {
|
||||
timings.upload = Date.now();
|
||||
timings.phases.request = timings.upload - timings.connect;
|
||||
};
|
||||
|
||||
handleError(request);
|
||||
|
||||
request.once('socket', socket => {
|
||||
timings.socket = Date.now();
|
||||
timings.phases.wait = timings.socket - timings.start;
|
||||
|
||||
const lookupListener = () => {
|
||||
timings.lookup = Date.now();
|
||||
timings.phases.dns = timings.lookup - timings.socket;
|
||||
};
|
||||
|
||||
socket.once('lookup', lookupListener);
|
||||
|
||||
deferToConnect(socket, () => {
|
||||
timings.connect = Date.now();
|
||||
|
||||
if (timings.lookup === null) {
|
||||
socket.removeListener('lookup', lookupListener);
|
||||
timings.lookup = timings.connect;
|
||||
timings.phases.dns = timings.lookup - timings.socket;
|
||||
}
|
||||
|
||||
timings.phases.tcp = timings.connect - timings.lookup;
|
||||
|
||||
if (uploadFinished && !timings.upload) {
|
||||
onUpload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
request.once('finish', () => {
|
||||
uploadFinished = true;
|
||||
|
||||
if (timings.connect) {
|
||||
onUpload();
|
||||
}
|
||||
});
|
||||
|
||||
request.once('response', response => {
|
||||
timings.response = Date.now();
|
||||
timings.phases.firstByte = timings.response - timings.upload;
|
||||
|
||||
handleError(response);
|
||||
|
||||
response.once('end', () => {
|
||||
timings.end = Date.now();
|
||||
timings.phases.download = timings.end - timings.response;
|
||||
timings.phases.total = timings.end - timings.start;
|
||||
});
|
||||
});
|
||||
|
||||
return timings;
|
||||
};
|
||||
7
node_modules/accepts/HISTORY.md
generated
vendored
7
node_modules/accepts/HISTORY.md
generated
vendored
@@ -1,3 +1,10 @@
|
||||
1.3.8 / 2022-02-02
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.34
|
||||
- deps: mime-db@~1.51.0
|
||||
* deps: negotiator@0.6.3
|
||||
|
||||
1.3.7 / 2019-04-29
|
||||
==================
|
||||
|
||||
|
||||
8
node_modules/accepts/README.md
generated
vendored
8
node_modules/accepts/README.md
generated
vendored
@@ -3,7 +3,7 @@
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
|
||||
@@ -29,8 +29,6 @@ $ npm install accepts
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```js
|
||||
var accepts = require('accepts')
|
||||
```
|
||||
@@ -133,10 +131,10 @@ curl -I -H'Accept: text/html' http://localhost:3000/
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
|
||||
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
|
||||
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
|
||||
[node-version-image]: https://badgen.net/npm/node/accepts
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
|
||||
[npm-url]: https://npmjs.org/package/accepts
|
||||
[npm-version-image]: https://badgen.net/npm/v/accepts
|
||||
[travis-image]: https://badgen.net/travis/jshttp/accepts/master
|
||||
[travis-url]: https://travis-ci.org/jshttp/accepts
|
||||
|
||||
34
node_modules/accepts/package.json
generated
vendored
34
node_modules/accepts/package.json
generated
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "accepts",
|
||||
"description": "Higher-level content negotiation",
|
||||
"version": "1.3.7",
|
||||
"version": "1.3.8",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
@@ -9,20 +9,20 @@
|
||||
"license": "MIT",
|
||||
"repository": "jshttp/accepts",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.24",
|
||||
"negotiator": "0.6.2"
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"deep-equal": "1.0.1",
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-standard": "12.0.0",
|
||||
"eslint-plugin-import": "2.17.2",
|
||||
"eslint-plugin-markdown": "1.0.0",
|
||||
"eslint-plugin-node": "8.0.1",
|
||||
"eslint-plugin-promise": "4.1.1",
|
||||
"eslint-plugin-standard": "4.0.0",
|
||||
"mocha": "6.1.4",
|
||||
"nyc": "14.0.0"
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.25.4",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "4.3.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "9.2.0",
|
||||
"nyc": "15.1.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
@@ -33,10 +33,10 @@
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"test-travis": "nyc --reporter=text npm test"
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
},
|
||||
"keywords": [
|
||||
"content",
|
||||
@@ -44,8 +44,4 @@
|
||||
"accept",
|
||||
"accepts"
|
||||
]
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz"
|
||||
,"_integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA=="
|
||||
,"_from": "accepts@1.3.7"
|
||||
}
|
||||
51
node_modules/ansi-align/CHANGELOG.md
generated
vendored
51
node_modules/ansi-align/CHANGELOG.md
generated
vendored
@@ -1,51 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
<a name="3.0.0"></a>
|
||||
# [3.0.0](https://github.com/nexdrew/ansi-align/compare/v2.0.0...v3.0.0) (2018-12-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **package:** update string-width to version 3.0.0 ([#50](https://github.com/nexdrew/ansi-align/issues/50)) ([67f0d8f](https://github.com/nexdrew/ansi-align/commit/67f0d8f))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **package:** Node 4 no longer supported, please update to Node 6+ or use ansi-align@2.0.0
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0"></a>
|
||||
# [2.0.0](https://github.com/nexdrew/ansi-align/compare/v1.1.0...v2.0.0) (2017-05-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* ES2015ify, dropping support for Node <4 ([#30](https://github.com/nexdrew/ansi-align/issues/30)) ([7b43f48](https://github.com/nexdrew/ansi-align/commit/7b43f48))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Node 0.10 or 0.12 no longer supported, please update to Node 4+ or use ansi-align@1.1.0
|
||||
|
||||
|
||||
|
||||
<a name="1.1.0"></a>
|
||||
# [1.1.0](https://github.com/nexdrew/ansi-align/compare/v1.0.0...v1.1.0) (2016-06-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support left-alignment as no-op ([#3](https://github.com/nexdrew/ansi-align/issues/3)) ([e581db6](https://github.com/nexdrew/ansi-align/commit/e581db6))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# 1.0.0 (2016-04-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* initial commit ([1914d90](https://github.com/nexdrew/ansi-align/commit/1914d90))
|
||||
13
node_modules/ansi-align/LICENSE
generated
vendored
13
node_modules/ansi-align/LICENSE
generated
vendored
@@ -1,13 +0,0 @@
|
||||
Copyright (c) 2016, Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright notice
|
||||
and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
80
node_modules/ansi-align/README.md
generated
vendored
80
node_modules/ansi-align/README.md
generated
vendored
@@ -1,80 +0,0 @@
|
||||
# ansi-align
|
||||
|
||||
> align-text with ANSI support for CLIs
|
||||
|
||||
[](https://travis-ci.org/nexdrew/ansi-align)
|
||||
[](https://coveralls.io/github/nexdrew/ansi-align?branch=master)
|
||||
[](https://github.com/conventional-changelog/standard-version)
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
Easily center- or right- align a block of text, carefully ignoring ANSI escape codes.
|
||||
|
||||
E.g. turn this:
|
||||
|
||||
<img width="281" alt="ansi text block no alignment :(" src="https://cloud.githubusercontent.com/assets/1929625/14937509/7c3076dc-0ed7-11e6-8c16-4f6a4ccc8346.png">
|
||||
|
||||
Into this:
|
||||
|
||||
<img width="278" alt="ansi text block center aligned!" src="https://cloud.githubusercontent.com/assets/1929625/14937510/7c3ca0b0-0ed7-11e6-8f0a-541ca39b6e0a.png">
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save ansi-align
|
||||
```
|
||||
|
||||
```js
|
||||
var ansiAlign = require('ansi-align')
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `ansiAlign(text, [opts])`
|
||||
|
||||
Align the given text per the line with the greatest [`string-width`](https://github.com/sindresorhus/string-width), returning a new string (or array).
|
||||
|
||||
#### Arguments
|
||||
|
||||
- `text`: required, string or array
|
||||
|
||||
The text to align. If a string is given, it will be split using either the `opts.split` value or `'\n'` by default. If an array is given, a different array of modified strings will be returned.
|
||||
|
||||
- `opts`: optional, object
|
||||
|
||||
Options to change behavior, see below.
|
||||
|
||||
#### Options
|
||||
|
||||
- `opts.align`: string, default `'center'`
|
||||
|
||||
The alignment mode. Use `'center'` for center-alignment, `'right'` for right-alignment, or `'left'` for left-alignment. Note that the given `text` is assumed to be left-aligned already, so specifying `align: 'left'` just returns the `text` as is (no-op).
|
||||
|
||||
- `opts.split`: string or RegExp, default `'\n'`
|
||||
|
||||
The separator to use when splitting the text. Only used if text is given as a string.
|
||||
|
||||
- `opts.pad`: string, default `' '`
|
||||
|
||||
The value used to left-pad (prepend to) lines of lesser width. Will be repeated as necessary to adjust alignment to the line with the greatest width.
|
||||
|
||||
### `ansiAlign.center(text)`
|
||||
|
||||
Alias for `ansiAlign(text, { align: 'center' })`.
|
||||
|
||||
### `ansiAlign.right(text)`
|
||||
|
||||
Alias for `ansiAlign(text, { align: 'right' })`.
|
||||
|
||||
### `ansiAlign.left(text)`
|
||||
|
||||
Alias for `ansiAlign(text, { align: 'left' })`, which is a no-op.
|
||||
|
||||
## Similar Packages
|
||||
|
||||
- [`center-align`](https://github.com/jonschlinkert/center-align): Very close to this package, except it doesn't support ANSI codes.
|
||||
- [`left-pad`](https://github.com/camwest/left-pad): Great for left-padding but does not support center alignment or ANSI codes.
|
||||
- Pretty much anything by the [chalk](https://github.com/chalk) team
|
||||
|
||||
## License
|
||||
|
||||
ISC © Contributors
|
||||
61
node_modules/ansi-align/index.js
generated
vendored
61
node_modules/ansi-align/index.js
generated
vendored
@@ -1,61 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const stringWidth = require('string-width')
|
||||
|
||||
function ansiAlign (text, opts) {
|
||||
if (!text) return text
|
||||
|
||||
opts = opts || {}
|
||||
const align = opts.align || 'center'
|
||||
|
||||
// short-circuit `align: 'left'` as no-op
|
||||
if (align === 'left') return text
|
||||
|
||||
const split = opts.split || '\n'
|
||||
const pad = opts.pad || ' '
|
||||
const widthDiffFn = align !== 'right' ? halfDiff : fullDiff
|
||||
|
||||
let returnString = false
|
||||
if (!Array.isArray(text)) {
|
||||
returnString = true
|
||||
text = String(text).split(split)
|
||||
}
|
||||
|
||||
let width
|
||||
let maxWidth = 0
|
||||
text = text.map(function (str) {
|
||||
str = String(str)
|
||||
width = stringWidth(str)
|
||||
maxWidth = Math.max(width, maxWidth)
|
||||
return {
|
||||
str,
|
||||
width
|
||||
}
|
||||
}).map(function (obj) {
|
||||
return new Array(widthDiffFn(maxWidth, obj.width) + 1).join(pad) + obj.str
|
||||
})
|
||||
|
||||
return returnString ? text.join(split) : text
|
||||
}
|
||||
|
||||
ansiAlign.left = function left (text) {
|
||||
return ansiAlign(text, { align: 'left' })
|
||||
}
|
||||
|
||||
ansiAlign.center = function center (text) {
|
||||
return ansiAlign(text, { align: 'center' })
|
||||
}
|
||||
|
||||
ansiAlign.right = function right (text) {
|
||||
return ansiAlign(text, { align: 'right' })
|
||||
}
|
||||
|
||||
module.exports = ansiAlign
|
||||
|
||||
function halfDiff (maxWidth, curWidth) {
|
||||
return Math.floor((maxWidth - curWidth) / 2)
|
||||
}
|
||||
|
||||
function fullDiff (maxWidth, curWidth) {
|
||||
return maxWidth - curWidth
|
||||
}
|
||||
39
node_modules/ansi-align/node_modules/string-width/index.js
generated
vendored
39
node_modules/ansi-align/node_modules/string-width/index.js
generated
vendored
@@ -1,39 +0,0 @@
|
||||
'use strict';
|
||||
const stripAnsi = require('strip-ansi');
|
||||
const isFullwidthCodePoint = require('is-fullwidth-code-point');
|
||||
const emojiRegex = require('emoji-regex')();
|
||||
|
||||
module.exports = input => {
|
||||
input = input.replace(emojiRegex, ' ');
|
||||
|
||||
if (typeof input !== 'string' || input.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
input = stripAnsi(input);
|
||||
|
||||
let width = 0;
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const code = input.codePointAt(i);
|
||||
|
||||
// Ignore control characters
|
||||
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore combining characters
|
||||
if (code >= 0x300 && code <= 0x36F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Surrogates
|
||||
if (code > 0xFFFF) {
|
||||
i++;
|
||||
}
|
||||
|
||||
width += isFullwidthCodePoint(code) ? 2 : 1;
|
||||
}
|
||||
|
||||
return width;
|
||||
};
|
||||
9
node_modules/ansi-align/node_modules/string-width/license
generated
vendored
9
node_modules/ansi-align/node_modules/string-width/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
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.
|
||||
60
node_modules/ansi-align/node_modules/string-width/package.json
generated
vendored
60
node_modules/ansi-align/node_modules/string-width/package.json
generated
vendored
@@ -1,60 +0,0 @@
|
||||
{
|
||||
"name": "string-width",
|
||||
"version": "3.1.0",
|
||||
"description": "Get the visual width of a string - the number of columns required to display it",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/string-width",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"string",
|
||||
"str",
|
||||
"character",
|
||||
"char",
|
||||
"unicode",
|
||||
"width",
|
||||
"visual",
|
||||
"column",
|
||||
"columns",
|
||||
"fullwidth",
|
||||
"full-width",
|
||||
"full",
|
||||
"ansi",
|
||||
"escape",
|
||||
"codes",
|
||||
"cli",
|
||||
"command-line",
|
||||
"terminal",
|
||||
"console",
|
||||
"cjk",
|
||||
"chinese",
|
||||
"japanese",
|
||||
"korean",
|
||||
"fixed-width"
|
||||
],
|
||||
"dependencies": {
|
||||
"emoji-regex": "^7.0.1",
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.0.1",
|
||||
"xo": "^0.23.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz"
|
||||
,"_integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w=="
|
||||
,"_from": "string-width@3.1.0"
|
||||
}
|
||||
45
node_modules/ansi-align/node_modules/string-width/readme.md
generated
vendored
45
node_modules/ansi-align/node_modules/string-width/readme.md
generated
vendored
@@ -1,45 +0,0 @@
|
||||
# string-width [](https://travis-ci.org/sindresorhus/string-width)
|
||||
|
||||
> Get the visual width of a string - the number of columns required to display it
|
||||
|
||||
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||
|
||||
Useful to be able to measure the actual width of command-line output.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install string-width
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const stringWidth = require('string-width');
|
||||
|
||||
stringWidth('古');
|
||||
//=> 2
|
||||
|
||||
stringWidth('\u001b[1m古\u001b[22m');
|
||||
//=> 2
|
||||
|
||||
stringWidth('a');
|
||||
//=> 1
|
||||
|
||||
stringWidth('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
|
||||
// => 5
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
|
||||
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
|
||||
- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
47
node_modules/ansi-align/package.json
generated
vendored
47
node_modules/ansi-align/package.json
generated
vendored
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"name": "ansi-align",
|
||||
"version": "3.0.0",
|
||||
"description": "align-text with ANSI support for CLIs",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"pretest": "standard",
|
||||
"test": "nyc ava",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"release": "standard-version"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nexdrew/ansi-align.git"
|
||||
},
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"align",
|
||||
"cli",
|
||||
"center",
|
||||
"pad"
|
||||
],
|
||||
"author": "nexdrew",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nexdrew/ansi-align/issues"
|
||||
},
|
||||
"homepage": "https://github.com/nexdrew/ansi-align#readme",
|
||||
"dependencies": {
|
||||
"string-width": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.0.1",
|
||||
"chalk": "^2.4.1",
|
||||
"coveralls": "^3.0.2",
|
||||
"nyc": "^13.1.0",
|
||||
"standard": "^12.0.1",
|
||||
"standard-version": "^4.4.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz"
|
||||
,"_integrity": "sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw=="
|
||||
,"_from": "ansi-align@3.0.0"
|
||||
}
|
||||
10
node_modules/ansi-regex/index.js
generated
vendored
10
node_modules/ansi-regex/index.js
generated
vendored
@@ -1,14 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = options => {
|
||||
options = Object.assign({
|
||||
onlyFirst: false
|
||||
}, options);
|
||||
|
||||
module.exports = ({onlyFirst = false} = {}) => {
|
||||
const pattern = [
|
||||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
||||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
||||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
||||
].join('|');
|
||||
|
||||
return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
|
||||
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
||||
};
|
||||
|
||||
18
node_modules/ansi-regex/package.json
generated
vendored
18
node_modules/ansi-regex/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ansi-regex",
|
||||
"version": "4.1.0",
|
||||
"version": "5.0.1",
|
||||
"description": "Regular expression for matching ANSI escape codes",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/ansi-regex",
|
||||
@@ -10,14 +10,15 @@
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava",
|
||||
"test": "xo && ava && tsd",
|
||||
"view-supported": "node fixtures/view-codes.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"ansi",
|
||||
@@ -47,11 +48,8 @@
|
||||
"pattern"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^0.25.0",
|
||||
"xo": "^0.23.0"
|
||||
"ava": "^2.4.0",
|
||||
"tsd": "^0.9.0",
|
||||
"xo": "^0.25.3"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz"
|
||||
,"_integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
|
||||
,"_from": "ansi-regex@4.1.0"
|
||||
}
|
||||
37
node_modules/ansi-regex/readme.md
generated
vendored
37
node_modules/ansi-regex/readme.md
generated
vendored
@@ -1,21 +1,7 @@
|
||||
# ansi-regex [](https://travis-ci.org/chalk/ansi-regex)
|
||||
# ansi-regex
|
||||
|
||||
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package 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
|
||||
|
||||
@@ -48,12 +34,14 @@ ansiRegex().test('cake');
|
||||
|
||||
## API
|
||||
|
||||
### ansiRegex([options])
|
||||
### ansiRegex(options?)
|
||||
|
||||
Returns a regex for matching ANSI escape codes.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### onlyFirst
|
||||
|
||||
Type: `boolean`<br>
|
||||
@@ -71,17 +59,20 @@ Some of the codes we run as a test are codes that we acquired finding various li
|
||||
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
---
|
||||
|
||||
MIT
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package 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>
|
||||
|
||||
1
node_modules/anymatch/index.d.ts
generated
vendored
1
node_modules/anymatch/index.d.ts
generated
vendored
@@ -10,6 +10,7 @@ type PicomatchOptions = {dot: boolean};
|
||||
|
||||
declare const anymatch: {
|
||||
(matchers: AnymatchMatcher): AnymatchTester;
|
||||
(matchers: AnymatchMatcher, testString: null, returnIndex: true | PicomatchOptions): AnymatchTester;
|
||||
(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true | PicomatchOptions): number;
|
||||
(matchers: AnymatchMatcher, testString: string|any[]): boolean;
|
||||
}
|
||||
|
||||
6
node_modules/anymatch/index.js
generated
vendored
6
node_modules/anymatch/index.js
generated
vendored
@@ -47,7 +47,7 @@ const matchPatterns = (patterns, negPatterns, args, returnIndex) => {
|
||||
throw new TypeError('anymatch: second argument must be a string: got ' +
|
||||
Object.prototype.toString.call(_path))
|
||||
}
|
||||
const path = normalizePath(_path);
|
||||
const path = normalizePath(_path, false);
|
||||
|
||||
for (let index = 0; index < negPatterns.length; index++) {
|
||||
const nglob = negPatterns[index];
|
||||
@@ -86,7 +86,9 @@ const anymatch = (matchers, testString, options = DEFAULT_OPTIONS) => {
|
||||
.filter(item => typeof item === 'string' && item.charAt(0) === BANG)
|
||||
.map(item => item.slice(1))
|
||||
.map(item => picomatch(item, opts));
|
||||
const patterns = mtchers.map(matcher => createPattern(matcher, opts));
|
||||
const patterns = mtchers
|
||||
.filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG))
|
||||
.map(matcher => createPattern(matcher, opts));
|
||||
|
||||
if (testString == null) {
|
||||
return (testString, ri = false) => {
|
||||
|
||||
6
node_modules/anymatch/package.json
generated
vendored
6
node_modules/anymatch/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "anymatch",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.3",
|
||||
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",
|
||||
"files": [
|
||||
"index.js",
|
||||
@@ -45,8 +45,4 @@
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz"
|
||||
,"_integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg=="
|
||||
,"_from": "anymatch@3.1.1"
|
||||
}
|
||||
48
node_modules/body-parser/HISTORY.md
generated
vendored
48
node_modules/body-parser/HISTORY.md
generated
vendored
@@ -1,3 +1,51 @@
|
||||
1.20.1 / 2022-10-06
|
||||
===================
|
||||
|
||||
* deps: qs@6.11.0
|
||||
* perf: remove unnecessary object clone
|
||||
|
||||
1.20.0 / 2022-04-02
|
||||
===================
|
||||
|
||||
* Fix error message for json parse whitespace in `strict`
|
||||
* Fix internal error when inflated body exceeds limit
|
||||
* Prevent loss of async hooks context
|
||||
* Prevent hanging when request already read
|
||||
* deps: depd@2.0.0
|
||||
- Replace internal `eval` usage with `Function` constructor
|
||||
- Use instance methods on `process` to check for listeners
|
||||
* deps: http-errors@2.0.0
|
||||
- deps: depd@2.0.0
|
||||
- deps: statuses@2.0.1
|
||||
* deps: on-finished@2.4.1
|
||||
* deps: qs@6.10.3
|
||||
* deps: raw-body@2.5.1
|
||||
- deps: http-errors@2.0.0
|
||||
|
||||
1.19.2 / 2022-02-15
|
||||
===================
|
||||
|
||||
* deps: bytes@3.1.2
|
||||
* deps: qs@6.9.7
|
||||
* Fix handling of `__proto__` keys
|
||||
* deps: raw-body@2.4.3
|
||||
- deps: bytes@3.1.2
|
||||
|
||||
1.19.1 / 2021-12-10
|
||||
===================
|
||||
|
||||
* deps: bytes@3.1.1
|
||||
* deps: http-errors@1.8.1
|
||||
- deps: inherits@2.0.4
|
||||
- deps: toidentifier@1.0.1
|
||||
- deps: setprototypeof@1.2.0
|
||||
* deps: qs@6.9.6
|
||||
* deps: raw-body@2.4.2
|
||||
- deps: bytes@3.1.1
|
||||
- deps: http-errors@1.8.1
|
||||
* deps: safe-buffer@5.2.1
|
||||
* deps: type-is@~1.6.18
|
||||
|
||||
1.19.0 / 2019-04-25
|
||||
===================
|
||||
|
||||
|
||||
45
node_modules/body-parser/README.md
generated
vendored
45
node_modules/body-parser/README.md
generated
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Node.js body parsing middleware.
|
||||
@@ -49,8 +49,6 @@ $ npm install body-parser
|
||||
|
||||
## API
|
||||
|
||||
<!-- eslint-disable no-unused-vars -->
|
||||
|
||||
```js
|
||||
var bodyParser = require('body-parser')
|
||||
```
|
||||
@@ -281,14 +279,15 @@ encoding of the request. The parsing can be aborted by throwing an error.
|
||||
|
||||
## Errors
|
||||
|
||||
The middlewares provided by this module create errors depending on the error
|
||||
condition during parsing. The errors will typically have a `status`/`statusCode`
|
||||
property that contains the suggested HTTP response code, an `expose` property
|
||||
to determine if the `message` property should be displayed to the client, a
|
||||
`type` property to determine the type of error without matching against the
|
||||
`message`, and a `body` property containing the read body, if available.
|
||||
The middlewares provided by this module create errors using the
|
||||
[`http-errors` module](https://www.npmjs.com/package/http-errors). The errors
|
||||
will typically have a `status`/`statusCode` property that contains the suggested
|
||||
HTTP response code, an `expose` property to determine if the `message` property
|
||||
should be displayed to the client, a `type` property to determine the type of
|
||||
error without matching against the `message`, and a `body` property containing
|
||||
the read body, if available.
|
||||
|
||||
The following are the common errors emitted, though any error can come through
|
||||
The following are the common errors created, though any error can come through
|
||||
for various reasons.
|
||||
|
||||
### content encoding unsupported
|
||||
@@ -299,6 +298,20 @@ contained an encoding but the "inflation" option was set to `false`. The
|
||||
`'encoding.unsupported'`, and the `charset` property will be set to the
|
||||
encoding that is unsupported.
|
||||
|
||||
### entity parse failed
|
||||
|
||||
This error will occur when the request contained an entity that could not be
|
||||
parsed by the middleware. The `status` property is set to `400`, the `type`
|
||||
property is set to `'entity.parse.failed'`, and the `body` property is set to
|
||||
the entity value that failed parsing.
|
||||
|
||||
### entity verify failed
|
||||
|
||||
This error will occur when the request contained an entity that could not be
|
||||
failed verification by the defined `verify` option. The `status` property is
|
||||
set to `403`, the `type` property is set to `'entity.verify.failed'`, and the
|
||||
`body` property is set to the entity value that failed verification.
|
||||
|
||||
### request aborted
|
||||
|
||||
This error will occur when the request is aborted by the client before reading
|
||||
@@ -329,6 +342,14 @@ to this middleware. This module operates directly on bytes only and you cannot
|
||||
call `req.setEncoding` when using this module. The `status` property is set to
|
||||
`500` and the `type` property is set to `'stream.encoding.set'`.
|
||||
|
||||
### stream is not readable
|
||||
|
||||
This error will occur when the request is no longer readable when this middleware
|
||||
attempts to read it. This typically means something other than a middleware from
|
||||
this module read the request body already and the middleware was also configured to
|
||||
read the same request. The `status` property is set to `500` and the `type`
|
||||
property is set to `'stream.not.readable'`.
|
||||
|
||||
### too many parameters
|
||||
|
||||
This error will occur when the content of the request exceeds the configured
|
||||
@@ -435,9 +456,9 @@ app.use(bodyParser.text({ type: 'text/html' }))
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/body-parser.svg
|
||||
[npm-url]: https://npmjs.org/package/body-parser
|
||||
[travis-image]: https://img.shields.io/travis/expressjs/body-parser/master.svg
|
||||
[travis-url]: https://travis-ci.org/expressjs/body-parser
|
||||
[coveralls-image]: https://img.shields.io/coveralls/expressjs/body-parser/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/body-parser.svg
|
||||
[downloads-url]: https://npmjs.org/package/body-parser
|
||||
[github-actions-ci-image]: https://img.shields.io/github/workflow/status/expressjs/body-parser/ci/master?label=ci
|
||||
[github-actions-ci-url]: https://github.com/expressjs/body-parser/actions/workflows/ci.yml
|
||||
|
||||
17
node_modules/body-parser/index.js
generated
vendored
17
node_modules/body-parser/index.js
generated
vendored
@@ -91,16 +91,15 @@ Object.defineProperty(exports, 'urlencoded', {
|
||||
*/
|
||||
|
||||
function bodyParser (options) {
|
||||
var opts = {}
|
||||
|
||||
// exclude type option
|
||||
if (options) {
|
||||
for (var prop in options) {
|
||||
if (prop !== 'type') {
|
||||
opts[prop] = options[prop]
|
||||
}
|
||||
// use default type for parsers
|
||||
var opts = Object.create(options || null, {
|
||||
type: {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: undefined,
|
||||
writable: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var _urlencoded = exports.urlencoded(opts)
|
||||
var _json = exports.json(opts)
|
||||
|
||||
28
node_modules/body-parser/lib/read.js
generated
vendored
28
node_modules/body-parser/lib/read.js
generated
vendored
@@ -12,9 +12,11 @@
|
||||
*/
|
||||
|
||||
var createError = require('http-errors')
|
||||
var destroy = require('destroy')
|
||||
var getBody = require('raw-body')
|
||||
var iconv = require('iconv-lite')
|
||||
var onFinished = require('on-finished')
|
||||
var unpipe = require('unpipe')
|
||||
var zlib = require('zlib')
|
||||
|
||||
/**
|
||||
@@ -89,9 +91,14 @@ function read (req, res, next, parse, debug, options) {
|
||||
_error = createError(400, error)
|
||||
}
|
||||
|
||||
// unpipe from stream and destroy
|
||||
if (stream !== req) {
|
||||
unpipe(req)
|
||||
destroy(stream, true)
|
||||
}
|
||||
|
||||
// read off entire request
|
||||
stream.resume()
|
||||
onFinished(req, function onfinished () {
|
||||
dump(req, function onfinished () {
|
||||
next(createError(400, _error))
|
||||
})
|
||||
return
|
||||
@@ -179,3 +186,20 @@ function contentstream (req, debug, inflate) {
|
||||
|
||||
return stream
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the contents of a request.
|
||||
*
|
||||
* @param {object} req
|
||||
* @param {function} callback
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function dump (req, callback) {
|
||||
if (onFinished.isFinished(req)) {
|
||||
callback(null)
|
||||
} else {
|
||||
onFinished(req, callback)
|
||||
req.resume()
|
||||
}
|
||||
}
|
||||
|
||||
14
node_modules/body-parser/lib/types/json.js
generated
vendored
14
node_modules/body-parser/lib/types/json.js
generated
vendored
@@ -37,7 +37,7 @@ module.exports = json
|
||||
* %x0D ) ; Carriage return
|
||||
*/
|
||||
|
||||
var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*(.)/ // eslint-disable-line no-control-regex
|
||||
var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex
|
||||
|
||||
/**
|
||||
* Create a middleware to parse JSON bodies.
|
||||
@@ -122,7 +122,7 @@ function json (options) {
|
||||
|
||||
// assert charset per RFC 7159 sec 8.1
|
||||
var charset = getCharset(req) || 'utf-8'
|
||||
if (charset.substr(0, 4) !== 'utf-') {
|
||||
if (charset.slice(0, 4) !== 'utf-') {
|
||||
debug('invalid charset')
|
||||
next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
|
||||
charset: charset,
|
||||
@@ -152,7 +152,9 @@ function json (options) {
|
||||
|
||||
function createStrictSyntaxError (str, char) {
|
||||
var index = str.indexOf(char)
|
||||
var partial = str.substring(0, index) + '#'
|
||||
var partial = index !== -1
|
||||
? str.substring(0, index) + '#'
|
||||
: ''
|
||||
|
||||
try {
|
||||
JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
|
||||
@@ -173,7 +175,11 @@ function createStrictSyntaxError (str, char) {
|
||||
*/
|
||||
|
||||
function firstchar (str) {
|
||||
return FIRST_CHAR_REGEXP.exec(str)[1]
|
||||
var match = FIRST_CHAR_REGEXP.exec(str)
|
||||
|
||||
return match
|
||||
? match[1]
|
||||
: undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
54
node_modules/body-parser/package.json
generated
vendored
54
node_modules/body-parser/package.json
generated
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "body-parser",
|
||||
"description": "Node.js body parsing middleware",
|
||||
"version": "1.19.0",
|
||||
"version": "1.20.1",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
@@ -9,48 +9,48 @@
|
||||
"license": "MIT",
|
||||
"repository": "expressjs/body-parser",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.0",
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.4",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.2",
|
||||
"http-errors": "1.7.2",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"http-errors": "2.0.0",
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "~2.3.0",
|
||||
"qs": "6.7.0",
|
||||
"raw-body": "2.4.0",
|
||||
"type-is": "~1.6.17"
|
||||
"on-finished": "2.4.1",
|
||||
"qs": "6.11.0",
|
||||
"raw-body": "2.5.1",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-standard": "12.0.0",
|
||||
"eslint-plugin-import": "2.17.2",
|
||||
"eslint-plugin-markdown": "1.0.0",
|
||||
"eslint-plugin-node": "8.0.1",
|
||||
"eslint-plugin-promise": "4.1.1",
|
||||
"eslint-plugin-standard": "4.0.0",
|
||||
"istanbul": "0.4.5",
|
||||
"eslint": "8.24.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.26.0",
|
||||
"eslint-plugin-markdown": "3.0.0",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "6.0.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"methods": "1.1.2",
|
||||
"mocha": "6.1.4",
|
||||
"safe-buffer": "5.1.2",
|
||||
"supertest": "4.0.2"
|
||||
"mocha": "10.0.0",
|
||||
"nyc": "15.1.0",
|
||||
"safe-buffer": "5.2.1",
|
||||
"supertest": "6.3.0"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"SECURITY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/"
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz"
|
||||
,"_integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw=="
|
||||
,"_from": "body-parser@1.19.0"
|
||||
}
|
||||
175
node_modules/boxen/index.d.ts
generated
vendored
175
node_modules/boxen/index.d.ts
generated
vendored
@@ -1,175 +0,0 @@
|
||||
import {LiteralUnion} from 'type-fest';
|
||||
import cliBoxes, {BoxStyle} from 'cli-boxes';
|
||||
|
||||
declare namespace boxen {
|
||||
/**
|
||||
Characters used for custom border.
|
||||
|
||||
@example
|
||||
```
|
||||
// affffb
|
||||
// e e
|
||||
// dffffc
|
||||
|
||||
const border: CustomBorderStyle = {
|
||||
topLeft: 'a',
|
||||
topRight: 'b',
|
||||
bottomRight: 'c',
|
||||
bottomLeft: 'd',
|
||||
vertical: 'e',
|
||||
horizontal: 'f'
|
||||
};
|
||||
```
|
||||
*/
|
||||
interface CustomBorderStyle extends BoxStyle {}
|
||||
|
||||
/**
|
||||
Spacing used for `padding` and `margin`.
|
||||
*/
|
||||
interface Spacing {
|
||||
readonly top: number;
|
||||
readonly right: number;
|
||||
readonly bottom: number;
|
||||
readonly left: number;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
Color of the box border.
|
||||
*/
|
||||
readonly borderColor?: LiteralUnion<
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'gray'
|
||||
| 'grey'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright',
|
||||
string
|
||||
>;
|
||||
|
||||
/**
|
||||
Style of the box border.
|
||||
|
||||
@default BorderStyle.Single
|
||||
*/
|
||||
readonly borderStyle?: BorderStyle | CustomBorderStyle;
|
||||
|
||||
/**
|
||||
Reduce opacity of the border.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly dimBorder?: boolean;
|
||||
|
||||
/**
|
||||
Space between the text and box border.
|
||||
|
||||
@default 0
|
||||
*/
|
||||
readonly padding?: number | Spacing;
|
||||
|
||||
/**
|
||||
Space around the box.
|
||||
|
||||
@default 0
|
||||
*/
|
||||
readonly margin?: number | Spacing;
|
||||
|
||||
/**
|
||||
Float the box on the available terminal screen space.
|
||||
|
||||
@default 'left'
|
||||
*/
|
||||
readonly float?: 'left' | 'right' | 'center';
|
||||
|
||||
/**
|
||||
Color of the background.
|
||||
*/
|
||||
readonly backgroundColor?: LiteralUnion<
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright',
|
||||
string
|
||||
>;
|
||||
|
||||
/**
|
||||
Align the text in the box based on the widest line.
|
||||
|
||||
@default 'left'
|
||||
*/
|
||||
readonly align?: 'left' | 'right' | 'center';
|
||||
}
|
||||
}
|
||||
|
||||
declare const enum BorderStyle {
|
||||
Single = 'single',
|
||||
Double = 'double',
|
||||
Round = 'round',
|
||||
Bold = 'bold',
|
||||
SingleDouble = 'singleDouble',
|
||||
DoubleSingle = 'doubleSingle',
|
||||
Classic = 'classic'
|
||||
}
|
||||
|
||||
declare const boxen: {
|
||||
/**
|
||||
Creates a box in the terminal.
|
||||
|
||||
@param text - The text inside the box.
|
||||
@returns The box.
|
||||
|
||||
@example
|
||||
```
|
||||
import boxen = require('boxen');
|
||||
|
||||
console.log(boxen('unicorn', {padding: 1}));
|
||||
// ┌─────────────┐
|
||||
// │ │
|
||||
// │ unicorn │
|
||||
// │ │
|
||||
// └─────────────┘
|
||||
|
||||
console.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'}));
|
||||
//
|
||||
// ╔═════════════╗
|
||||
// ║ ║
|
||||
// ║ unicorn ║
|
||||
// ║ ║
|
||||
// ╚═════════════╝
|
||||
//
|
||||
```
|
||||
*/
|
||||
(text: string, options?: boxen.Options): string;
|
||||
|
||||
/**
|
||||
Border styles from [`cli-boxes`](https://github.com/sindresorhus/cli-boxes).
|
||||
*/
|
||||
BorderStyle: typeof BorderStyle;
|
||||
};
|
||||
|
||||
export = boxen;
|
||||
139
node_modules/boxen/index.js
generated
vendored
139
node_modules/boxen/index.js
generated
vendored
@@ -1,139 +0,0 @@
|
||||
'use strict';
|
||||
const stringWidth = require('string-width');
|
||||
const chalk = require('chalk');
|
||||
const widestLine = require('widest-line');
|
||||
const cliBoxes = require('cli-boxes');
|
||||
const camelCase = require('camelcase');
|
||||
const ansiAlign = require('ansi-align');
|
||||
const termSize = require('term-size');
|
||||
|
||||
const getObject = detail => {
|
||||
let object;
|
||||
|
||||
if (typeof detail === 'number') {
|
||||
object = {
|
||||
top: detail,
|
||||
right: detail * 3,
|
||||
bottom: detail,
|
||||
left: detail * 3
|
||||
};
|
||||
} else {
|
||||
object = {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...detail
|
||||
};
|
||||
}
|
||||
|
||||
return object;
|
||||
};
|
||||
|
||||
const getBorderChars = borderStyle => {
|
||||
const sides = [
|
||||
'topLeft',
|
||||
'topRight',
|
||||
'bottomRight',
|
||||
'bottomLeft',
|
||||
'vertical',
|
||||
'horizontal'
|
||||
];
|
||||
|
||||
let chararacters;
|
||||
|
||||
if (typeof borderStyle === 'string') {
|
||||
chararacters = cliBoxes[borderStyle];
|
||||
|
||||
if (!chararacters) {
|
||||
throw new TypeError(`Invalid border style: ${borderStyle}`);
|
||||
}
|
||||
} else {
|
||||
for (const side of sides) {
|
||||
if (!borderStyle[side] || typeof borderStyle[side] !== 'string') {
|
||||
throw new TypeError(`Invalid border style: ${side}`);
|
||||
}
|
||||
}
|
||||
|
||||
chararacters = borderStyle;
|
||||
}
|
||||
|
||||
return chararacters;
|
||||
};
|
||||
|
||||
const isHex = color => color.match(/^#[0-f]{3}(?:[0-f]{3})?$/i);
|
||||
const isColorValid = color => typeof color === 'string' && ((chalk[color]) || isHex(color));
|
||||
const getColorFn = color => isHex(color) ? chalk.hex(color) : chalk[color];
|
||||
const getBGColorFn = color => isHex(color) ? chalk.bgHex(color) : chalk[camelCase(['bg', color])];
|
||||
|
||||
module.exports = (text, options) => {
|
||||
options = {
|
||||
padding: 0,
|
||||
borderStyle: 'single',
|
||||
dimBorder: false,
|
||||
align: 'left',
|
||||
float: 'left',
|
||||
...options
|
||||
};
|
||||
|
||||
if (options.borderColor && !isColorValid(options.borderColor)) {
|
||||
throw new Error(`${options.borderColor} is not a valid borderColor`);
|
||||
}
|
||||
|
||||
if (options.backgroundColor && !isColorValid(options.backgroundColor)) {
|
||||
throw new Error(`${options.backgroundColor} is not a valid backgroundColor`);
|
||||
}
|
||||
|
||||
const chars = getBorderChars(options.borderStyle);
|
||||
const padding = getObject(options.padding);
|
||||
const margin = getObject(options.margin);
|
||||
|
||||
const colorizeBorder = border => {
|
||||
const newBorder = options.borderColor ? getColorFn(options.borderColor)(border) : border;
|
||||
return options.dimBorder ? chalk.dim(newBorder) : newBorder;
|
||||
};
|
||||
|
||||
const colorizeContent = content => options.backgroundColor ? getBGColorFn(options.backgroundColor)(content) : content;
|
||||
|
||||
text = ansiAlign(text, {align: options.align});
|
||||
|
||||
const NL = '\n';
|
||||
const PAD = ' ';
|
||||
|
||||
let lines = text.split(NL);
|
||||
|
||||
if (padding.top > 0) {
|
||||
lines = new Array(padding.top).fill('').concat(lines);
|
||||
}
|
||||
|
||||
if (padding.bottom > 0) {
|
||||
lines = lines.concat(new Array(padding.bottom).fill(''));
|
||||
}
|
||||
|
||||
const contentWidth = widestLine(text) + padding.left + padding.right;
|
||||
const paddingLeft = PAD.repeat(padding.left);
|
||||
const {columns} = termSize();
|
||||
let marginLeft = PAD.repeat(margin.left);
|
||||
|
||||
if (options.float === 'center') {
|
||||
const padWidth = Math.max((columns - contentWidth) / 2, 0);
|
||||
marginLeft = PAD.repeat(padWidth);
|
||||
} else if (options.float === 'right') {
|
||||
const padWidth = Math.max(columns - contentWidth - margin.right - 2, 0);
|
||||
marginLeft = PAD.repeat(padWidth);
|
||||
}
|
||||
|
||||
const horizontal = chars.horizontal.repeat(contentWidth);
|
||||
const top = colorizeBorder(NL.repeat(margin.top) + marginLeft + chars.topLeft + horizontal + chars.topRight);
|
||||
const bottom = colorizeBorder(marginLeft + chars.bottomLeft + horizontal + chars.bottomRight + NL.repeat(margin.bottom));
|
||||
const side = colorizeBorder(chars.vertical);
|
||||
|
||||
const middle = lines.map(line => {
|
||||
const paddingRight = PAD.repeat(contentWidth - stringWidth(line) - padding.left);
|
||||
return marginLeft + side + colorizeContent(paddingLeft + line + paddingRight) + side;
|
||||
}).join(NL);
|
||||
|
||||
return top + NL + middle + NL + bottom;
|
||||
};
|
||||
|
||||
module.exports._borderStyles = cliBoxes;
|
||||
9
node_modules/boxen/license
generated
vendored
9
node_modules/boxen/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
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.
|
||||
55
node_modules/boxen/package.json
generated
vendored
55
node_modules/boxen/package.json
generated
vendored
@@ -1,55 +0,0 @@
|
||||
{
|
||||
"name": "boxen",
|
||||
"version": "4.2.0",
|
||||
"description": "Create boxes in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/boxen",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"cli",
|
||||
"box",
|
||||
"boxes",
|
||||
"terminal",
|
||||
"term",
|
||||
"console",
|
||||
"ascii",
|
||||
"unicode",
|
||||
"border",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"ansi-align": "^3.0.0",
|
||||
"camelcase": "^5.3.1",
|
||||
"chalk": "^3.0.0",
|
||||
"cli-boxes": "^2.2.0",
|
||||
"string-width": "^4.1.0",
|
||||
"term-size": "^2.1.0",
|
||||
"type-fest": "^0.8.1",
|
||||
"widest-line": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"nyc": "^14.1.1",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/boxen/-/boxen-4.2.0.tgz"
|
||||
,"_integrity": "sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ=="
|
||||
,"_from": "boxen@4.2.0"
|
||||
}
|
||||
187
node_modules/boxen/readme.md
generated
vendored
187
node_modules/boxen/readme.md
generated
vendored
@@ -1,187 +0,0 @@
|
||||
# boxen [](https://travis-ci.org/sindresorhus/boxen)
|
||||
|
||||
> Create boxes in the terminal
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install boxen
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const boxen = require('boxen');
|
||||
|
||||
console.log(boxen('unicorn', {padding: 1}));
|
||||
/*
|
||||
┌─────────────┐
|
||||
│ │
|
||||
│ unicorn │
|
||||
│ │
|
||||
└─────────────┘
|
||||
*/
|
||||
|
||||
console.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'}));
|
||||
/*
|
||||
|
||||
╔═════════════╗
|
||||
║ ║
|
||||
║ unicorn ║
|
||||
║ ║
|
||||
╚═════════════╝
|
||||
|
||||
*/
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### boxen(text, options?)
|
||||
|
||||
#### text
|
||||
|
||||
Type: `string`
|
||||
|
||||
Text inside the box.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### borderColor
|
||||
|
||||
Type: `string`\
|
||||
Values: `'black'` `'red'` `'green'` `'yellow'` `'blue'` `'magenta'` `'cyan'` `'white'` `'gray'` or a hex value like `'#ff0000'`
|
||||
|
||||
Color of the box border.
|
||||
|
||||
##### borderStyle
|
||||
|
||||
Type: `string | object`\
|
||||
Default: `'single'`\
|
||||
Values:
|
||||
- `'single'`
|
||||
```
|
||||
┌───┐
|
||||
│foo│
|
||||
└───┘
|
||||
```
|
||||
- `'double'`
|
||||
```
|
||||
╔═══╗
|
||||
║foo║
|
||||
╚═══╝
|
||||
```
|
||||
- `'round'` (`'single'` sides with round corners)
|
||||
```
|
||||
╭───╮
|
||||
│foo│
|
||||
╰───╯
|
||||
```
|
||||
- `'bold'`
|
||||
```
|
||||
┏━━━┓
|
||||
┃foo┃
|
||||
┗━━━┛
|
||||
```
|
||||
- `'singleDouble'` (`'single'` on top and bottom, `'double'` on right and left)
|
||||
```
|
||||
╓───╖
|
||||
║foo║
|
||||
╙───╜
|
||||
```
|
||||
- `'doubleSingle'` (`'double'` on top and bottom, `'single'` on right and left)
|
||||
```
|
||||
╒═══╕
|
||||
│foo│
|
||||
╘═══╛
|
||||
```
|
||||
- `'classic'`
|
||||
```
|
||||
+---+
|
||||
|foo|
|
||||
+---+
|
||||
```
|
||||
|
||||
Style of the box border.
|
||||
|
||||
Can be any of the above predefined styles or an object with the following keys:
|
||||
|
||||
```js
|
||||
{
|
||||
topLeft: '+',
|
||||
topRight: '+',
|
||||
bottomLeft: '+',
|
||||
bottomRight: '+',
|
||||
horizontal: '-',
|
||||
vertical: '|'
|
||||
}
|
||||
```
|
||||
|
||||
##### dimBorder
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Reduce opacity of the border.
|
||||
|
||||
##### padding
|
||||
|
||||
Type: `number | object`\
|
||||
Default: `0`
|
||||
|
||||
Space between the text and box border.
|
||||
|
||||
Accepts a number or an object with any of the `top`, `right`, `bottom`, `left` properties. When a number is specified, the left/right padding is 3 times the top/bottom to make it look nice.
|
||||
|
||||
##### margin
|
||||
|
||||
Type: `number | object`\
|
||||
Default: `0`
|
||||
|
||||
Space around the box.
|
||||
|
||||
Accepts a number or an object with any of the `top`, `right`, `bottom`, `left` properties. When a number is specified, the left/right margin is 3 times the top/bottom to make it look nice.
|
||||
|
||||
##### float
|
||||
|
||||
Type: `string`\
|
||||
Default: `'left'`\
|
||||
Values: `'right'` `'center'` `'left'`
|
||||
|
||||
Float the box on the available terminal screen space.
|
||||
|
||||
##### backgroundColor
|
||||
|
||||
Type: `string`\
|
||||
Values: `'black'` `'red'` `'green'` `'yellow'` `'blue'` `'magenta'` `'cyan'` `'white'` `'gray'` or a hex value like `'#ff0000'`
|
||||
|
||||
Color of the background.
|
||||
|
||||
##### align
|
||||
|
||||
Type: `string`\
|
||||
Default: `'left'`\
|
||||
Values: `'left'` `'center'` `'right'`
|
||||
|
||||
Align the text in the box based on the widest line.
|
||||
|
||||
## Related
|
||||
|
||||
- [boxen-cli](https://github.com/sindresorhus/boxen-cli) - CLI for this module
|
||||
- [cli-boxes](https://github.com/sindresorhus/cli-boxes) - Boxes for use in the terminal
|
||||
- [ink-box](https://github.com/sindresorhus/ink-box) - Box component for Ink that uses this package
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-boxen?utm_source=npm-boxen&utm_medium=referral&utm_campaign=readme">Get professional support for this package 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>
|
||||
18
node_modules/bson/HISTORY.md
generated
vendored
18
node_modules/bson/HISTORY.md
generated
vendored
@@ -1,3 +1,21 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [1.1.6](https://github.com/mongodb/js-bson/compare/v1.1.5...v1.1.6) (2021-03-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Throw error on bigint usage and add helpers to Long ([#426](https://github.com/mongodb/js-bson/issues/426)) ([375f368](https://github.com/mongodb/js-bson/commit/375f368738807f2d41c7751e618fd09c8a1b94c9))
|
||||
|
||||
### [1.1.5](https://github.com/mongodb/js-bson/compare/v1.1.4...v1.1.5) (2020-08-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **object-id:** harden the duck-typing ([b526145](https://github.com/mongodb/js-bson/commit/b5261450c3bc4abb2e2fb19b5b1a7aba27982d44))
|
||||
|
||||
<a name="1.1.3"></a>
|
||||
## [1.1.3](https://github.com/mongodb/js-bson/compare/v1.1.2...v1.1.3) (2019-11-09)
|
||||
|
||||
|
||||
3
node_modules/bson/bower.json
generated
vendored
3
node_modules/bson/bower.json
generated
vendored
@@ -21,5 +21,6 @@
|
||||
"node_modules",
|
||||
"test",
|
||||
"tools"
|
||||
]
|
||||
],
|
||||
"version": "1.1.6"
|
||||
}
|
||||
|
||||
14
node_modules/bson/lib/bson/long.js
generated
vendored
14
node_modules/bson/lib/bson/long.js
generated
vendored
@@ -77,6 +77,11 @@ Long.prototype.toNumber = function() {
|
||||
return this.high_ * Long.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();
|
||||
};
|
||||
|
||||
/** Converts the Long to a BigInt (arbitrary precision). */
|
||||
Long.prototype.toBigInt = function () {
|
||||
return BigInt(this.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the JSON value.
|
||||
*
|
||||
@@ -711,6 +716,15 @@ Long.fromNumber = function(value) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
|
||||
* @param {bigint} value - The number in question
|
||||
* @returns {Long} The corresponding Long value
|
||||
*/
|
||||
Long.fromBigInt = function(value) {
|
||||
return Long.fromString(value.toString(10), 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits.
|
||||
*
|
||||
|
||||
7
node_modules/bson/lib/bson/objectid.js
generated
vendored
7
node_modules/bson/lib/bson/objectid.js
generated
vendored
@@ -66,7 +66,7 @@ var ObjectID = function ObjectID(id) {
|
||||
} else if (id != null && id.length === 12) {
|
||||
// assume 12 byte string
|
||||
this.id = id;
|
||||
} else if (id != null && id.toHexString) {
|
||||
} else if (id != null && typeof id.toHexString === 'function') {
|
||||
// Duck-typing to support ObjectId from different npm packages
|
||||
return id;
|
||||
} else {
|
||||
@@ -357,7 +357,10 @@ ObjectID.isValid = function isValid(id) {
|
||||
}
|
||||
|
||||
// Duck-Typing detection of ObjectId like objects
|
||||
if (id.toHexString) {
|
||||
if (
|
||||
typeof id.toHexString === 'function' &&
|
||||
(id.id instanceof _Buffer || typeof id.id === 'string')
|
||||
) {
|
||||
return id.id.length === 12 || (id.id.length === 24 && checkForHexRegExp.test(id.id));
|
||||
}
|
||||
|
||||
|
||||
6
node_modules/bson/lib/bson/parser/serializer.js
generated
vendored
6
node_modules/bson/lib/bson/parser/serializer.js
generated
vendored
@@ -709,6 +709,8 @@ var serializeInto = function serializeInto(
|
||||
index = serializeString(buffer, key, value, index, true);
|
||||
} else if (type === 'number') {
|
||||
index = serializeNumber(buffer, key, value, index, true);
|
||||
} else if(type === 'bigint') {
|
||||
throw new TypeError('Unsupported type BigInt, please use Decimal128');
|
||||
} else if (type === 'boolean') {
|
||||
index = serializeBoolean(buffer, key, value, index, true);
|
||||
} else if (value instanceof Date || isDate(value)) {
|
||||
@@ -820,6 +822,8 @@ var serializeInto = function serializeInto(
|
||||
index = serializeString(buffer, key, value, index);
|
||||
} else if (type === 'number') {
|
||||
index = serializeNumber(buffer, key, value, index);
|
||||
} else if(type === 'bigint') {
|
||||
throw new TypeError('Unsupported type BigInt, please use Decimal128');
|
||||
} else if (type === 'boolean') {
|
||||
index = serializeBoolean(buffer, key, value, index);
|
||||
} else if (value instanceof Date || isDate(value)) {
|
||||
@@ -923,6 +927,8 @@ var serializeInto = function serializeInto(
|
||||
index = serializeString(buffer, key, value, index);
|
||||
} else if (type === 'number') {
|
||||
index = serializeNumber(buffer, key, value, index);
|
||||
} else if(type === 'bigint') {
|
||||
throw new TypeError('Unsupported type BigInt, please use Decimal128');
|
||||
} else if (type === 'boolean') {
|
||||
index = serializeBoolean(buffer, key, value, index);
|
||||
} else if (value instanceof Date || isDate(value)) {
|
||||
|
||||
10
node_modules/bson/package.json
generated
vendored
10
node_modules/bson/package.json
generated
vendored
@@ -12,7 +12,7 @@
|
||||
"browser_build",
|
||||
"bower.json"
|
||||
],
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"author": "Christian Amor Kvalheim <christkv@gmail.com>",
|
||||
"contributors": [],
|
||||
"repository": "mongodb/js-bson",
|
||||
@@ -31,6 +31,7 @@
|
||||
"babel-preset-stage-0": "^6.5.0",
|
||||
"babel-register": "^6.14.0",
|
||||
"conventional-changelog-cli": "^1.3.5",
|
||||
"standard-version": "^9.1.1",
|
||||
"webpack": "^1.13.2",
|
||||
"webpack-polyfills-plugin": "0.0.9"
|
||||
},
|
||||
@@ -49,12 +50,9 @@
|
||||
"build": "webpack --config ./webpack.dist.config.js",
|
||||
"changelog": "conventional-changelog -p angular -i HISTORY.md -s",
|
||||
"lint": "eslint lib test",
|
||||
"format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'"
|
||||
"format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'",
|
||||
"release": "standard-version -i HISTORY.md"
|
||||
},
|
||||
"browser": "lib/bson/bson.js",
|
||||
"license": "Apache-2.0"
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/bson/-/bson-1.1.4.tgz"
|
||||
,"_integrity": "sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q=="
|
||||
,"_from": "bson@1.1.4"
|
||||
}
|
||||
2
node_modules/buffer-equal-constant-time/.npmignore
generated
vendored
2
node_modules/buffer-equal-constant-time/.npmignore
generated
vendored
@@ -1,2 +0,0 @@
|
||||
.*.sw[mnop]
|
||||
node_modules/
|
||||
4
node_modules/buffer-equal-constant-time/.travis.yml
generated
vendored
4
node_modules/buffer-equal-constant-time/.travis.yml
generated
vendored
@@ -1,4 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
12
node_modules/buffer-equal-constant-time/LICENSE.txt
generated
vendored
12
node_modules/buffer-equal-constant-time/LICENSE.txt
generated
vendored
@@ -1,12 +0,0 @@
|
||||
Copyright (c) 2013, GoInstant Inc., a salesforce.com company
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of salesforce.com, nor GoInstant, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
50
node_modules/buffer-equal-constant-time/README.md
generated
vendored
50
node_modules/buffer-equal-constant-time/README.md
generated
vendored
@@ -1,50 +0,0 @@
|
||||
# buffer-equal-constant-time
|
||||
|
||||
Constant-time `Buffer` comparison for node.js. Should work with browserify too.
|
||||
|
||||
[](https://travis-ci.org/goinstant/buffer-equal-constant-time)
|
||||
|
||||
```sh
|
||||
npm install buffer-equal-constant-time
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
```js
|
||||
var bufferEq = require('buffer-equal-constant-time');
|
||||
|
||||
var a = new Buffer('asdf');
|
||||
var b = new Buffer('asdf');
|
||||
if (bufferEq(a,b)) {
|
||||
// the same!
|
||||
} else {
|
||||
// different in at least one byte!
|
||||
}
|
||||
```
|
||||
|
||||
If you'd like to install an `.equal()` method onto the node.js `Buffer` and
|
||||
`SlowBuffer` prototypes:
|
||||
|
||||
```js
|
||||
require('buffer-equal-constant-time').install();
|
||||
|
||||
var a = new Buffer('asdf');
|
||||
var b = new Buffer('asdf');
|
||||
if (a.equal(b)) {
|
||||
// the same!
|
||||
} else {
|
||||
// different in at least one byte!
|
||||
}
|
||||
```
|
||||
|
||||
To get rid of the installed `.equal()` method, call `.restore()`:
|
||||
|
||||
```js
|
||||
require('buffer-equal-constant-time').restore();
|
||||
```
|
||||
|
||||
# Legal
|
||||
|
||||
© 2013 GoInstant Inc., a salesforce.com company
|
||||
|
||||
Licensed under the BSD 3-clause license.
|
||||
41
node_modules/buffer-equal-constant-time/index.js
generated
vendored
41
node_modules/buffer-equal-constant-time/index.js
generated
vendored
@@ -1,41 +0,0 @@
|
||||
/*jshint node:true */
|
||||
'use strict';
|
||||
var Buffer = require('buffer').Buffer; // browserify
|
||||
var SlowBuffer = require('buffer').SlowBuffer;
|
||||
|
||||
module.exports = bufferEq;
|
||||
|
||||
function bufferEq(a, b) {
|
||||
|
||||
// shortcutting on type is necessary for correctness
|
||||
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// buffer sizes should be well-known information, so despite this
|
||||
// shortcutting, it doesn't leak any information about the *contents* of the
|
||||
// buffers.
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var c = 0;
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
/*jshint bitwise:false */
|
||||
c |= a[i] ^ b[i]; // XOR
|
||||
}
|
||||
return c === 0;
|
||||
}
|
||||
|
||||
bufferEq.install = function() {
|
||||
Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
|
||||
return bufferEq(this, that);
|
||||
};
|
||||
};
|
||||
|
||||
var origBufEqual = Buffer.prototype.equal;
|
||||
var origSlowBufEqual = SlowBuffer.prototype.equal;
|
||||
bufferEq.restore = function() {
|
||||
Buffer.prototype.equal = origBufEqual;
|
||||
SlowBuffer.prototype.equal = origSlowBufEqual;
|
||||
};
|
||||
25
node_modules/buffer-equal-constant-time/package.json
generated
vendored
25
node_modules/buffer-equal-constant-time/package.json
generated
vendored
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "buffer-equal-constant-time",
|
||||
"version": "1.0.1",
|
||||
"description": "Constant-time comparison of Buffers",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha test.js"
|
||||
},
|
||||
"repository": "git@github.com:goinstant/buffer-equal-constant-time.git",
|
||||
"keywords": [
|
||||
"buffer",
|
||||
"equal",
|
||||
"constant-time",
|
||||
"crypto"
|
||||
],
|
||||
"author": "GoInstant Inc., a salesforce.com company",
|
||||
"license": "BSD-3-Clause",
|
||||
"devDependencies": {
|
||||
"mocha": "~1.15.1"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz"
|
||||
,"_integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk="
|
||||
,"_from": "buffer-equal-constant-time@1.0.1"
|
||||
}
|
||||
42
node_modules/buffer-equal-constant-time/test.js
generated
vendored
42
node_modules/buffer-equal-constant-time/test.js
generated
vendored
@@ -1,42 +0,0 @@
|
||||
/*jshint node:true */
|
||||
'use strict';
|
||||
|
||||
var bufferEq = require('./index');
|
||||
var assert = require('assert');
|
||||
|
||||
describe('buffer-equal-constant-time', function() {
|
||||
var a = new Buffer('asdfasdf123456');
|
||||
var b = new Buffer('asdfasdf123456');
|
||||
var c = new Buffer('asdfasdf');
|
||||
|
||||
describe('bufferEq', function() {
|
||||
it('says a == b', function() {
|
||||
assert.strictEqual(bufferEq(a, b), true);
|
||||
});
|
||||
|
||||
it('says a != c', function() {
|
||||
assert.strictEqual(bufferEq(a, c), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('install/restore', function() {
|
||||
before(function() {
|
||||
bufferEq.install();
|
||||
});
|
||||
after(function() {
|
||||
bufferEq.restore();
|
||||
});
|
||||
|
||||
it('installed an .equal method', function() {
|
||||
var SlowBuffer = require('buffer').SlowBuffer;
|
||||
assert.ok(Buffer.prototype.equal);
|
||||
assert.ok(SlowBuffer.prototype.equal);
|
||||
});
|
||||
|
||||
it('infected existing Buffers', function() {
|
||||
assert.strictEqual(a.equal(b), true);
|
||||
assert.strictEqual(a.equal(c), false);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
4
node_modules/busboy/package.json
generated
vendored
4
node_modules/busboy/package.json
generated
vendored
@@ -14,8 +14,4 @@
|
||||
"keywords": [ "uploads", "forms", "multipart", "form-data" ],
|
||||
"licenses": [ { "type": "MIT", "url": "http://github.com/mscdex/busboy/raw/master/LICENSE" } ],
|
||||
"repository" : { "type": "git", "url": "http://github.com/mscdex/busboy.git" }
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz"
|
||||
,"_integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM="
|
||||
,"_from": "busboy@0.2.14"
|
||||
}
|
||||
10
node_modules/bytes/History.md
generated
vendored
10
node_modules/bytes/History.md
generated
vendored
@@ -1,3 +1,13 @@
|
||||
3.1.2 / 2022-01-27
|
||||
==================
|
||||
|
||||
* Fix return value for un-parsable strings
|
||||
|
||||
3.1.1 / 2021-11-15
|
||||
==================
|
||||
|
||||
* Fix "thousandsSeparator" incorrecting formatting fractional part
|
||||
|
||||
3.1.0 / 2019-01-22
|
||||
==================
|
||||
|
||||
|
||||
56
node_modules/bytes/Readme.md
generated
vendored
56
node_modules/bytes/Readme.md
generated
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
|
||||
@@ -23,6 +23,33 @@ $ npm install bytes
|
||||
var bytes = require('bytes');
|
||||
```
|
||||
|
||||
#### bytes(number|string value, [options]): number|string|null
|
||||
|
||||
Default export function. Delegates to either `bytes.format` or `bytes.parse` based on the type of `value`.
|
||||
|
||||
**Arguments**
|
||||
|
||||
| Name | Type | Description |
|
||||
|---------|----------|--------------------|
|
||||
| value | `number`|`string` | Number value to format or string value to parse |
|
||||
| options | `Object` | Conversion options for `format` |
|
||||
|
||||
**Returns**
|
||||
|
||||
| Name | Type | Description |
|
||||
|---------|------------------|-------------------------------------------------|
|
||||
| results | `string`|`number`|`null` | Return null upon error. Numeric value in bytes, or string value otherwise. |
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
bytes(1024);
|
||||
// output: '1KB'
|
||||
|
||||
bytes('1KB');
|
||||
// output: 1024
|
||||
```
|
||||
|
||||
#### bytes.format(number value, [options]): string|null
|
||||
|
||||
Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
|
||||
@@ -41,7 +68,7 @@ Format the given value in bytes into a string. If the value is negative, it is k
|
||||
|-------------------|--------|-----------------------------------------------------------------------------------------|
|
||||
| decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. |
|
||||
| fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` |
|
||||
| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `.`... Default value to `''`. |
|
||||
| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `'.'`... Default value to `''`. |
|
||||
| unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
|
||||
| unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. |
|
||||
|
||||
@@ -54,21 +81,20 @@ Format the given value in bytes into a string. If the value is negative, it is k
|
||||
**Example**
|
||||
|
||||
```js
|
||||
bytes(1024);
|
||||
bytes.format(1024);
|
||||
// output: '1KB'
|
||||
|
||||
bytes(1000);
|
||||
bytes.format(1000);
|
||||
// output: '1000B'
|
||||
|
||||
bytes(1000, {thousandsSeparator: ' '});
|
||||
bytes.format(1000, {thousandsSeparator: ' '});
|
||||
// output: '1 000B'
|
||||
|
||||
bytes(1024 * 1.7, {decimalPlaces: 0});
|
||||
bytes.format(1024 * 1.7, {decimalPlaces: 0});
|
||||
// output: '2KB'
|
||||
|
||||
bytes(1024, {unitSeparator: ' '});
|
||||
bytes.format(1024, {unitSeparator: ' '});
|
||||
// output: '1 KB'
|
||||
|
||||
```
|
||||
|
||||
#### bytes.parse(string|number value): number|null
|
||||
@@ -102,25 +128,25 @@ The units are in powers of two, not ten. This means 1kb = 1024b according to thi
|
||||
**Example**
|
||||
|
||||
```js
|
||||
bytes('1KB');
|
||||
bytes.parse('1KB');
|
||||
// output: 1024
|
||||
|
||||
bytes('1024');
|
||||
bytes.parse('1024');
|
||||
// output: 1024
|
||||
|
||||
bytes(1024);
|
||||
// output: 1KB
|
||||
bytes.parse(1024);
|
||||
// output: 1024
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci
|
||||
[ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
|
||||
[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
|
||||
[downloads-image]: https://badgen.net/npm/dm/bytes
|
||||
[downloads-url]: https://npmjs.org/package/bytes
|
||||
[npm-image]: https://badgen.net/npm/node/bytes
|
||||
[npm-image]: https://badgen.net/npm/v/bytes
|
||||
[npm-url]: https://npmjs.org/package/bytes
|
||||
[travis-image]: https://badgen.net/travis/visionmedia/bytes.js/master
|
||||
[travis-url]: https://travis-ci.org/visionmedia/bytes.js
|
||||
|
||||
10
node_modules/bytes/index.js
generated
vendored
10
node_modules/bytes/index.js
generated
vendored
@@ -117,7 +117,11 @@ function format(value, options) {
|
||||
}
|
||||
|
||||
if (thousandsSeparator) {
|
||||
str = str.replace(formatThousandsRegExp, thousandsSeparator);
|
||||
str = str.split('.').map(function (s, i) {
|
||||
return i === 0
|
||||
? s.replace(formatThousandsRegExp, thousandsSeparator)
|
||||
: s
|
||||
}).join('.');
|
||||
}
|
||||
|
||||
return str + unitSeparator + unit;
|
||||
@@ -158,5 +162,9 @@ function parse(val) {
|
||||
unit = results[4].toLowerCase();
|
||||
}
|
||||
|
||||
if (isNaN(floatValue)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Math.floor(map[unit] * floatValue);
|
||||
}
|
||||
|
||||
15
node_modules/bytes/package.json
generated
vendored
15
node_modules/bytes/package.json
generated
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "bytes",
|
||||
"description": "Utility to parse a string bytes to bytes and vice-versa",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.2",
|
||||
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
|
||||
"contributors": [
|
||||
"Jed Watson <jed.watson@me.com>",
|
||||
@@ -19,9 +19,10 @@
|
||||
],
|
||||
"repository": "visionmedia/bytes.js",
|
||||
"devDependencies": {
|
||||
"eslint": "5.12.1",
|
||||
"mocha": "5.2.0",
|
||||
"nyc": "13.1.0"
|
||||
"eslint": "7.32.0",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"mocha": "9.2.0",
|
||||
"nyc": "15.1.0"
|
||||
},
|
||||
"files": [
|
||||
"History.md",
|
||||
@@ -35,11 +36,7 @@
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --check-leaks --reporter spec",
|
||||
"test-ci": "nyc --reporter=text npm test",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz"
|
||||
,"_integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
|
||||
,"_from": "bytes@3.1.0"
|
||||
}
|
||||
21
node_modules/cacheable-request/LICENSE
generated
vendored
21
node_modules/cacheable-request/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
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.
|
||||
206
node_modules/cacheable-request/README.md
generated
vendored
206
node_modules/cacheable-request/README.md
generated
vendored
@@ -1,206 +0,0 @@
|
||||
# cacheable-request
|
||||
|
||||
> Wrap native HTTP requests with RFC compliant cache support
|
||||
|
||||
[](https://travis-ci.org/lukechilds/cacheable-request)
|
||||
[](https://coveralls.io/github/lukechilds/cacheable-request?branch=master)
|
||||
[](https://www.npmjs.com/package/cacheable-request)
|
||||
[](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 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 @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.
|
||||
- Any [`http-cache-semantics`](https://github.com/kornelski/http-cache-semantics#constructor-options) options.
|
||||
- Any of the following:
|
||||
|
||||
###### 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 `true` once a cached resource has expired it is deleted and will have to be re-requested.
|
||||
|
||||
If set to `false` (default), 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.
|
||||
|
||||
###### opts.maxTtl
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `undefined`
|
||||
|
||||
Limits TTL. The `number` represents milliseconds.
|
||||
|
||||
###### 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.
|
||||
|
||||
###### opts.forceRefresh
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Forces refreshing the cache. If the response could be retrieved from the cache, it will perform a new request and override the cache instead.
|
||||
|
||||
##### 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
|
||||
52
node_modules/cacheable-request/node_modules/get-stream/buffer-stream.js
generated
vendored
52
node_modules/cacheable-request/node_modules/get-stream/buffer-stream.js
generated
vendored
@@ -1,52 +0,0 @@
|
||||
'use strict';
|
||||
const {PassThrough: PassThroughStream} = require('stream');
|
||||
|
||||
module.exports = options => {
|
||||
options = {...options};
|
||||
|
||||
const {array} = options;
|
||||
let {encoding} = options;
|
||||
const isBuffer = encoding === 'buffer';
|
||||
let objectMode = false;
|
||||
|
||||
if (array) {
|
||||
objectMode = !(encoding || isBuffer);
|
||||
} else {
|
||||
encoding = encoding || 'utf8';
|
||||
}
|
||||
|
||||
if (isBuffer) {
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
const stream = new PassThroughStream({objectMode});
|
||||
|
||||
if (encoding) {
|
||||
stream.setEncoding(encoding);
|
||||
}
|
||||
|
||||
let length = 0;
|
||||
const chunks = [];
|
||||
|
||||
stream.on('data', chunk => {
|
||||
chunks.push(chunk);
|
||||
|
||||
if (objectMode) {
|
||||
length = chunks.length;
|
||||
} else {
|
||||
length += chunk.length;
|
||||
}
|
||||
});
|
||||
|
||||
stream.getBufferedValue = () => {
|
||||
if (array) {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
|
||||
};
|
||||
|
||||
stream.getBufferedLength = () => length;
|
||||
|
||||
return stream;
|
||||
};
|
||||
108
node_modules/cacheable-request/node_modules/get-stream/index.d.ts
generated
vendored
108
node_modules/cacheable-request/node_modules/get-stream/index.d.ts
generated
vendored
@@ -1,108 +0,0 @@
|
||||
/// <reference types="node"/>
|
||||
import {Stream} from 'stream';
|
||||
|
||||
declare class MaxBufferErrorClass extends Error {
|
||||
readonly name: 'MaxBufferError';
|
||||
constructor();
|
||||
}
|
||||
|
||||
declare namespace getStream {
|
||||
interface Options {
|
||||
/**
|
||||
Maximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected with a `MaxBufferError` error.
|
||||
|
||||
@default Infinity
|
||||
*/
|
||||
readonly maxBuffer?: number;
|
||||
}
|
||||
|
||||
interface OptionsWithEncoding<EncodingType = BufferEncoding> extends Options {
|
||||
/**
|
||||
[Encoding](https://nodejs.org/api/buffer.html#buffer_buffer) of the incoming stream.
|
||||
|
||||
@default 'utf8'
|
||||
*/
|
||||
readonly encoding?: EncodingType;
|
||||
}
|
||||
|
||||
type MaxBufferError = MaxBufferErrorClass;
|
||||
}
|
||||
|
||||
declare const getStream: {
|
||||
/**
|
||||
Get the `stream` as a string.
|
||||
|
||||
@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.
|
||||
|
||||
@example
|
||||
```
|
||||
import * as fs from 'fs';
|
||||
import getStream = require('get-stream');
|
||||
|
||||
(async () => {
|
||||
const stream = fs.createReadStream('unicorn.txt');
|
||||
|
||||
console.log(await getStream(stream));
|
||||
// ,,))))))));,
|
||||
// __)))))))))))))),
|
||||
// \|/ -\(((((''''((((((((.
|
||||
// -*-==//////(('' . `)))))),
|
||||
// /|\ ))| o ;-. '((((( ,(,
|
||||
// ( `| / ) ;))))' ,_))^;(~
|
||||
// | | | ,))((((_ _____------~~~-. %,;(;(>';'~
|
||||
// o_); ; )))(((` ~---~ `:: \ %%~~)(v;(`('~
|
||||
// ; ''''```` `: `:::|\,__,%% );`'; ~
|
||||
// | _ ) / `:|`----' `-'
|
||||
// ______/\/~ | / /
|
||||
// /~;;.____/;;' / ___--,-( `;;;/
|
||||
// / // _;______;'------~~~~~ /;;/\ /
|
||||
// // | | / ; \;;,\
|
||||
// (<_ | ; /',/-----' _>
|
||||
// \_| ||_ //~;~~~~~~~~~
|
||||
// `\_| (,~~
|
||||
// \~\
|
||||
// ~~
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(stream: Stream, options?: getStream.OptionsWithEncoding): Promise<string>;
|
||||
|
||||
/**
|
||||
Get the `stream` as a buffer.
|
||||
|
||||
It honors the `maxBuffer` option as above, but it refers to byte length rather than string length.
|
||||
*/
|
||||
buffer(
|
||||
stream: Stream,
|
||||
options?: getStream.OptionsWithEncoding
|
||||
): Promise<Buffer>;
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
array<StreamObjectModeType>(
|
||||
stream: Stream,
|
||||
options?: getStream.Options
|
||||
): Promise<StreamObjectModeType[]>;
|
||||
array(
|
||||
stream: Stream,
|
||||
options: getStream.OptionsWithEncoding<'buffer'>
|
||||
): Promise<Buffer[]>;
|
||||
array(
|
||||
stream: Stream,
|
||||
options: getStream.OptionsWithEncoding<BufferEncoding>
|
||||
): Promise<string[]>;
|
||||
|
||||
MaxBufferError: typeof MaxBufferErrorClass;
|
||||
|
||||
// TODO: Remove this for the next major release
|
||||
default: typeof getStream;
|
||||
};
|
||||
|
||||
export = getStream;
|
||||
60
node_modules/cacheable-request/node_modules/get-stream/index.js
generated
vendored
60
node_modules/cacheable-request/node_modules/get-stream/index.js
generated
vendored
@@ -1,60 +0,0 @@
|
||||
'use strict';
|
||||
const {constants: BufferConstants} = require('buffer');
|
||||
const pump = require('pump');
|
||||
const bufferStream = require('./buffer-stream');
|
||||
|
||||
class MaxBufferError extends Error {
|
||||
constructor() {
|
||||
super('maxBuffer exceeded');
|
||||
this.name = 'MaxBufferError';
|
||||
}
|
||||
}
|
||||
|
||||
async function getStream(inputStream, options) {
|
||||
if (!inputStream) {
|
||||
return Promise.reject(new Error('Expected a stream'));
|
||||
}
|
||||
|
||||
options = {
|
||||
maxBuffer: Infinity,
|
||||
...options
|
||||
};
|
||||
|
||||
const {maxBuffer} = options;
|
||||
|
||||
let stream;
|
||||
await new Promise((resolve, reject) => {
|
||||
const rejectPromise = error => {
|
||||
// Don't retrieve an oversized buffer.
|
||||
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
||||
error.bufferedData = stream.getBufferedValue();
|
||||
}
|
||||
|
||||
reject(error);
|
||||
};
|
||||
|
||||
stream = pump(inputStream, bufferStream(options), error => {
|
||||
if (error) {
|
||||
rejectPromise(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
|
||||
stream.on('data', () => {
|
||||
if (stream.getBufferedLength() > maxBuffer) {
|
||||
rejectPromise(new MaxBufferError());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return stream.getBufferedValue();
|
||||
}
|
||||
|
||||
module.exports = getStream;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = getStream;
|
||||
module.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'});
|
||||
module.exports.array = (stream, options) => getStream(stream, {...options, array: true});
|
||||
module.exports.MaxBufferError = MaxBufferError;
|
||||
9
node_modules/cacheable-request/node_modules/get-stream/license
generated
vendored
9
node_modules/cacheable-request/node_modules/get-stream/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://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.
|
||||
82
node_modules/cacheable-request/node_modules/get-stream/package.json
generated
vendored
82
node_modules/cacheable-request/node_modules/get-stream/package.json
generated
vendored
@@ -1,82 +0,0 @@
|
||||
{
|
||||
"_from": "get-stream@^5.1.0",
|
||||
"_id": "get-stream@5.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
|
||||
"_location": "/cacheable-request/get-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "get-stream@^5.1.0",
|
||||
"name": "get-stream",
|
||||
"escapedName": "get-stream",
|
||||
"rawSpec": "^5.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cacheable-request"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
|
||||
"_shasum": "4966a1795ee5ace65e706c4b7beb71257d6e22d3",
|
||||
"_spec": "get-stream@^5.1.0",
|
||||
"_where": "C:\\Users\\Jonasz\\Desktop\\Menui\\menui_backend\\node_modules\\cacheable-request",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/get-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"pump": "^3.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Get a stream as a string, buffer, or array",
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.0.7",
|
||||
"ava": "^2.0.0",
|
||||
"into-stream": "^5.0.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"buffer-stream.js"
|
||||
],
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"homepage": "https://github.com/sindresorhus/get-stream#readme",
|
||||
"keywords": [
|
||||
"get",
|
||||
"stream",
|
||||
"promise",
|
||||
"concat",
|
||||
"string",
|
||||
"text",
|
||||
"buffer",
|
||||
"read",
|
||||
"data",
|
||||
"consume",
|
||||
"readable",
|
||||
"readablestream",
|
||||
"array",
|
||||
"object"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "get-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/get-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "5.2.0"
|
||||
}
|
||||
124
node_modules/cacheable-request/node_modules/get-stream/readme.md
generated
vendored
124
node_modules/cacheable-request/node_modules/get-stream/readme.md
generated
vendored
@@ -1,124 +0,0 @@
|
||||
# get-stream [](https://travis-ci.com/github/sindresorhus/get-stream)
|
||||
|
||||
> Get a stream as a string, buffer, or array
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install get-stream
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const getStream = require('get-stream');
|
||||
|
||||
(async () => {
|
||||
const stream = fs.createReadStream('unicorn.txt');
|
||||
|
||||
console.log(await getStream(stream));
|
||||
/*
|
||||
,,))))))));,
|
||||
__)))))))))))))),
|
||||
\|/ -\(((((''''((((((((.
|
||||
-*-==//////(('' . `)))))),
|
||||
/|\ ))| 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
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### encoding
|
||||
|
||||
Type: `string`\
|
||||
Default: `'utf8'`
|
||||
|
||||
[Encoding](https://nodejs.org/api/buffer.html#buffer_buffer) of the incoming stream.
|
||||
|
||||
##### maxBuffer
|
||||
|
||||
Type: `number`\
|
||||
Default: `Infinity`
|
||||
|
||||
Maximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected with a `getStream.MaxBufferError` error.
|
||||
|
||||
### 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
|
||||
(async () => {
|
||||
try {
|
||||
await getStream(streamThatErrorsAtTheEnd('unicorn'));
|
||||
} catch (error) {
|
||||
console.log(error.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
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-get-stream?utm_source=npm-get-stream&utm_medium=referral&utm_campaign=readme">Get professional support for this package 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>
|
||||
16
node_modules/cacheable-request/node_modules/lowercase-keys/index.d.ts
generated
vendored
16
node_modules/cacheable-request/node_modules/lowercase-keys/index.d.ts
generated
vendored
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
Lowercase the keys of an object.
|
||||
|
||||
@returns A new object with the keys lowercased.
|
||||
|
||||
@example
|
||||
```
|
||||
import lowercaseKeys = require('lowercase-keys');
|
||||
|
||||
lowercaseKeys({FOO: true, bAr: false});
|
||||
//=> {foo: true, bar: false}
|
||||
```
|
||||
*/
|
||||
declare function lowercaseKeys<T extends unknown>(object: {[key: string]: T}): {[key: string]: T};
|
||||
|
||||
export = lowercaseKeys;
|
||||
10
node_modules/cacheable-request/node_modules/lowercase-keys/index.js
generated
vendored
10
node_modules/cacheable-request/node_modules/lowercase-keys/index.js
generated
vendored
@@ -1,10 +0,0 @@
|
||||
'use strict';
|
||||
module.exports = object => {
|
||||
const result = {};
|
||||
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
result[key.toLowerCase()] = value;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
9
node_modules/cacheable-request/node_modules/lowercase-keys/license
generated
vendored
9
node_modules/cacheable-request/node_modules/lowercase-keys/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
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.
|
||||
42
node_modules/cacheable-request/node_modules/lowercase-keys/package.json
generated
vendored
42
node_modules/cacheable-request/node_modules/lowercase-keys/package.json
generated
vendored
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"name": "lowercase-keys",
|
||||
"version": "2.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": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"object",
|
||||
"assign",
|
||||
"extend",
|
||||
"properties",
|
||||
"lowercase",
|
||||
"lower-case",
|
||||
"case",
|
||||
"keys",
|
||||
"key"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz"
|
||||
,"_integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA=="
|
||||
,"_from": "lowercase-keys@2.0.0"
|
||||
}
|
||||
32
node_modules/cacheable-request/node_modules/lowercase-keys/readme.md
generated
vendored
32
node_modules/cacheable-request/node_modules/lowercase-keys/readme.md
generated
vendored
@@ -1,32 +0,0 @@
|
||||
# lowercase-keys [](https://travis-ci.org/sindresorhus/lowercase-keys)
|
||||
|
||||
> Lowercase the keys of an object
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install lowercase-keys
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const lowercaseKeys = require('lowercase-keys');
|
||||
|
||||
lowercaseKeys({FOO: true, bAr: false});
|
||||
//=> {foo: true, bar: false}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### lowercaseKeys(object)
|
||||
|
||||
Returns a new object with the keys lowercased.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
60
node_modules/cacheable-request/package.json
generated
vendored
60
node_modules/cacheable-request/package.json
generated
vendored
@@ -1,60 +0,0 @@
|
||||
{
|
||||
"name": "cacheable-request",
|
||||
"version": "6.1.0",
|
||||
"description": "Wrap native HTTP requests with RFC compliant cache support",
|
||||
"license": "MIT",
|
||||
"repository": "lukechilds/cacheable-request",
|
||||
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)",
|
||||
"main": "src/index.js",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"HTTP",
|
||||
"HTTPS",
|
||||
"cache",
|
||||
"caching",
|
||||
"layer",
|
||||
"cacheable",
|
||||
"RFC 7234",
|
||||
"RFC",
|
||||
"7234",
|
||||
"compliant"
|
||||
],
|
||||
"dependencies": {
|
||||
"clone-response": "^1.0.2",
|
||||
"get-stream": "^5.1.0",
|
||||
"http-cache-semantics": "^4.0.0",
|
||||
"keyv": "^3.0.0",
|
||||
"lowercase-keys": "^2.0.0",
|
||||
"normalize-url": "^4.1.0",
|
||||
"responselike": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@keyv/sqlite": "^2.0.0",
|
||||
"ava": "^1.1.0",
|
||||
"coveralls": "^3.0.0",
|
||||
"create-test-server": "3.0.0",
|
||||
"delay": "^4.0.0",
|
||||
"eslint-config-xo-lukechilds": "^1.0.0",
|
||||
"nyc": "^14.1.1",
|
||||
"pify": "^4.0.0",
|
||||
"sqlite3": "^4.0.2",
|
||||
"this": "^1.0.2",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"xo": {
|
||||
"extends": "xo-lukechilds"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz"
|
||||
,"_integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg=="
|
||||
,"_from": "cacheable-request@6.1.0"
|
||||
}
|
||||
251
node_modules/cacheable-request/src/index.js
generated
vendored
251
node_modules/cacheable-request/src/index.js
generated
vendored
@@ -1,251 +0,0 @@
|
||||
'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) => {
|
||||
let url;
|
||||
if (typeof opts === 'string') {
|
||||
url = normalizeUrlObject(urlLib.parse(opts));
|
||||
opts = {};
|
||||
} else if (opts instanceof urlLib.URL) {
|
||||
url = normalizeUrlObject(urlLib.parse(opts.toString()));
|
||||
opts = {};
|
||||
} else {
|
||||
const [pathname, ...searchParts] = (opts.path || '').split('?');
|
||||
const search = searchParts.length > 0 ?
|
||||
`?${searchParts.join('?')}` :
|
||||
'';
|
||||
url = normalizeUrlObject({ ...opts, pathname, search });
|
||||
}
|
||||
|
||||
opts = {
|
||||
headers: {},
|
||||
method: 'GET',
|
||||
cache: true,
|
||||
strictTtl: false,
|
||||
automaticFailover: false,
|
||||
...opts,
|
||||
...urlObjectToRequestOptions(url)
|
||||
};
|
||||
opts.headers = lowercaseKeys(opts.headers);
|
||||
|
||||
const ee = new EventEmitter();
|
||||
const normalizedUrlString = normalizeUrl(
|
||||
urlLib.format(url),
|
||||
{
|
||||
stripWWW: false,
|
||||
removeTrailingSlash: false,
|
||||
stripAuthentication: false
|
||||
}
|
||||
);
|
||||
const key = `${opts.method}:${normalizedUrlString}`;
|
||||
let revalidate = false;
|
||||
let madeRequest = false;
|
||||
|
||||
const makeRequest = opts => {
|
||||
madeRequest = true;
|
||||
let requestErrored = false;
|
||||
let requestErrorCallback;
|
||||
|
||||
const requestErrorPromise = new Promise(resolve => {
|
||||
requestErrorCallback = () => {
|
||||
if (!requestErrored) {
|
||||
requestErrored = true;
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const handler = response => {
|
||||
if (revalidate && !opts.forceRefresh) {
|
||||
response.status = response.statusCode;
|
||||
const revalidatedPolicy = CachePolicy.fromObject(revalidate.cachePolicy).revalidatedPolicy(opts, response);
|
||||
if (!revalidatedPolicy.modified) {
|
||||
const headers = revalidatedPolicy.policy.responseHeaders();
|
||||
response = new Response(revalidate.statusCode, headers, revalidate.body, revalidate.url);
|
||||
response.cachePolicy = revalidatedPolicy.policy;
|
||||
response.fromCache = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!response.fromCache) {
|
||||
response.cachePolicy = new CachePolicy(opts, response, opts);
|
||||
response.fromCache = false;
|
||||
}
|
||||
|
||||
let clonedResponse;
|
||||
if (opts.cache && response.cachePolicy.storable()) {
|
||||
clonedResponse = cloneResponse(response);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const bodyPromise = getStream.buffer(response);
|
||||
|
||||
await Promise.race([
|
||||
requestErrorPromise,
|
||||
new Promise(resolve => response.once('end', resolve))
|
||||
]);
|
||||
|
||||
if (requestErrored) {
|
||||
return;
|
||||
}
|
||||
|
||||
const body = await bodyPromise;
|
||||
|
||||
const value = {
|
||||
cachePolicy: response.cachePolicy.toObject(),
|
||||
url: response.url,
|
||||
statusCode: response.fromCache ? revalidate.statusCode : response.statusCode,
|
||||
body
|
||||
};
|
||||
|
||||
let ttl = opts.strictTtl ? response.cachePolicy.timeToLive() : undefined;
|
||||
if (opts.maxTtl) {
|
||||
ttl = ttl ? Math.min(ttl, opts.maxTtl) : opts.maxTtl;
|
||||
}
|
||||
|
||||
await this.cache.set(key, value, ttl);
|
||||
} catch (error) {
|
||||
ee.emit('error', new CacheableRequest.CacheError(error));
|
||||
}
|
||||
})();
|
||||
} else if (opts.cache && revalidate) {
|
||||
(async () => {
|
||||
try {
|
||||
await this.cache.delete(key);
|
||||
} catch (error) {
|
||||
ee.emit('error', new CacheableRequest.CacheError(error));
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
ee.emit('response', clonedResponse || response);
|
||||
if (typeof cb === 'function') {
|
||||
cb(clonedResponse || response);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
const req = request(opts, handler);
|
||||
req.once('error', requestErrorCallback);
|
||||
req.once('abort', requestErrorCallback);
|
||||
ee.emit('request', req);
|
||||
} catch (error) {
|
||||
ee.emit('error', new CacheableRequest.RequestError(error));
|
||||
}
|
||||
};
|
||||
|
||||
(async () => {
|
||||
const get = async opts => {
|
||||
await Promise.resolve();
|
||||
|
||||
const cacheEntry = opts.cache ? await this.cache.get(key) : undefined;
|
||||
if (typeof cacheEntry === 'undefined') {
|
||||
return makeRequest(opts);
|
||||
}
|
||||
|
||||
const policy = CachePolicy.fromObject(cacheEntry.cachePolicy);
|
||||
if (policy.satisfiesWithoutRevalidation(opts) && !opts.forceRefresh) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
const errorHandler = error => ee.emit('error', new CacheableRequest.CacheError(error));
|
||||
this.cache.once('error', errorHandler);
|
||||
ee.on('response', () => this.cache.removeListener('error', errorHandler));
|
||||
|
||||
try {
|
||||
await get(opts);
|
||||
} catch (error) {
|
||||
if (opts.automaticFailover && !madeRequest) {
|
||||
makeRequest(opts);
|
||||
}
|
||||
|
||||
ee.emit('error', new CacheableRequest.CacheError(error));
|
||||
}
|
||||
})();
|
||||
|
||||
return ee;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function urlObjectToRequestOptions(url) {
|
||||
const options = { ...url };
|
||||
options.path = `${url.pathname || '/'}${url.search || ''}`;
|
||||
delete options.pathname;
|
||||
delete options.search;
|
||||
return options;
|
||||
}
|
||||
|
||||
function normalizeUrlObject(url) {
|
||||
// If url was parsed by url.parse or new URL:
|
||||
// - hostname will be set
|
||||
// - host will be hostname[:port]
|
||||
// - port will be set if it was explicit in the parsed string
|
||||
// Otherwise, url was from request options:
|
||||
// - hostname or host may be set
|
||||
// - host shall not have port encoded
|
||||
return {
|
||||
protocol: url.protocol,
|
||||
auth: url.auth,
|
||||
hostname: url.hostname || url.host || 'localhost',
|
||||
port: url.port,
|
||||
pathname: url.pathname,
|
||||
search: url.search
|
||||
};
|
||||
}
|
||||
|
||||
CacheableRequest.RequestError = class extends Error {
|
||||
constructor(error) {
|
||||
super(error.message);
|
||||
this.name = 'RequestError';
|
||||
Object.assign(this, error);
|
||||
}
|
||||
};
|
||||
|
||||
CacheableRequest.CacheError = class extends Error {
|
||||
constructor(error) {
|
||||
super(error.message);
|
||||
this.name = 'CacheError';
|
||||
Object.assign(this, error);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = CacheableRequest;
|
||||
411
node_modules/chalk/index.d.ts
generated
vendored
411
node_modules/chalk/index.d.ts
generated
vendored
@@ -1,411 +0,0 @@
|
||||
declare const enum LevelEnum {
|
||||
/**
|
||||
All colors disabled.
|
||||
*/
|
||||
None = 0,
|
||||
|
||||
/**
|
||||
Basic 16 colors support.
|
||||
*/
|
||||
Basic = 1,
|
||||
|
||||
/**
|
||||
ANSI 256 colors support.
|
||||
*/
|
||||
Ansi256 = 2,
|
||||
|
||||
/**
|
||||
Truecolor 16 million colors support.
|
||||
*/
|
||||
TrueColor = 3
|
||||
}
|
||||
|
||||
/**
|
||||
Basic foreground colors.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
declare type ForegroundColor =
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'gray'
|
||||
| 'grey'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright';
|
||||
|
||||
/**
|
||||
Basic background colors.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
declare type BackgroundColor =
|
||||
| 'bgBlack'
|
||||
| 'bgRed'
|
||||
| 'bgGreen'
|
||||
| 'bgYellow'
|
||||
| 'bgBlue'
|
||||
| 'bgMagenta'
|
||||
| 'bgCyan'
|
||||
| 'bgWhite'
|
||||
| 'bgGray'
|
||||
| 'bgGrey'
|
||||
| 'bgBlackBright'
|
||||
| 'bgRedBright'
|
||||
| 'bgGreenBright'
|
||||
| 'bgYellowBright'
|
||||
| 'bgBlueBright'
|
||||
| 'bgMagentaBright'
|
||||
| 'bgCyanBright'
|
||||
| 'bgWhiteBright';
|
||||
|
||||
/**
|
||||
Basic colors.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
declare type Color = ForegroundColor | BackgroundColor;
|
||||
|
||||
declare type Modifiers =
|
||||
| 'reset'
|
||||
| 'bold'
|
||||
| 'dim'
|
||||
| 'italic'
|
||||
| 'underline'
|
||||
| 'inverse'
|
||||
| 'hidden'
|
||||
| 'strikethrough'
|
||||
| 'visible';
|
||||
|
||||
declare namespace chalk {
|
||||
type Level = LevelEnum;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
Specify the color support for Chalk.
|
||||
By default, color support is automatically detected based on the environment.
|
||||
*/
|
||||
level?: Level;
|
||||
}
|
||||
|
||||
interface Instance {
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
new (options?: Options): Chalk;
|
||||
}
|
||||
|
||||
/**
|
||||
Detect whether the terminal supports color.
|
||||
*/
|
||||
interface ColorSupport {
|
||||
/**
|
||||
The color level used by Chalk.
|
||||
*/
|
||||
level: Level;
|
||||
|
||||
/**
|
||||
Return whether Chalk supports basic 16 colors.
|
||||
*/
|
||||
hasBasic: boolean;
|
||||
|
||||
/**
|
||||
Return whether Chalk supports ANSI 256 colors.
|
||||
*/
|
||||
has256: boolean;
|
||||
|
||||
/**
|
||||
Return whether Chalk supports Truecolor 16 million colors.
|
||||
*/
|
||||
has16m: boolean;
|
||||
}
|
||||
|
||||
interface ChalkFunction {
|
||||
/**
|
||||
Use a template string.
|
||||
|
||||
@remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
log(chalk`
|
||||
CPU: {red ${cpu.totalPercent}%}
|
||||
RAM: {green ${ram.used / ram.total * 100}%}
|
||||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
||||
`);
|
||||
```
|
||||
*/
|
||||
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
||||
|
||||
(...text: unknown[]): string;
|
||||
}
|
||||
|
||||
interface Chalk extends ChalkFunction {
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
Instance: Instance;
|
||||
|
||||
/**
|
||||
The color support for Chalk.
|
||||
By default, color support is automatically detected based on the environment.
|
||||
*/
|
||||
level: Level;
|
||||
|
||||
/**
|
||||
Use HEX value to set text color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.hex('#DEADED');
|
||||
```
|
||||
*/
|
||||
hex(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use keyword color value to set text color.
|
||||
|
||||
@param color - Keyword value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.keyword('orange');
|
||||
```
|
||||
*/
|
||||
keyword(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use RGB values to set text color.
|
||||
*/
|
||||
rgb(red: number, green: number, blue: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSL values to set text color.
|
||||
*/
|
||||
hsl(hue: number, saturation: number, lightness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSV values to set text color.
|
||||
*/
|
||||
hsv(hue: number, saturation: number, value: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HWB values to set text color.
|
||||
*/
|
||||
hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
||||
|
||||
30 <= code && code < 38 || 90 <= code && code < 98
|
||||
For example, 31 for red, 91 for redBright.
|
||||
*/
|
||||
ansi(code: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
||||
*/
|
||||
ansi256(index: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HEX value to set background color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.bgHex('#DEADED');
|
||||
```
|
||||
*/
|
||||
bgHex(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use keyword color value to set background color.
|
||||
|
||||
@param color - Keyword value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.bgKeyword('orange');
|
||||
```
|
||||
*/
|
||||
bgKeyword(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use RGB values to set background color.
|
||||
*/
|
||||
bgRgb(red: number, green: number, blue: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSL values to set background color.
|
||||
*/
|
||||
bgHsl(hue: number, saturation: number, lightness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSV values to set background color.
|
||||
*/
|
||||
bgHsv(hue: number, saturation: number, value: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HWB values to set background color.
|
||||
*/
|
||||
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
||||
|
||||
30 <= code && code < 38 || 90 <= code && code < 98
|
||||
For example, 31 for red, 91 for redBright.
|
||||
Use the foreground code, not the background code (for example, not 41, nor 101).
|
||||
*/
|
||||
bgAnsi(code: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
||||
*/
|
||||
bgAnsi256(index: number): Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Resets the current color chain.
|
||||
*/
|
||||
readonly reset: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Make text bold.
|
||||
*/
|
||||
readonly bold: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Emitting only a small amount of light.
|
||||
*/
|
||||
readonly dim: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Make text italic. (Not widely supported)
|
||||
*/
|
||||
readonly italic: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Make text underline. (Not widely supported)
|
||||
*/
|
||||
readonly underline: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Inverse background and foreground colors.
|
||||
*/
|
||||
readonly inverse: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Prints the text, but makes it invisible.
|
||||
*/
|
||||
readonly hidden: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
|
||||
*/
|
||||
readonly strikethrough: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Prints the text only when Chalk has a color support level > 0.
|
||||
Can be useful for things that are purely cosmetic.
|
||||
*/
|
||||
readonly visible: Chalk;
|
||||
|
||||
readonly black: Chalk;
|
||||
readonly red: Chalk;
|
||||
readonly green: Chalk;
|
||||
readonly yellow: Chalk;
|
||||
readonly blue: Chalk;
|
||||
readonly magenta: Chalk;
|
||||
readonly cyan: Chalk;
|
||||
readonly white: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: Chalk;
|
||||
|
||||
readonly blackBright: Chalk;
|
||||
readonly redBright: Chalk;
|
||||
readonly greenBright: Chalk;
|
||||
readonly yellowBright: Chalk;
|
||||
readonly blueBright: Chalk;
|
||||
readonly magentaBright: Chalk;
|
||||
readonly cyanBright: Chalk;
|
||||
readonly whiteBright: Chalk;
|
||||
|
||||
readonly bgBlack: Chalk;
|
||||
readonly bgRed: Chalk;
|
||||
readonly bgGreen: Chalk;
|
||||
readonly bgYellow: Chalk;
|
||||
readonly bgBlue: Chalk;
|
||||
readonly bgMagenta: Chalk;
|
||||
readonly bgCyan: Chalk;
|
||||
readonly bgWhite: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: Chalk;
|
||||
|
||||
readonly bgBlackBright: Chalk;
|
||||
readonly bgRedBright: Chalk;
|
||||
readonly bgGreenBright: Chalk;
|
||||
readonly bgYellowBright: Chalk;
|
||||
readonly bgBlueBright: Chalk;
|
||||
readonly bgMagentaBright: Chalk;
|
||||
readonly bgCyanBright: Chalk;
|
||||
readonly bgWhiteBright: Chalk;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Main Chalk object that allows to chain styles together.
|
||||
Call the last one as a method with a string argument.
|
||||
Order doesn't matter, and later styles take precedent in case of a conflict.
|
||||
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
*/
|
||||
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
||||
supportsColor: chalk.ColorSupport | false;
|
||||
Level: typeof LevelEnum;
|
||||
Color: Color;
|
||||
ForegroundColor: ForegroundColor;
|
||||
BackgroundColor: BackgroundColor;
|
||||
Modifiers: Modifiers;
|
||||
stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
|
||||
};
|
||||
|
||||
export = chalk;
|
||||
9
node_modules/chalk/license
generated
vendored
9
node_modules/chalk/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
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.
|
||||
39
node_modules/chalk/node_modules/has-flag/index.d.ts
generated
vendored
39
node_modules/chalk/node_modules/has-flag/index.d.ts
generated
vendored
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.
|
||||
|
||||
@param flag - CLI flag to look for. The `--` prefix is optional.
|
||||
@param argv - CLI arguments. Default: `process.argv`.
|
||||
@returns Whether the flag exists.
|
||||
|
||||
@example
|
||||
```
|
||||
// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow
|
||||
|
||||
// foo.ts
|
||||
import hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
*/
|
||||
declare function hasFlag(flag: string, argv?: string[]): boolean;
|
||||
|
||||
export = hasFlag;
|
||||
8
node_modules/chalk/node_modules/has-flag/index.js
generated
vendored
8
node_modules/chalk/node_modules/has-flag/index.js
generated
vendored
@@ -1,8 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (flag, argv = process.argv) => {
|
||||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||
const position = argv.indexOf(prefix + flag);
|
||||
const terminatorPosition = argv.indexOf('--');
|
||||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
||||
};
|
||||
9
node_modules/chalk/node_modules/has-flag/license
generated
vendored
9
node_modules/chalk/node_modules/has-flag/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
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.
|
||||
50
node_modules/chalk/node_modules/has-flag/package.json
generated
vendored
50
node_modules/chalk/node_modules/has-flag/package.json
generated
vendored
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "has-flag",
|
||||
"version": "4.0.0",
|
||||
"description": "Check if argv has a specific flag",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/has-flag",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"has",
|
||||
"check",
|
||||
"detect",
|
||||
"contains",
|
||||
"find",
|
||||
"flag",
|
||||
"cli",
|
||||
"command-line",
|
||||
"argv",
|
||||
"process",
|
||||
"arg",
|
||||
"args",
|
||||
"argument",
|
||||
"arguments",
|
||||
"getopt",
|
||||
"minimist",
|
||||
"optimist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz"
|
||||
,"_integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
|
||||
,"_from": "has-flag@4.0.0"
|
||||
}
|
||||
89
node_modules/chalk/node_modules/has-flag/readme.md
generated
vendored
89
node_modules/chalk/node_modules/has-flag/readme.md
generated
vendored
@@ -1,89 +0,0 @@
|
||||
# has-flag [](https://travis-ci.org/sindresorhus/has-flag)
|
||||
|
||||
> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
|
||||
|
||||
Correctly stops looking after an `--` argument terminator.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-has-flag?utm_source=npm-has-flag&utm_medium=referral&utm_campaign=readme">Get professional support for this package 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 has-flag
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
|
||||
```
|
||||
$ node foo.js -f --unicorn --foo=bar -- --rainbow
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### hasFlag(flag, [argv])
|
||||
|
||||
Returns a boolean for whether the flag exists.
|
||||
|
||||
#### flag
|
||||
|
||||
Type: `string`
|
||||
|
||||
CLI flag to look for. The `--` prefix is optional.
|
||||
|
||||
#### argv
|
||||
|
||||
Type: `string[]`<br>
|
||||
Default: `process.argv`
|
||||
|
||||
CLI arguments.
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
5
node_modules/chalk/node_modules/supports-color/browser.js
generated
vendored
5
node_modules/chalk/node_modules/supports-color/browser.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
stdout: false,
|
||||
stderr: false
|
||||
};
|
||||
135
node_modules/chalk/node_modules/supports-color/index.js
generated
vendored
135
node_modules/chalk/node_modules/supports-color/index.js
generated
vendored
@@ -1,135 +0,0 @@
|
||||
'use strict';
|
||||
const os = require('os');
|
||||
const tty = require('tty');
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
const {env} = process;
|
||||
|
||||
let forceColor;
|
||||
if (hasFlag('no-color') ||
|
||||
hasFlag('no-colors') ||
|
||||
hasFlag('color=false') ||
|
||||
hasFlag('color=never')) {
|
||||
forceColor = 0;
|
||||
} else if (hasFlag('color') ||
|
||||
hasFlag('colors') ||
|
||||
hasFlag('color=true') ||
|
||||
hasFlag('color=always')) {
|
||||
forceColor = 1;
|
||||
}
|
||||
|
||||
if ('FORCE_COLOR' in env) {
|
||||
if (env.FORCE_COLOR === 'true') {
|
||||
forceColor = 1;
|
||||
} else if (env.FORCE_COLOR === 'false') {
|
||||
forceColor = 0;
|
||||
} else {
|
||||
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
||||
}
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3
|
||||
};
|
||||
}
|
||||
|
||||
function supportsColor(haveStream, streamIsTTY) {
|
||||
if (forceColor === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hasFlag('color=16m') ||
|
||||
hasFlag('color=full') ||
|
||||
hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const min = forceColor || 0;
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
||||
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
||||
const osRelease = os.release().split('.');
|
||||
if (
|
||||
Number(osRelease[0]) >= 10 &&
|
||||
Number(osRelease[2]) >= 10586
|
||||
) {
|
||||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (env.COLORTERM === 'truecolor') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app':
|
||||
return version >= 3 ? 3 : 2;
|
||||
case 'Apple_Terminal':
|
||||
return 2;
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
function getSupportLevel(stream) {
|
||||
const level = supportsColor(stream, stream && stream.isTTY);
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supportsColor: getSupportLevel,
|
||||
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
||||
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
||||
};
|
||||
9
node_modules/chalk/node_modules/supports-color/license
generated
vendored
9
node_modules/chalk/node_modules/supports-color/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
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.
|
||||
85
node_modules/chalk/node_modules/supports-color/package.json
generated
vendored
85
node_modules/chalk/node_modules/supports-color/package.json
generated
vendored
@@ -1,85 +0,0 @@
|
||||
{
|
||||
"_from": "supports-color@^7.1.0",
|
||||
"_id": "supports-color@7.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"_location": "/chalk/supports-color",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "supports-color@^7.1.0",
|
||||
"name": "supports-color",
|
||||
"escapedName": "supports-color",
|
||||
"rawSpec": "^7.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^7.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/chalk"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"_shasum": "1b7dcdcb32b8138801b3e478ba6a51caa89648da",
|
||||
"_spec": "supports-color@^7.1.0",
|
||||
"_where": "C:\\Users\\Jonasz\\Desktop\\Menui\\menui_backend\\node_modules\\chalk",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"browser": "browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/supports-color/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Detect whether a terminal supports color",
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"import-fresh": "^3.0.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"browser.js"
|
||||
],
|
||||
"homepage": "https://github.com/chalk/supports-color#readme",
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"ansi",
|
||||
"styles",
|
||||
"tty",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"support",
|
||||
"supports",
|
||||
"capability",
|
||||
"detect",
|
||||
"truecolor",
|
||||
"16m"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "supports-color",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chalk/supports-color.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "7.2.0"
|
||||
}
|
||||
76
node_modules/chalk/node_modules/supports-color/readme.md
generated
vendored
76
node_modules/chalk/node_modules/supports-color/readme.md
generated
vendored
@@ -1,76 +0,0 @@
|
||||
# supports-color [](https://travis-ci.org/chalk/supports-color)
|
||||
|
||||
> Detect whether a terminal supports color
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install supports-color
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor.stdout) {
|
||||
console.log('Terminal stdout supports color');
|
||||
}
|
||||
|
||||
if (supportsColor.stdout.has256) {
|
||||
console.log('Terminal stdout supports 256 colors');
|
||||
}
|
||||
|
||||
if (supportsColor.stderr.has16m) {
|
||||
console.log('Terminal stderr supports 16 million colors (truecolor)');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
|
||||
|
||||
The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
|
||||
|
||||
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
|
||||
- `.level = 2` and `.has256 = true`: 256 color support
|
||||
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
|
||||
|
||||
|
||||
## Info
|
||||
|
||||
It obeys the `--color` and `--no-color` CLI flags.
|
||||
|
||||
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package 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>
|
||||
|
||||
---
|
||||
67
node_modules/chalk/package.json
generated
vendored
67
node_modules/chalk/package.json
generated
vendored
@@ -1,67 +0,0 @@
|
||||
{
|
||||
"name": "chalk",
|
||||
"version": "3.0.0",
|
||||
"description": "Terminal string styling done right",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/chalk",
|
||||
"main": "source",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd",
|
||||
"bench": "matcha benchmark.js"
|
||||
},
|
||||
"files": [
|
||||
"source",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"str",
|
||||
"ansi",
|
||||
"style",
|
||||
"styles",
|
||||
"tty",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"coveralls": "^3.0.7",
|
||||
"execa": "^3.2.0",
|
||||
"import-fresh": "^3.1.0",
|
||||
"matcha": "^0.7.0",
|
||||
"nyc": "^14.1.1",
|
||||
"resolve-from": "^5.0.0",
|
||||
"tsd": "^0.7.4",
|
||||
"xo": "^0.25.3"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"unicorn/prefer-includes": "off"
|
||||
}
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz"
|
||||
,"_integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg=="
|
||||
,"_from": "chalk@3.0.0"
|
||||
}
|
||||
304
node_modules/chalk/readme.md
generated
vendored
304
node_modules/chalk/readme.md
generated
vendored
@@ -1,304 +0,0 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<br>
|
||||
<img width="320" src="media/logo.svg" alt="Chalk">
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</h1>
|
||||
|
||||
> Terminal string styling done right
|
||||
|
||||
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) 
|
||||
|
||||
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
||||
|
||||
|
||||
## Highlights
|
||||
|
||||
- Expressive API
|
||||
- Highly performant
|
||||
- Ability to nest styles
|
||||
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
||||
- Auto-detects color support
|
||||
- Doesn't extend `String.prototype`
|
||||
- Clean and focused
|
||||
- Actively maintained
|
||||
- [Used by ~46,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 1, 2019
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
$ npm install chalk
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
console.log(chalk.blue('Hello world!'));
|
||||
```
|
||||
|
||||
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
const log = console.log;
|
||||
|
||||
// Combine styled and normal strings
|
||||
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
||||
|
||||
// Compose multiple styles using the chainable API
|
||||
log(chalk.blue.bgRed.bold('Hello world!'));
|
||||
|
||||
// Pass in multiple arguments
|
||||
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
||||
|
||||
// Nest styles
|
||||
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
||||
|
||||
// Nest styles of the same type even (color, underline, background)
|
||||
log(chalk.green(
|
||||
'I am a green line ' +
|
||||
chalk.blue.underline.bold('with a blue substring') +
|
||||
' that becomes green again!'
|
||||
));
|
||||
|
||||
// ES2015 template literal
|
||||
log(`
|
||||
CPU: ${chalk.red('90%')}
|
||||
RAM: ${chalk.green('40%')}
|
||||
DISK: ${chalk.yellow('70%')}
|
||||
`);
|
||||
|
||||
// ES2015 tagged template literal
|
||||
log(chalk`
|
||||
CPU: {red ${cpu.totalPercent}%}
|
||||
RAM: {green ${ram.used / ram.total * 100}%}
|
||||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
||||
`);
|
||||
|
||||
// Use RGB colors in terminal emulators that support it.
|
||||
log(chalk.keyword('orange')('Yay for orange colored text!'));
|
||||
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
||||
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
||||
```
|
||||
|
||||
Easily define your own themes:
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
const error = chalk.bold.red;
|
||||
const warning = chalk.keyword('orange');
|
||||
|
||||
console.log(error('Error!'));
|
||||
console.log(warning('Warning!'));
|
||||
```
|
||||
|
||||
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
||||
|
||||
```js
|
||||
const name = 'Sindre';
|
||||
console.log(chalk.green('Hello %s'), name);
|
||||
//=> 'Hello Sindre'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### chalk.`<style>[.<style>...](string, [string...])`
|
||||
|
||||
Example: `chalk.red.bold.underline('Hello', 'world');`
|
||||
|
||||
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
|
||||
Multiple arguments will be separated by space.
|
||||
|
||||
### chalk.level
|
||||
|
||||
Specifies the level of color support.
|
||||
|
||||
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
||||
|
||||
If you need to change this in a reusable module, create a new instance:
|
||||
|
||||
```js
|
||||
const ctx = new chalk.Instance({level: 0});
|
||||
```
|
||||
|
||||
| Level | Description |
|
||||
| :---: | :--- |
|
||||
| `0` | All colors disabled |
|
||||
| `1` | Basic color support (16 colors) |
|
||||
| `2` | 256 color support |
|
||||
| `3` | Truecolor support (16 million colors) |
|
||||
|
||||
### chalk.supportsColor
|
||||
|
||||
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
||||
|
||||
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
### chalk.stderr and chalk.stderr.supportsColor
|
||||
|
||||
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
|
||||
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset` - Resets the current color chain.
|
||||
- `bold` - Make text bold.
|
||||
- `dim` - Emitting only a small amount of light.
|
||||
- `italic` - Make text italic. *(Not widely supported)*
|
||||
- `underline` - Make text underline. *(Not widely supported)*
|
||||
- `inverse`- Inverse background and foreground colors.
|
||||
- `hidden` - Prints the text, but makes it invisible.
|
||||
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
||||
- `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `blackBright` (alias: `gray`, `grey`)
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
|
||||
## Tagged template literal
|
||||
|
||||
Chalk can be used as a [tagged template literal](http://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
const miles = 18;
|
||||
const calculateFeet = miles => miles * 5280;
|
||||
|
||||
console.log(chalk`
|
||||
There are {bold 5280 feet} in a mile.
|
||||
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
|
||||
`);
|
||||
```
|
||||
|
||||
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
||||
|
||||
Template styles are chained exactly like normal Chalk styles. The following two statements are equivalent:
|
||||
|
||||
```js
|
||||
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
||||
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
||||
```
|
||||
|
||||
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
|
||||
|
||||
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
||||
|
||||
|
||||
## 256 and Truecolor color support
|
||||
|
||||
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
||||
|
||||
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
||||
|
||||
Examples:
|
||||
|
||||
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.keyword('orange')('Some orange text')`
|
||||
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
|
||||
|
||||
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.bgKeyword('orange')('Some orange text')`
|
||||
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
The following color models can be used:
|
||||
|
||||
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
||||
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
||||
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
||||
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
||||
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
||||
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
||||
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
||||
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
||||
|
||||
|
||||
## Windows
|
||||
|
||||
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
||||
|
||||
|
||||
## Origin story
|
||||
|
||||
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
||||
|
||||
|
||||
## chalk for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
||||
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
||||
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
||||
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
||||
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
||||
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
||||
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
||||
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
||||
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
||||
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
||||
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
233
node_modules/chalk/source/index.js
generated
vendored
233
node_modules/chalk/source/index.js
generated
vendored
@@ -1,233 +0,0 @@
|
||||
'use strict';
|
||||
const ansiStyles = require('ansi-styles');
|
||||
const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
|
||||
const {
|
||||
stringReplaceAll,
|
||||
stringEncaseCRLFWithFirstIndex
|
||||
} = require('./util');
|
||||
|
||||
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
||||
const levelMapping = [
|
||||
'ansi',
|
||||
'ansi',
|
||||
'ansi256',
|
||||
'ansi16m'
|
||||
];
|
||||
|
||||
const styles = Object.create(null);
|
||||
|
||||
const applyOptions = (object, options = {}) => {
|
||||
if (options.level > 3 || options.level < 0) {
|
||||
throw new Error('The `level` option should be an integer from 0 to 3');
|
||||
}
|
||||
|
||||
// Detect level if not set manually
|
||||
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
||||
object.level = options.level === undefined ? colorLevel : options.level;
|
||||
};
|
||||
|
||||
class ChalkClass {
|
||||
constructor(options) {
|
||||
return chalkFactory(options);
|
||||
}
|
||||
}
|
||||
|
||||
const chalkFactory = options => {
|
||||
const chalk = {};
|
||||
applyOptions(chalk, options);
|
||||
|
||||
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
||||
|
||||
Object.setPrototypeOf(chalk, Chalk.prototype);
|
||||
Object.setPrototypeOf(chalk.template, chalk);
|
||||
|
||||
chalk.template.constructor = () => {
|
||||
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
||||
};
|
||||
|
||||
chalk.template.Instance = ChalkClass;
|
||||
|
||||
return chalk.template;
|
||||
};
|
||||
|
||||
function Chalk(options) {
|
||||
return chalkFactory(options);
|
||||
}
|
||||
|
||||
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
||||
styles[styleName] = {
|
||||
get() {
|
||||
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
||||
Object.defineProperty(this, styleName, {value: builder});
|
||||
return builder;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
styles.visible = {
|
||||
get() {
|
||||
const builder = createBuilder(this, this._styler, true);
|
||||
Object.defineProperty(this, 'visible', {value: builder});
|
||||
return builder;
|
||||
}
|
||||
};
|
||||
|
||||
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
||||
|
||||
for (const model of usedModels) {
|
||||
styles[model] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
||||
return createBuilder(this, styler, this._isEmpty);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
for (const model of usedModels) {
|
||||
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
||||
styles[bgModel] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
||||
return createBuilder(this, styler, this._isEmpty);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const proto = Object.defineProperties(() => {}, {
|
||||
...styles,
|
||||
level: {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this._generator.level;
|
||||
},
|
||||
set(level) {
|
||||
this._generator.level = level;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const createStyler = (open, close, parent) => {
|
||||
let openAll;
|
||||
let closeAll;
|
||||
if (parent === undefined) {
|
||||
openAll = open;
|
||||
closeAll = close;
|
||||
} else {
|
||||
openAll = parent.openAll + open;
|
||||
closeAll = close + parent.closeAll;
|
||||
}
|
||||
|
||||
return {
|
||||
open,
|
||||
close,
|
||||
openAll,
|
||||
closeAll,
|
||||
parent
|
||||
};
|
||||
};
|
||||
|
||||
const createBuilder = (self, _styler, _isEmpty) => {
|
||||
const builder = (...arguments_) => {
|
||||
// Single argument is hot path, implicit coercion is faster than anything
|
||||
// eslint-disable-next-line no-implicit-coercion
|
||||
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
||||
};
|
||||
|
||||
// `__proto__` is used because we must return a function, but there is
|
||||
// no way to create a function with a different prototype
|
||||
builder.__proto__ = proto; // eslint-disable-line no-proto
|
||||
|
||||
builder._generator = self;
|
||||
builder._styler = _styler;
|
||||
builder._isEmpty = _isEmpty;
|
||||
|
||||
return builder;
|
||||
};
|
||||
|
||||
const applyStyle = (self, string) => {
|
||||
if (self.level <= 0 || !string) {
|
||||
return self._isEmpty ? '' : string;
|
||||
}
|
||||
|
||||
let styler = self._styler;
|
||||
|
||||
if (styler === undefined) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const {openAll, closeAll} = styler;
|
||||
if (string.indexOf('\u001B') !== -1) {
|
||||
while (styler !== undefined) {
|
||||
// Replace any instances already present with a re-opening code
|
||||
// otherwise only the part of the string until said closing code
|
||||
// will be colored, and the rest will simply be 'plain'.
|
||||
string = stringReplaceAll(string, styler.close, styler.open);
|
||||
|
||||
styler = styler.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// We can move both next actions out of loop, because remaining actions in loop won't have
|
||||
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
||||
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
||||
const lfIndex = string.indexOf('\n');
|
||||
if (lfIndex !== -1) {
|
||||
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
||||
}
|
||||
|
||||
return openAll + string + closeAll;
|
||||
};
|
||||
|
||||
let template;
|
||||
const chalkTag = (chalk, ...strings) => {
|
||||
const [firstString] = strings;
|
||||
|
||||
if (!Array.isArray(firstString)) {
|
||||
// If chalk() was called by itself or with a string,
|
||||
// return the string itself as a string.
|
||||
return strings.join(' ');
|
||||
}
|
||||
|
||||
const arguments_ = strings.slice(1);
|
||||
const parts = [firstString.raw[0]];
|
||||
|
||||
for (let i = 1; i < firstString.length; i++) {
|
||||
parts.push(
|
||||
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
|
||||
String(firstString.raw[i])
|
||||
);
|
||||
}
|
||||
|
||||
if (template === undefined) {
|
||||
template = require('./templates');
|
||||
}
|
||||
|
||||
return template(chalk, parts.join(''));
|
||||
};
|
||||
|
||||
Object.defineProperties(Chalk.prototype, styles);
|
||||
|
||||
const chalk = Chalk(); // eslint-disable-line new-cap
|
||||
chalk.supportsColor = stdoutColor;
|
||||
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
||||
chalk.stderr.supportsColor = stderrColor;
|
||||
|
||||
// For TypeScript
|
||||
chalk.Level = {
|
||||
None: 0,
|
||||
Basic: 1,
|
||||
Ansi256: 2,
|
||||
TrueColor: 3,
|
||||
0: 'None',
|
||||
1: 'Basic',
|
||||
2: 'Ansi256',
|
||||
3: 'TrueColor'
|
||||
};
|
||||
|
||||
module.exports = chalk;
|
||||
134
node_modules/chalk/source/templates.js
generated
vendored
134
node_modules/chalk/source/templates.js
generated
vendored
@@ -1,134 +0,0 @@
|
||||
'use strict';
|
||||
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
||||
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
||||
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
||||
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
|
||||
|
||||
const ESCAPES = new Map([
|
||||
['n', '\n'],
|
||||
['r', '\r'],
|
||||
['t', '\t'],
|
||||
['b', '\b'],
|
||||
['f', '\f'],
|
||||
['v', '\v'],
|
||||
['0', '\0'],
|
||||
['\\', '\\'],
|
||||
['e', '\u001B'],
|
||||
['a', '\u0007']
|
||||
]);
|
||||
|
||||
function unescape(c) {
|
||||
const u = c[0] === 'u';
|
||||
const bracket = c[1] === '{';
|
||||
|
||||
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
||||
return String.fromCharCode(parseInt(c.slice(1), 16));
|
||||
}
|
||||
|
||||
if (u && bracket) {
|
||||
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
||||
}
|
||||
|
||||
return ESCAPES.get(c) || c;
|
||||
}
|
||||
|
||||
function parseArguments(name, arguments_) {
|
||||
const results = [];
|
||||
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
||||
let matches;
|
||||
|
||||
for (const chunk of chunks) {
|
||||
const number = Number(chunk);
|
||||
if (!Number.isNaN(number)) {
|
||||
results.push(number);
|
||||
} else if ((matches = chunk.match(STRING_REGEX))) {
|
||||
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
||||
} else {
|
||||
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function parseStyle(style) {
|
||||
STYLE_REGEX.lastIndex = 0;
|
||||
|
||||
const results = [];
|
||||
let matches;
|
||||
|
||||
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
||||
const name = matches[1];
|
||||
|
||||
if (matches[2]) {
|
||||
const args = parseArguments(name, matches[2]);
|
||||
results.push([name].concat(args));
|
||||
} else {
|
||||
results.push([name]);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function buildStyle(chalk, styles) {
|
||||
const enabled = {};
|
||||
|
||||
for (const layer of styles) {
|
||||
for (const style of layer.styles) {
|
||||
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
let current = chalk;
|
||||
for (const [styleName, styles] of Object.entries(enabled)) {
|
||||
if (!Array.isArray(styles)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(styleName in current)) {
|
||||
throw new Error(`Unknown Chalk style: ${styleName}`);
|
||||
}
|
||||
|
||||
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
module.exports = (chalk, temporary) => {
|
||||
const styles = [];
|
||||
const chunks = [];
|
||||
let chunk = [];
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
||||
if (escapeCharacter) {
|
||||
chunk.push(unescape(escapeCharacter));
|
||||
} else if (style) {
|
||||
const string = chunk.join('');
|
||||
chunk = [];
|
||||
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
||||
styles.push({inverse, styles: parseStyle(style)});
|
||||
} else if (close) {
|
||||
if (styles.length === 0) {
|
||||
throw new Error('Found extraneous } in Chalk template literal');
|
||||
}
|
||||
|
||||
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
||||
chunk = [];
|
||||
styles.pop();
|
||||
} else {
|
||||
chunk.push(character);
|
||||
}
|
||||
});
|
||||
|
||||
chunks.push(chunk.join(''));
|
||||
|
||||
if (styles.length > 0) {
|
||||
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
return chunks.join('');
|
||||
};
|
||||
39
node_modules/chalk/source/util.js
generated
vendored
39
node_modules/chalk/source/util.js
generated
vendored
@@ -1,39 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const stringReplaceAll = (string, substring, replacer) => {
|
||||
let index = string.indexOf(substring);
|
||||
if (index === -1) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const substringLength = substring.length;
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
||||
endIndex = index + substringLength;
|
||||
index = string.indexOf(substring, endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.substr(endIndex);
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
const gotCR = string[index - 1] === '\r';
|
||||
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
||||
endIndex = index + 1;
|
||||
index = string.indexOf('\n', endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.substr(endIndex);
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
stringReplaceAll,
|
||||
stringEncaseCRLFWithFirstIndex
|
||||
};
|
||||
9
node_modules/chokidar/README.md
generated
vendored
9
node_modules/chokidar/README.md
generated
vendored
@@ -13,6 +13,7 @@ Node.js `fs.watch`:
|
||||
* Often reports events twice.
|
||||
* Emits most changes as `rename`.
|
||||
* Does not provide an easy way to recursively watch file trees.
|
||||
* Does not support recursive watching on Linux.
|
||||
|
||||
Node.js `fs.watchFile`:
|
||||
|
||||
@@ -46,7 +47,7 @@ On MacOS, chokidar by default uses a native extension exposing the Darwin
|
||||
implementations like `kqueue` available on most \*nix platforms. Chokidar still
|
||||
does have to do some work to normalize the events received that way as well.
|
||||
|
||||
On other platforms, the `fs.watch`-based implementation is the default, which
|
||||
On most other platforms, the `fs.watch`-based implementation is the default, which
|
||||
avoids polling and keeps CPU usage down. Be advised that chokidar will initiate
|
||||
watchers recursively for everything within scope of the paths that have been
|
||||
specified, so be judicious about not wasting system resources by watching much
|
||||
@@ -254,8 +255,8 @@ Available events: `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `ready`,
|
||||
Additionally `all` is available which gets emitted with the underlying event
|
||||
name and path for every event other than `ready`, `raw`, and `error`. `raw` is internal, use it carefully.
|
||||
* `.unwatch(path / paths)`: Stop watching files, directories, or glob patterns.
|
||||
Takes an array of strings or just one string. Use with `await` to ensure bugs don't happen.
|
||||
* `.close()`: **async** Removes all listeners from watched files. Asynchronous, returns Promise.
|
||||
Takes an array of strings or just one string.
|
||||
* `.close()`: **async** Removes all listeners from watched files. Asynchronous, returns Promise. Use with `await` to ensure bugs don't happen.
|
||||
* `.getWatched()`: Returns an object representing all the paths on the file
|
||||
system being watched by this `FSWatcher` instance. The object's keys are all the
|
||||
directories (using absolute paths unless the `cwd` option was used), and the
|
||||
@@ -264,7 +265,7 @@ values are arrays of the names of the items contained in each directory.
|
||||
## CLI
|
||||
|
||||
If you need a CLI interface for your file watching, check out
|
||||
[chokidar-cli](https://github.com/kimmobrunfeldt/chokidar-cli), allowing you to
|
||||
[chokidar-cli](https://github.com/open-cli-tools/chokidar-cli), allowing you to
|
||||
execute a command on each change, or get a stdio stream of change events.
|
||||
|
||||
## Install Troubleshooting
|
||||
|
||||
8
node_modules/chokidar/index.js
generated
vendored
8
node_modules/chokidar/index.js
generated
vendored
@@ -48,7 +48,8 @@ const {
|
||||
EMPTY_FN,
|
||||
|
||||
isWindows,
|
||||
isMacos
|
||||
isMacos,
|
||||
isIBMi
|
||||
} = require('./lib/constants');
|
||||
|
||||
const stat = promisify(fs.stat);
|
||||
@@ -330,6 +331,11 @@ constructor(_opts) {
|
||||
opts.usePolling = isMacos;
|
||||
}
|
||||
|
||||
// Always default to polling on IBM i because fs.watch() is not available on IBM i.
|
||||
if(isIBMi) {
|
||||
opts.usePolling = true;
|
||||
}
|
||||
|
||||
// Global override (useful for end-developers that need to force polling for all
|
||||
// instances of chokidar, regardless of usage/dependency depth)
|
||||
const envPoll = process.env.CHOKIDAR_USEPOLLING;
|
||||
|
||||
2
node_modules/chokidar/lib/constants.js
generated
vendored
2
node_modules/chokidar/lib/constants.js
generated
vendored
@@ -2,6 +2,7 @@
|
||||
|
||||
const {sep} = require('path');
|
||||
const {platform} = process;
|
||||
const os = require('os');
|
||||
|
||||
exports.EV_ALL = 'all';
|
||||
exports.EV_READY = 'ready';
|
||||
@@ -61,3 +62,4 @@ exports.IDENTITY_FN = val => val;
|
||||
exports.isWindows = platform === 'win32';
|
||||
exports.isMacos = platform === 'darwin';
|
||||
exports.isLinux = platform === 'linux';
|
||||
exports.isIBMi = os.type() === 'OS400';
|
||||
|
||||
3
node_modules/chokidar/lib/fsevents-handler.js
generated
vendored
3
node_modules/chokidar/lib/fsevents-handler.js
generated
vendored
@@ -104,7 +104,8 @@ const createFSEventsInstance = (path, callback) => {
|
||||
* @returns {Function} closer
|
||||
*/
|
||||
function setFSEventsListener(path, realPath, listener, rawEmitter) {
|
||||
let watchPath = sysPath.extname(path) ? sysPath.dirname(path) : path;
|
||||
let watchPath = sysPath.extname(realPath) ? sysPath.dirname(realPath) : realPath;
|
||||
|
||||
const parentPath = sysPath.dirname(watchPath);
|
||||
let cont = FSEventsWatchers.get(watchPath);
|
||||
|
||||
|
||||
10
node_modules/chokidar/lib/nodefs-handler.js
generated
vendored
10
node_modules/chokidar/lib/nodefs-handler.js
generated
vendored
@@ -421,7 +421,15 @@ async _handleSymlink(entry, directory, path, item) {
|
||||
if (!this.fsw.options.followSymlinks) {
|
||||
// watch symlink directly (don't follow) and detect changes
|
||||
this.fsw._incrReadyCount();
|
||||
const linkPath = await fsrealpath(path);
|
||||
|
||||
let linkPath;
|
||||
try {
|
||||
linkPath = await fsrealpath(path);
|
||||
} catch (e) {
|
||||
this.fsw._emitReady();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.fsw.closed) return;
|
||||
if (dir.has(item)) {
|
||||
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user