init
This commit is contained in:
67
dist/src/array.d.ts
vendored
Normal file
67
dist/src/array.d.ts
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
export declare function addUnique<T>(array: T[], el: T): T[];
|
||||
export declare function arrayDiff(a: any[], b: any[]): any[];
|
||||
/**
|
||||
* Provides a shorthand for sorting arrays of complex objects by a string property
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* let arr = [{a: 'Apple', b: 123}, {a: 'Carrot', b: 789}, {a: 'banana', b: 456}];
|
||||
* arr.sort(caseInsensitiveSort('a'));
|
||||
* ```
|
||||
*
|
||||
* @param {string} prop - Name of property to use, supports dot notation
|
||||
* @returns {(a, b) => (number)} - Function to handle sort (Meant to be passed to Array.prototype.sort or used in sortFn)
|
||||
*/
|
||||
export declare function caseInsensitiveSort(prop: string): (a: any, b: any) => number;
|
||||
/**
|
||||
* Recursively flatten nested arrays
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const arr = [
|
||||
* {label: null, url: '/'},
|
||||
* {label: 'Model Admin', url: '/model-admin'},
|
||||
* [
|
||||
* {label: 'Elements', url: '/model-admin/elements'},
|
||||
* {label: 'Example', url: null}
|
||||
* ]
|
||||
* ];
|
||||
*
|
||||
* console.log(flattenArr(arr));
|
||||
* // Output:
|
||||
* [
|
||||
* {label: null, url: '/'},
|
||||
* {label: 'Model Admin', url: '/model-admin'},
|
||||
* {label: 'Elements', url: '/model-admin/elements'},
|
||||
* {label: 'Example', url: null}
|
||||
* ]
|
||||
* ```
|
||||
*
|
||||
* @param {any[]} arr - n-dimensional array
|
||||
* @param {any[]} result - Internal use only -- Keeps track of recursion
|
||||
* @returns {any[]} - Flattened array
|
||||
*/
|
||||
export declare function flattenArr(arr: any[], result?: any[]): any[];
|
||||
/**
|
||||
* Provides a shorthand for sorting arrays of complex objects
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* let arr = [{a: {b: 2}}, {a: {b: 3}}, {a: {b: 1}}];
|
||||
* arr.sort(sortByProp('a.b'));
|
||||
* ```
|
||||
*
|
||||
* @param {string} prop - Name of property to use, supports dot notation
|
||||
* @param {boolean} reverse - Reverse the order of the sort
|
||||
* @returns {(a, b) => (number)} - Function to handle sort (Meant to be passed to Array.prototype.sort)
|
||||
*/
|
||||
export declare function sortByProp(prop: string, reverse?: boolean): (a: any, b: any) => number;
|
||||
export declare function findByProp(prop: string, value: any): (v: any) => boolean;
|
||||
export declare function makeUnique(arr: any[]): any[];
|
||||
/**
|
||||
* Make sure value is an array, if it isn't wrap it in one.
|
||||
* @param {T[] | T} value Value that should be an array
|
||||
* @returns {T[]} Value in an array
|
||||
*/
|
||||
export declare function makeArray<T>(value: T | T[]): T[];
|
||||
//# sourceMappingURL=array.d.ts.map
|
1
dist/src/array.d.ts.map
vendored
Normal file
1
dist/src/array.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/array.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAGnD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAKnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,OAC3B,GAAG,KAAK,GAAG,YAM/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,MAAM,GAAE,GAAG,EAAO,GAAG,GAAG,EAAE,CAGhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,8BAUvD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,uBAElD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,SAKpC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAEhD"}
|
10
dist/src/emitter.d.ts
vendored
Normal file
10
dist/src/emitter.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export type Listener<T> = (event: T) => any;
|
||||
export declare class Emitter<T> {
|
||||
private listeners;
|
||||
constructor();
|
||||
emit(e: T): void;
|
||||
listen(fn: Listener<T>): () => {};
|
||||
listen(key: string, fn: Listener<T>): () => {};
|
||||
once(fn: Listener<T>): void;
|
||||
}
|
||||
//# sourceMappingURL=emitter.d.ts.map
|
1
dist/src/emitter.d.ts.map
vendored
Normal file
1
dist/src/emitter.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC;AAE5C,qBAAa,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,SAAS,CAAoC;;IAIrD,IAAI,CAAC,CAAC,EAAE,CAAC;IAIT,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE;IACjC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE;IAS9C,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;CAMpB"}
|
36
dist/src/errors.d.ts
vendored
Normal file
36
dist/src/errors.d.ts
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
export declare class CustomError extends Error {
|
||||
static code: number;
|
||||
private _code?;
|
||||
get code(): number;
|
||||
set code(c: number);
|
||||
constructor(message?: string, code?: number);
|
||||
static from(err: Error): CustomError;
|
||||
static instanceof(err: Error): boolean;
|
||||
toString(): string;
|
||||
}
|
||||
export declare class BadRequestError extends CustomError {
|
||||
static code: number;
|
||||
constructor(message?: string);
|
||||
static instanceof(err: Error): boolean;
|
||||
}
|
||||
export declare class UnauthorizedError extends CustomError {
|
||||
static code: number;
|
||||
constructor(message?: string);
|
||||
static instanceof(err: Error): boolean;
|
||||
}
|
||||
export declare class ForbiddenError extends CustomError {
|
||||
static code: number;
|
||||
constructor(message?: string);
|
||||
static instanceof(err: Error): boolean;
|
||||
}
|
||||
export declare class NotFoundError extends CustomError {
|
||||
static code: number;
|
||||
constructor(message?: string);
|
||||
static instanceof(err: Error): boolean;
|
||||
}
|
||||
export declare class InternalServerError extends CustomError {
|
||||
static code: number;
|
||||
constructor(message?: string);
|
||||
static instanceof(err: Error): boolean;
|
||||
}
|
||||
//# sourceMappingURL=errors.d.ts.map
|
1
dist/src/errors.d.ts.map
vendored
Normal file
1
dist/src/errors.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAYA,qBAAa,WAAY,SAAQ,KAAK;IACrC,MAAM,CAAC,IAAI,SAAO;IAElB,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,IAAI,IAAI,IAAI,MAAM,CAAuD;IACzE,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,EAAqB;gBAE3B,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAK3C,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,WAAW;IAUpC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK;IAI5B,QAAQ;CAGR;AAED,qBAAa,eAAgB,SAAQ,WAAW;IAC/C,MAAM,CAAC,IAAI,SAAO;gBAEN,OAAO,GAAE,MAAsB;IAI3C,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK;CAG5B;AAED,qBAAa,iBAAkB,SAAQ,WAAW;IACjD,MAAM,CAAC,IAAI,SAAO;gBAEN,OAAO,GAAE,MAAuB;IAI5C,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK;CAG5B;AAED,qBAAa,cAAe,SAAQ,WAAW;IAC9C,MAAM,CAAC,IAAI,SAAO;gBAEN,OAAO,GAAE,MAAoB;IAIzC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK;CAG5B;AAED,qBAAa,aAAc,SAAQ,WAAW;IAC7C,MAAM,CAAC,IAAI,SAAO;gBAEN,OAAO,GAAE,MAAoB;IAIzC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK;CAG5B;AAED,qBAAa,mBAAoB,SAAQ,WAAW;IACnD,MAAM,CAAC,IAAI,SAAO;gBAEN,OAAO,GAAE,MAAgC;IAIrD,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK;CAG5B"}
|
10
dist/src/index.d.ts
vendored
Normal file
10
dist/src/index.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export * from './array';
|
||||
export * from './emitter';
|
||||
export * from './errors';
|
||||
export * from './logger';
|
||||
export * from './misc';
|
||||
export * from './objects';
|
||||
export * from './string';
|
||||
export * from './time';
|
||||
export * from './xhr';
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/index.d.ts.map
vendored
Normal file
1
dist/src/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAE1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC"}
|
43
dist/src/logger.d.ts
vendored
Normal file
43
dist/src/logger.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
export declare const CliEffects: {
|
||||
CLEAR: string;
|
||||
BRIGHT: string;
|
||||
DIM: string;
|
||||
UNDERSCORE: string;
|
||||
BLINK: string;
|
||||
REVERSE: string;
|
||||
HIDDEN: string;
|
||||
};
|
||||
export declare const CliForeground: {
|
||||
BLACK: string;
|
||||
RED: string;
|
||||
GREEN: string;
|
||||
YELLOW: string;
|
||||
BLUE: string;
|
||||
MAGENTA: string;
|
||||
CYAN: string;
|
||||
WHITE: string;
|
||||
GREY: string;
|
||||
};
|
||||
export declare const CliBackground: {
|
||||
BLACK: string;
|
||||
RED: string;
|
||||
GREEN: string;
|
||||
YELLOW: string;
|
||||
BLUE: string;
|
||||
MAGENTA: string;
|
||||
CYAN: string;
|
||||
WHITE: string;
|
||||
GREY: string;
|
||||
};
|
||||
export declare class Logger {
|
||||
readonly namespace: string;
|
||||
constructor(namespace: string);
|
||||
private format;
|
||||
debug(...args: string[]): void;
|
||||
error(...args: string[]): void;
|
||||
info(...args: string[]): void;
|
||||
log(...args: string[]): void;
|
||||
warn(...args: string[]): void;
|
||||
verbose(...args: string[]): void;
|
||||
}
|
||||
//# sourceMappingURL=logger.d.ts.map
|
1
dist/src/logger.d.ts.map
vendored
Normal file
1
dist/src/logger.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;CAQtB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;CAUzB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;CAUzB,CAAA;AAED,qBAAa,MAAM;aACU,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;IAE7C,OAAO,CAAC,MAAM;IAId,KAAK,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAIvB,KAAK,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAIvB,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAItB,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAIrB,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAItB,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;CAGzB"}
|
34
dist/src/misc.d.ts
vendored
Normal file
34
dist/src/misc.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Convert data into a form encoded format.
|
||||
*
|
||||
* @param {any} data - data to convert
|
||||
* @returns {string} - Ecodeded form data
|
||||
*/
|
||||
export declare function formEncode(data: any): string;
|
||||
/**
|
||||
* Get profile image from Gravatar
|
||||
*
|
||||
* @param {string} email Account email address
|
||||
* @returns {string} Gravatar URL
|
||||
*/
|
||||
export declare function gravatar(email: string): string;
|
||||
/** Parts of a URL */
|
||||
export type ParsedUrl = {
|
||||
protocol?: string;
|
||||
subdomain?: string;
|
||||
domain: string;
|
||||
host: string;
|
||||
port?: number;
|
||||
path?: string;
|
||||
query?: {
|
||||
[name: string]: string;
|
||||
};
|
||||
fragment?: string;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param {string} url
|
||||
* @returns {RegExpExecArray}
|
||||
*/
|
||||
export declare function urlParser(url: string): ParsedUrl;
|
||||
//# sourceMappingURL=misc.d.ts.map
|
1
dist/src/misc.d.ts.map
vendored
Normal file
1
dist/src/misc.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/misc.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAI5C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,UAGrC;AAED,qBAAqB;AACrB,MAAM,MAAM,SAAS,GAAG;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAoBhD"}
|
67
dist/src/objects.d.ts
vendored
Normal file
67
dist/src/objects.d.ts
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Removes any null values from an object in-place
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* let test = {a: 0, b: false, c: null, d: 'abc'}
|
||||
* console.log(clean(test)); // Output: {a: 0, b: false, d: 'abc'}
|
||||
* ```
|
||||
*
|
||||
* @param {T} obj Object reference that will be cleaned
|
||||
* @returns {Partial<T>} Cleaned object
|
||||
*/
|
||||
export declare function clean<T>(obj: T, includeNull?: boolean): Partial<T>;
|
||||
/**
|
||||
* Create a deep copy of an object (vs. a shallow copy of references)
|
||||
*
|
||||
* Should be replaced by `structuredClone` once released.
|
||||
*
|
||||
* @param {T} value Object to copy
|
||||
* @returns {T} Type
|
||||
*/
|
||||
export declare function deepCopy<T>(value: T): T;
|
||||
/**
|
||||
* Get/set a property of an object using dot notation
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Get a value
|
||||
* const name = dotNotation<string>(person, 'firstName');
|
||||
* const familyCarMake = dotNotation(family, 'cars[0].make');
|
||||
* // Set a value
|
||||
* dotNotation(family, 'cars[0].make', 'toyota');
|
||||
* ```
|
||||
*
|
||||
* @type T Return type
|
||||
* @param {Object} obj source object to search
|
||||
* @param {string} prop property name (Dot notation & indexing allowed)
|
||||
* @param {any} set Set object property to value, omit to fetch value instead
|
||||
* @return {T} property value
|
||||
*/
|
||||
export declare function dotNotation<T>(obj: any, prop: string, set: T): T;
|
||||
export declare function dotNotation<T>(obj: any, prop: string): T | undefined;
|
||||
/**
|
||||
* Check that an object has the following values
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const test = {a: 2, b: 2};
|
||||
* includes(test, {a: 1}); // true
|
||||
* includes(test, {b: 1, c: 3}); // false
|
||||
* ```
|
||||
*
|
||||
* @param target Object to search
|
||||
* @param values Criteria to check against
|
||||
* @param allowMissing Only check the keys that are available on the target
|
||||
* @returns {boolean} Does target include all the values
|
||||
*/
|
||||
export declare function includes(target: any, values: any, allowMissing?: boolean): boolean;
|
||||
/**
|
||||
* Deep check if two objects are equal
|
||||
*
|
||||
* @param {any} a - first item to compare
|
||||
* @param {any} b - second item to compare
|
||||
* @returns {boolean} True if they match
|
||||
*/
|
||||
export declare function isEqual(a: any, b: any): boolean;
|
||||
//# sourceMappingURL=objects.d.ts.map
|
1
dist/src/objects.d.ts.map
vendored
Normal file
1
dist/src/objects.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/objects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,UAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAUhE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;AAClE,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;AAgBtE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,UAAQ,GAAG,OAAO,CAUhF;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAO/C"}
|
1
dist/src/redis.d.ts
vendored
Normal file
1
dist/src/redis.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
//# sourceMappingURL=redis.d.ts.map
|
1
dist/src/redis.d.ts.map
vendored
Normal file
1
dist/src/redis.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/redis.ts"],"names":[],"mappings":""}
|
72
dist/src/string.d.ts
vendored
Normal file
72
dist/src/string.d.ts
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
export declare function countChars(text: string, pattern: RegExp): number;
|
||||
export declare function createHex(length: number): string;
|
||||
export declare function formatPhoneNumber(number: string): string;
|
||||
/**
|
||||
* Insert a string into another string at a given position
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* console.log(insertAt('Hello world!', ' glorious', 5);
|
||||
* // Output: Hello glorious world!
|
||||
* ```
|
||||
*
|
||||
* @param {string} target - Parent string you want to modify
|
||||
* @param {string} str - Value that will be injected to parent
|
||||
* @param {number} index - Position to inject string at
|
||||
* @returns {string} - New string
|
||||
*/
|
||||
export declare function insertAt(target: string, str: string, index: number): String;
|
||||
/**
|
||||
* Generate a string of random characters.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const random = randomString();
|
||||
* const randomByte = randomString(8, "01")
|
||||
* ```
|
||||
*
|
||||
* @param {number} length - length of generated string
|
||||
* @param {string} pool - character pool to generate string from
|
||||
* @return {string} generated string
|
||||
*/
|
||||
export declare function randomString(length: number, pool?: string): string;
|
||||
/**
|
||||
* Generate a random string with fine control over letters, numbers & symbols
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const randomLetter = randomString(1, true);
|
||||
* const randomChar = randomString(1, true, true, true);
|
||||
* ```
|
||||
*
|
||||
* @param {number} length - length of generated string
|
||||
* @param {boolean} letters - Add letters to pool
|
||||
* @param {boolean} numbers - Add numbers to pool
|
||||
* @param {boolean} symbols - Add symbols to pool
|
||||
* @return {string} generated string
|
||||
*/
|
||||
export declare function randomStringBuilder(length: number, letters?: boolean, numbers?: boolean, symbols?: boolean): string;
|
||||
/**
|
||||
* Find all substrings that match a given pattern.
|
||||
*
|
||||
* Roughly based on `String.prototype.matchAll`.
|
||||
*
|
||||
* @param {string} value - String to search.
|
||||
* @param {RegExp | string} regex - Regular expression to match.
|
||||
* @return {RegExpExecArray[]} Found matches.
|
||||
*/
|
||||
export declare function matchAll(value: string, regex: RegExp | string): RegExpExecArray[];
|
||||
/**
|
||||
* Create MD5 hash using native javascript
|
||||
* @param d String to hash
|
||||
* @returns {string} Hashed string
|
||||
*/
|
||||
export declare function md5(d: any): string;
|
||||
/**
|
||||
* Check if email is valid
|
||||
*
|
||||
* @param {string} email - Target
|
||||
* @returns {boolean} - Follows format
|
||||
*/
|
||||
export declare function validateEmail(email: string): boolean;
|
||||
//# sourceMappingURL=string.d.ts.map
|
1
dist/src/string.d.ts.map
vendored
Normal file
1
dist/src/string.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/string.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAEvD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,UAEvC;AAwBD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,UAI/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAK7E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,UAAQ,EAAE,OAAO,UAAQ,EAAE,OAAO,UAAQ,GAAG,MAAM,CAgB7G;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,EAAE,CAiBjF;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,KAAA,UACoC;AAGzD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,WAE1C"}
|
25
dist/src/time.d.ts
vendored
Normal file
25
dist/src/time.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Calculate the number of milliseconds until date/time
|
||||
*
|
||||
* @param {Date | number} date - Target
|
||||
* @returns {number} - Number of milliseconds until target
|
||||
*/
|
||||
export declare function timeUntil(date: Date | number): number;
|
||||
/**
|
||||
* Use in conjunction with `await` to pause an async script
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* async () => {
|
||||
* ...
|
||||
* await sleep(1000) // Pause for 1 second
|
||||
* ...
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param {number} ms - Time to pause for in milliseconds
|
||||
* @returns {Promise<unknown>} - Resolves promise when it's time to resume
|
||||
*/
|
||||
export declare function sleep(ms: number): Promise<unknown>;
|
||||
export declare function formatDate(date: Date | number | string): string;
|
||||
//# sourceMappingURL=time.d.ts.map
|
1
dist/src/time.d.ts.map
vendored
Normal file
1
dist/src/time.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/time.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAE/B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,UAUtD"}
|
22
dist/src/xhr.d.ts
vendored
Normal file
22
dist/src/xhr.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
export type FetchInterceptor = (resp: Response, next: () => any) => any;
|
||||
export declare class XHR<T> {
|
||||
readonly baseUrl: string;
|
||||
readonly headers: Record<string, string | null>;
|
||||
private static interceptors;
|
||||
static headers: Record<string, string | null>;
|
||||
private interceptors;
|
||||
constructor(baseUrl: string, headers?: Record<string, string | null>);
|
||||
static addInterceptor(fn: FetchInterceptor): () => {};
|
||||
static addInterceptor(key: string, fn: FetchInterceptor): () => {};
|
||||
addInterceptor(fn: FetchInterceptor): () => {};
|
||||
addInterceptor(key: string, fn: FetchInterceptor): () => {};
|
||||
getInterceptors(): FetchInterceptor[];
|
||||
fetch<T2 = T>(href?: string, body?: any, opts?: any): Promise<T2>;
|
||||
delete<T2 = void>(url?: string, opts?: any): Promise<T2>;
|
||||
get<T2 = T>(url?: string, opts?: any): Promise<T2>;
|
||||
patch<T2 = T>(data: T2, url?: string, opts?: any): Promise<T2>;
|
||||
post<T2 = T>(data: T2, url?: string, opts?: any): Promise<T2>;
|
||||
put<T2 = T>(data: Partial<T2>, url?: string, opts?: any): Promise<T2>;
|
||||
new<T2 = T>(href: string, headers: Record<string, string | null>): XHR<T2>;
|
||||
}
|
||||
//# sourceMappingURL=xhr.d.ts.map
|
1
dist/src/xhr.d.ts.map
vendored
Normal file
1
dist/src/xhr.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../src/xhr.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,CAAC;AAExE,qBAAa,GAAG,CAAC,CAAC;aAMW,OAAO,EAAE,MAAM;aACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IANzD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAyC;IACpE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAM;IAEnD,OAAO,CAAC,YAAY,CAAyC;gBAEjC,OAAO,EAAE,MAAM,EACxB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAM;IAG9D,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,gBAAgB,GAAG,MAAM,EAAE;IACrD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,GAAG,MAAM,EAAE;IASlE,cAAc,CAAC,EAAE,EAAE,gBAAgB,GAAG,MAAM,EAAE;IAC9C,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,GAAG,MAAM,EAAE;IAS3D,eAAe;IAIf,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,GAAE,GAAQ,GAAG,OAAO,CAAC,EAAE,CAAC;IA0BrE,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,CAAC;IAIxD,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,CAAC;IAIlD,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,CAAC;IAI9D,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,CAAC;IAI7D,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,CAAC;IAIrE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;CAS1E"}
|
1
dist/utilities.js
vendored
Normal file
1
dist/utilities.js
vendored
Normal file
File diff suppressed because one or more lines are too long
458
dist/utilities.mjs
vendored
Normal file
458
dist/utilities.mjs
vendored
Normal file
@ -0,0 +1,458 @@
|
||||
var b = Object.defineProperty;
|
||||
var j = (t, n, e) => n in t ? b(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
|
||||
var h = (t, n, e) => (j(t, typeof n != "symbol" ? n + "" : n, e), e);
|
||||
function H(t, n = !1) {
|
||||
if (t == null)
|
||||
throw new Error("Cannot clean a NULL value");
|
||||
return Array.isArray(t) ? t = t.filter((e) => e != null) : Object.entries(t).forEach(([e, o]) => {
|
||||
(o === void 0 || n || o === null) && delete t[e];
|
||||
}), t;
|
||||
}
|
||||
function J(t) {
|
||||
return JSON.parse(JSON.stringify(t));
|
||||
}
|
||||
function x(t, n, e) {
|
||||
if (!(t == null || !n))
|
||||
return n.split(/[.[\]]/g).filter((o) => o.length).reduce((o, r, s, c) => {
|
||||
if ((r[0] == '"' || r[0] == "'") && (r = r.slice(1, -1)), !(o != null && o.hasOwnProperty(r))) {
|
||||
if (e == null)
|
||||
return;
|
||||
o[r] = {};
|
||||
}
|
||||
return e !== void 0 && s == c.length - 1 ? o[r] = e : o[r];
|
||||
}, t);
|
||||
}
|
||||
function S(t, n, e = !1) {
|
||||
if (t == null)
|
||||
return e;
|
||||
if (Array.isArray(n))
|
||||
return n.findIndex((r, s) => !S(t[s], n[s], e)) == -1;
|
||||
const o = typeof n;
|
||||
return o != typeof t ? !1 : o == "object" ? Object.keys(n).find((r) => !S(t[r], n[r], e)) == null : o == "function" ? t.toString() == n.toString() : t == n;
|
||||
}
|
||||
function w(t, n) {
|
||||
const e = typeof t, o = typeof n;
|
||||
return e != "object" || t == null || o != "object" || n == null ? e == "function" && o == "function" ? t.toString() == n.toString() : t === n : Object.keys(t).length != Object.keys(n).length ? !1 : Object.keys(t).every((s) => w(t[s], n[s]));
|
||||
}
|
||||
function K(t, n) {
|
||||
return t.indexOf(n) === -1 && t.push(n), t;
|
||||
}
|
||||
function Z(t, n) {
|
||||
return M([
|
||||
...t.filter((e) => !n.includes((o) => w(e, o))),
|
||||
...n.filter((e) => !t.includes((o) => w(e, o)))
|
||||
]);
|
||||
}
|
||||
function F(t) {
|
||||
return function(n, e) {
|
||||
const o = x(n, t), r = x(e, t);
|
||||
return typeof o != "string" || typeof r != "string" ? 1 : o.toLowerCase().localeCompare(r.toLowerCase());
|
||||
};
|
||||
}
|
||||
function U(t, n = []) {
|
||||
return t.forEach((e) => Array.isArray(e) ? U(e, n) : n.push(e)), n;
|
||||
}
|
||||
function Q(t, n = !1) {
|
||||
return function(e, o) {
|
||||
const r = x(e, t), s = x(o, t);
|
||||
return typeof r == "number" && typeof s == "number" ? (n ? -1 : 1) * (r - s) : r > s ? n ? -1 : 1 : r < s ? n ? 1 : -1 : 0;
|
||||
};
|
||||
}
|
||||
function X(t, n) {
|
||||
return (e) => w(e[t], n);
|
||||
}
|
||||
function M(t) {
|
||||
for (let n = t.length - 1; n >= 0; n--)
|
||||
t.slice(0, n).find((e) => w(e, t[n])) && t.splice(n, 1);
|
||||
return t;
|
||||
}
|
||||
function _(t) {
|
||||
return Array.isArray(t) ? t : [t];
|
||||
}
|
||||
class tt {
|
||||
constructor() {
|
||||
h(this, "listeners", {});
|
||||
}
|
||||
emit(n) {
|
||||
Object.values(this.listeners).forEach((e) => e(n));
|
||||
}
|
||||
listen(n, e) {
|
||||
const o = e || n, r = typeof n == "string" ? n : `_${Object.keys(this.listeners).length.toString()}`;
|
||||
return this.listeners[r] = o, () => delete this.listeners[r];
|
||||
}
|
||||
once(n) {
|
||||
const e = this.listen((o) => {
|
||||
n(o), e();
|
||||
});
|
||||
}
|
||||
}
|
||||
const f = class f {
|
||||
constructor(n, e = {}) {
|
||||
h(this, "interceptors", {});
|
||||
this.baseUrl = n, this.headers = e;
|
||||
}
|
||||
static addInterceptor(n, e) {
|
||||
const o = e || n, r = typeof n == "string" ? n : `_${Object.keys(f.interceptors).length.toString()}`;
|
||||
return f.interceptors[r] = o, () => delete f.interceptors[r];
|
||||
}
|
||||
addInterceptor(n, e) {
|
||||
const o = e || n, r = typeof n == "string" ? n : `_${Object.keys(this.interceptors).length.toString()}`;
|
||||
return this.interceptors[r] = o, () => delete this.interceptors[r];
|
||||
}
|
||||
getInterceptors() {
|
||||
return [...Object.values(f.interceptors), ...Object.values(this.interceptors)];
|
||||
}
|
||||
fetch(n, e, o = {}) {
|
||||
const r = {
|
||||
"Content-Type": e && !(e instanceof FormData) ? "application/json" : void 0,
|
||||
...f.headers,
|
||||
...this.headers,
|
||||
...o.headers
|
||||
};
|
||||
return Object.keys(r).forEach((s) => {
|
||||
r[s] || delete r[s];
|
||||
}), fetch(`${this.baseUrl}${n || ""}`.replace(/([^:]\/)\/+/g, "$1"), {
|
||||
headers: r,
|
||||
method: o.method || (e ? "POST" : "GET"),
|
||||
body: r["Content-Type"].startsWith("application/json") && e ? JSON.stringify(e) : e
|
||||
}).then(async (s) => {
|
||||
for (let c of this.getInterceptors())
|
||||
await new Promise((d) => c(s, () => d(null)));
|
||||
return s.headers["Content-Type"] && s.headers.get("Content-Type").startsWith("application/json") ? await s.json() : s.headers["Content-Type"] && s.headers.get("Content-Type").startsWith("text/plain") ? await s.text() : s;
|
||||
});
|
||||
}
|
||||
delete(n, e) {
|
||||
return this.fetch(n, null, { method: "delete", ...e });
|
||||
}
|
||||
get(n, e) {
|
||||
return this.fetch(n, null, { method: "get", ...e });
|
||||
}
|
||||
patch(n, e, o) {
|
||||
return this.fetch(e, n, { method: "patch", ...o });
|
||||
}
|
||||
post(n, e, o) {
|
||||
return this.fetch(e, n, { method: "post", ...o });
|
||||
}
|
||||
put(n, e, o) {
|
||||
return this.fetch(e, n, { method: "put", ...o });
|
||||
}
|
||||
new(n, e) {
|
||||
const o = new f(`${this.baseUrl}${n}`, {
|
||||
...this.headers,
|
||||
...e
|
||||
});
|
||||
return Object.entries(this.interceptors).map(([r, s]) => o.addInterceptor(r, s)), o;
|
||||
}
|
||||
};
|
||||
h(f, "interceptors", {}), h(f, "headers", {});
|
||||
let C = f;
|
||||
C.addInterceptor((t, n) => {
|
||||
if (t.status == 200)
|
||||
return n();
|
||||
throw t.status == 400 ? new R(t.statusText) : t.status == 401 ? new I(t.statusText) : t.status == 403 ? new N(t.statusText) : t.status == 404 ? new $(t.statusText) : t.status == 500 ? new O(t.statusText) : new p(t.statusText, t.status);
|
||||
});
|
||||
class p extends Error {
|
||||
constructor(e, o) {
|
||||
super(e);
|
||||
h(this, "_code");
|
||||
o != null && (this._code = o);
|
||||
}
|
||||
get code() {
|
||||
return this._code || this.constructor.code;
|
||||
}
|
||||
set code(e) {
|
||||
this._code = e;
|
||||
}
|
||||
static from(e) {
|
||||
const o = Number(e.statusCode) ?? Number(e.code), r = new this(e.message || e.toString());
|
||||
return Object.assign(r, {
|
||||
stack: e.stack,
|
||||
...e,
|
||||
code: o ?? void 0
|
||||
});
|
||||
}
|
||||
static instanceof(e) {
|
||||
return e.constructor.code != null;
|
||||
}
|
||||
toString() {
|
||||
return this.message || super.toString();
|
||||
}
|
||||
}
|
||||
h(p, "code", 500);
|
||||
class R extends p {
|
||||
constructor(n = "Bad Request") {
|
||||
super(n);
|
||||
}
|
||||
static instanceof(n) {
|
||||
return n.constructor.code == this.code;
|
||||
}
|
||||
}
|
||||
h(R, "code", 400);
|
||||
class I extends p {
|
||||
constructor(n = "Unauthorized") {
|
||||
super(n);
|
||||
}
|
||||
static instanceof(n) {
|
||||
return n.constructor.code == this.code;
|
||||
}
|
||||
}
|
||||
h(I, "code", 401);
|
||||
class N extends p {
|
||||
constructor(n = "Forbidden") {
|
||||
super(n);
|
||||
}
|
||||
static instanceof(n) {
|
||||
return n.constructor.code == this.code;
|
||||
}
|
||||
}
|
||||
h(N, "code", 403);
|
||||
class $ extends p {
|
||||
constructor(n = "Not Found") {
|
||||
super(n);
|
||||
}
|
||||
static instanceof(n) {
|
||||
return n.constructor.code == this.code;
|
||||
}
|
||||
}
|
||||
h($, "code", 404);
|
||||
class O extends p {
|
||||
constructor(n = "Internal Server Error") {
|
||||
super(n);
|
||||
}
|
||||
static instanceof(n) {
|
||||
return n.constructor.code == this.code;
|
||||
}
|
||||
}
|
||||
h(O, "code", 500);
|
||||
const E = {
|
||||
CLEAR: "\x1B[0m",
|
||||
BRIGHT: "\x1B[1m",
|
||||
DIM: "\x1B[2m",
|
||||
UNDERSCORE: "\x1B[4m",
|
||||
BLINK: "\x1B[5m",
|
||||
REVERSE: "\x1B[7m",
|
||||
HIDDEN: "\x1B[8m"
|
||||
}, y = {
|
||||
BLACK: "\x1B[30m",
|
||||
RED: "\x1B[31m",
|
||||
GREEN: "\x1B[32m",
|
||||
YELLOW: "\x1B[33m",
|
||||
BLUE: "\x1B[34m",
|
||||
MAGENTA: "\x1B[35m",
|
||||
CYAN: "\x1B[36m",
|
||||
WHITE: "\x1B[37m",
|
||||
GREY: "\x1B[90m"
|
||||
}, et = {
|
||||
BLACK: "\x1B[40m",
|
||||
RED: "\x1B[41m",
|
||||
GREEN: "\x1B[42m",
|
||||
YELLOW: "\x1B[43m",
|
||||
BLUE: "\x1B[44m",
|
||||
MAGENTA: "\x1B[45m",
|
||||
CYAN: "\x1B[46m",
|
||||
WHITE: "\x1B[47m",
|
||||
GREY: "\x1B[100m"
|
||||
};
|
||||
class nt {
|
||||
constructor(n) {
|
||||
this.namespace = n;
|
||||
}
|
||||
format(...n) {
|
||||
return `${(/* @__PURE__ */ new Date()).toISOString()} [${this.namespace}] ${n.join(" ")}`;
|
||||
}
|
||||
debug(...n) {
|
||||
console.log(y.MAGENTA + this.format(...n) + E.CLEAR);
|
||||
}
|
||||
error(...n) {
|
||||
console.log(y.RED + this.format(...n) + E.CLEAR);
|
||||
}
|
||||
info(...n) {
|
||||
console.log(y.CYAN + this.format(...n) + E.CLEAR);
|
||||
}
|
||||
log(...n) {
|
||||
console.log(E.CLEAR + this.format(...n));
|
||||
}
|
||||
warn(...n) {
|
||||
console.log(y.YELLOW + this.format(...n) + E.CLEAR);
|
||||
}
|
||||
verbose(...n) {
|
||||
console.log(y.WHITE + this.format(...n) + E.CLEAR);
|
||||
}
|
||||
}
|
||||
function ot(t, n) {
|
||||
return t.length - t.replaceAll(n, "").length;
|
||||
}
|
||||
function rt(t) {
|
||||
return Array(t).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
||||
}
|
||||
const T = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", m = "0123456789", L = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", k = T + m + L;
|
||||
function st(t) {
|
||||
const n = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(t);
|
||||
if (!n)
|
||||
throw new Error(`Number cannot be parsed: ${t}`);
|
||||
return `${n[1] ?? ""} (${n[2]}) ${n[3]}-${n[4]}`.trim();
|
||||
}
|
||||
function ct(t, n, e) {
|
||||
return `${t.slice(0, e)}${n}${t.slice(e + 1)}`;
|
||||
}
|
||||
function it(t, n = k) {
|
||||
return Array(t).fill(null).map(() => {
|
||||
const e = ~~(Math.random() * n.length);
|
||||
return n[e];
|
||||
}).join("");
|
||||
}
|
||||
function ut(t, n = !1, e = !1, o = !1) {
|
||||
if (!n && !e && !o)
|
||||
throw new Error("Must enable at least one: letters, numbers, symbols");
|
||||
return Array(t).fill(null).map(() => {
|
||||
let r;
|
||||
do {
|
||||
const s = ~~(Math.random() * 3);
|
||||
n && s == 0 ? r = T[~~(Math.random() * T.length)] : e && s == 1 ? r = m[~~(Math.random() * m.length)] : o && s == 2 && (r = L[~~(Math.random() * L.length)]);
|
||||
} while (!r);
|
||||
return r;
|
||||
}).join("");
|
||||
}
|
||||
function at(t, n) {
|
||||
if (typeof n == "string" && (n = new RegExp(n, "g")), !n.global)
|
||||
throw new TypeError("Regular expression must be global.");
|
||||
let e = [], o;
|
||||
for (; (o = n.exec(t)) !== null; )
|
||||
e.push(o);
|
||||
return e;
|
||||
}
|
||||
function Y(t) {
|
||||
var n = q(W(P(G(t), 8 * t.length)));
|
||||
return n.toLowerCase();
|
||||
}
|
||||
function q(t) {
|
||||
for (var n, e = "0123456789ABCDEF", o = "", r = 0; r < t.length; r++)
|
||||
n = t.charCodeAt(r), o += e.charAt(n >>> 4 & 15) + e.charAt(15 & n);
|
||||
return o;
|
||||
}
|
||||
function G(t) {
|
||||
for (var n = Array(t.length >> 2), e = 0; e < n.length; e++)
|
||||
n[e] = 0;
|
||||
for (e = 0; e < 8 * t.length; e += 8)
|
||||
n[e >> 5] |= (255 & t.charCodeAt(e / 8)) << e % 32;
|
||||
return n;
|
||||
}
|
||||
function W(t) {
|
||||
for (var n = "", e = 0; e < 32 * t.length; e += 8)
|
||||
n += String.fromCharCode(t[e >> 5] >>> e % 32 & 255);
|
||||
return n;
|
||||
}
|
||||
function P(t, n) {
|
||||
t[n >> 5] |= 128 << n % 32, t[14 + (n + 64 >>> 9 << 4)] = n;
|
||||
for (var e = 1732584193, o = -271733879, r = -1732584194, s = 271733878, c = 0; c < t.length; c += 16) {
|
||||
var A = e, d = o, v = r, D = s;
|
||||
o = l(o = l(o = l(o = l(o = a(o = a(o = a(o = a(o = u(o = u(o = u(o = u(o = i(o = i(o = i(o = i(o, r = i(r, s = i(s, e = i(e, o, r, s, t[c + 0], 7, -680876936), o, r, t[c + 1], 12, -389564586), e, o, t[c + 2], 17, 606105819), s, e, t[c + 3], 22, -1044525330), r = i(r, s = i(s, e = i(e, o, r, s, t[c + 4], 7, -176418897), o, r, t[c + 5], 12, 1200080426), e, o, t[c + 6], 17, -1473231341), s, e, t[c + 7], 22, -45705983), r = i(r, s = i(s, e = i(e, o, r, s, t[c + 8], 7, 1770035416), o, r, t[c + 9], 12, -1958414417), e, o, t[c + 10], 17, -42063), s, e, t[c + 11], 22, -1990404162), r = i(r, s = i(s, e = i(e, o, r, s, t[c + 12], 7, 1804603682), o, r, t[c + 13], 12, -40341101), e, o, t[c + 14], 17, -1502002290), s, e, t[c + 15], 22, 1236535329), r = u(r, s = u(s, e = u(e, o, r, s, t[c + 1], 5, -165796510), o, r, t[c + 6], 9, -1069501632), e, o, t[c + 11], 14, 643717713), s, e, t[c + 0], 20, -373897302), r = u(r, s = u(s, e = u(e, o, r, s, t[c + 5], 5, -701558691), o, r, t[c + 10], 9, 38016083), e, o, t[c + 15], 14, -660478335), s, e, t[c + 4], 20, -405537848), r = u(r, s = u(s, e = u(e, o, r, s, t[c + 9], 5, 568446438), o, r, t[c + 14], 9, -1019803690), e, o, t[c + 3], 14, -187363961), s, e, t[c + 8], 20, 1163531501), r = u(r, s = u(s, e = u(e, o, r, s, t[c + 13], 5, -1444681467), o, r, t[c + 2], 9, -51403784), e, o, t[c + 7], 14, 1735328473), s, e, t[c + 12], 20, -1926607734), r = a(r, s = a(s, e = a(e, o, r, s, t[c + 5], 4, -378558), o, r, t[c + 8], 11, -2022574463), e, o, t[c + 11], 16, 1839030562), s, e, t[c + 14], 23, -35309556), r = a(r, s = a(s, e = a(e, o, r, s, t[c + 1], 4, -1530992060), o, r, t[c + 4], 11, 1272893353), e, o, t[c + 7], 16, -155497632), s, e, t[c + 10], 23, -1094730640), r = a(r, s = a(s, e = a(e, o, r, s, t[c + 13], 4, 681279174), o, r, t[c + 0], 11, -358537222), e, o, t[c + 3], 16, -722521979), s, e, t[c + 6], 23, 76029189), r = a(r, s = a(s, e = a(e, o, r, s, t[c + 9], 4, -640364487), o, r, t[c + 12], 11, -421815835), e, o, t[c + 15], 16, 530742520), s, e, t[c + 2], 23, -995338651), r = l(r, s = l(s, e = l(e, o, r, s, t[c + 0], 6, -198630844), o, r, t[c + 7], 10, 1126891415), e, o, t[c + 14], 15, -1416354905), s, e, t[c + 5], 21, -57434055), r = l(r, s = l(s, e = l(e, o, r, s, t[c + 12], 6, 1700485571), o, r, t[c + 3], 10, -1894986606), e, o, t[c + 10], 15, -1051523), s, e, t[c + 1], 21, -2054922799), r = l(r, s = l(s, e = l(e, o, r, s, t[c + 8], 6, 1873313359), o, r, t[c + 15], 10, -30611744), e, o, t[c + 6], 15, -1560198380), s, e, t[c + 13], 21, 1309151649), r = l(r, s = l(s, e = l(e, o, r, s, t[c + 4], 6, -145523070), o, r, t[c + 11], 10, -1120210379), e, o, t[c + 2], 15, 718787259), s, e, t[c + 9], 21, -343485551), e = g(e, A), o = g(o, d), r = g(r, v), s = g(s, D);
|
||||
}
|
||||
return Array(e, o, r, s);
|
||||
}
|
||||
function B(t, n, e, o, r, s) {
|
||||
return g(V(g(g(n, t), g(o, s)), r), e);
|
||||
}
|
||||
function i(t, n, e, o, r, s, c) {
|
||||
return B(n & e | ~n & o, t, n, r, s, c);
|
||||
}
|
||||
function u(t, n, e, o, r, s, c) {
|
||||
return B(n & o | e & ~o, t, n, r, s, c);
|
||||
}
|
||||
function a(t, n, e, o, r, s, c) {
|
||||
return B(n ^ e ^ o, t, n, r, s, c);
|
||||
}
|
||||
function l(t, n, e, o, r, s, c) {
|
||||
return B(e ^ (n | ~o), t, n, r, s, c);
|
||||
}
|
||||
function g(t, n) {
|
||||
var e = (65535 & t) + (65535 & n);
|
||||
return (t >> 16) + (n >> 16) + (e >> 16) << 16 | 65535 & e;
|
||||
}
|
||||
function V(t, n) {
|
||||
return t << n | t >>> 32 - n;
|
||||
}
|
||||
function lt(t) {
|
||||
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(t);
|
||||
}
|
||||
function ht(t) {
|
||||
return Object.entries(t).map(
|
||||
([n, e]) => encodeURIComponent(n) + "=" + encodeURIComponent(e)
|
||||
).join("&");
|
||||
}
|
||||
function ft(t) {
|
||||
return t ? `https://www.gravatar.com/avatar/${Y(t)}` : "";
|
||||
}
|
||||
function gt(t) {
|
||||
const n = new RegExp(
|
||||
"(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
|
||||
"gm"
|
||||
).exec(t), e = (n == null ? void 0 : n.groups) ?? {}, o = e.domain.split(".");
|
||||
if (e.port != null && (e.port = Number(e.port)), o.length > 2 && (e.domain = o.splice(-2, 2).join("."), e.subdomain = o.join(".")), e.query) {
|
||||
const r = e.query.split("&"), s = {};
|
||||
r.forEach((c) => {
|
||||
const [A, d] = c.split("=");
|
||||
s[A] = d;
|
||||
}), e.query = s;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
function pt(t) {
|
||||
return (t instanceof Date ? t.getTime() : t) - (/* @__PURE__ */ new Date()).getTime();
|
||||
}
|
||||
function Et(t) {
|
||||
return new Promise((n) => setTimeout(n, t));
|
||||
}
|
||||
function dt(t) {
|
||||
const n = t instanceof Date ? t : new Date(t);
|
||||
return new Intl.DateTimeFormat("en-us", {
|
||||
weekday: "long",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
hour12: !0
|
||||
}).format(n);
|
||||
}
|
||||
export {
|
||||
R as BadRequestError,
|
||||
et as CliBackground,
|
||||
E as CliEffects,
|
||||
y as CliForeground,
|
||||
p as CustomError,
|
||||
tt as Emitter,
|
||||
N as ForbiddenError,
|
||||
O as InternalServerError,
|
||||
nt as Logger,
|
||||
$ as NotFoundError,
|
||||
I as UnauthorizedError,
|
||||
C as XHR,
|
||||
K as addUnique,
|
||||
Z as arrayDiff,
|
||||
F as caseInsensitiveSort,
|
||||
H as clean,
|
||||
ot as countChars,
|
||||
rt as createHex,
|
||||
J as deepCopy,
|
||||
x as dotNotation,
|
||||
X as findByProp,
|
||||
U as flattenArr,
|
||||
ht as formEncode,
|
||||
dt as formatDate,
|
||||
st as formatPhoneNumber,
|
||||
ft as gravatar,
|
||||
S as includes,
|
||||
ct as insertAt,
|
||||
w as isEqual,
|
||||
_ as makeArray,
|
||||
M as makeUnique,
|
||||
at as matchAll,
|
||||
Y as md5,
|
||||
it as randomString,
|
||||
ut as randomStringBuilder,
|
||||
Et as sleep,
|
||||
Q as sortByProp,
|
||||
pt as timeUntil,
|
||||
gt as urlParser,
|
||||
lt as validateEmail
|
||||
};
|
Reference in New Issue
Block a user