type PossibleDataString = string | undefined | null; /** * Based on https://stackoverflow.com/a/56416192/6639124 */ type AllValues> = { [P in keyof T]: { key: P; value: T[P]; }; }[keyof T]; type InvertResult> = { [P in AllValues['value']]: Extract, { value: P; }>['key']; }; type RecursivePartial = { [P in keyof T]?: RecursivePartial; }; /** * Based on https://dev.to/pffigueiredo/typescript-utility-keyof-nested-object-2pa3 */ type NestedKeyOf = { [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf}` : `${Key}`; }[keyof ObjectType & (string | number)]; /** * https://github.com/ghoullier/awesome-template-literal-types#dot-notation-string-type-safe */ type ExtractPathsLogic = Key extends string ? T[Key] extends Record ? `${Key}.${ExtractPathsLogic> & string}` | `${Key}.${Exclude & string}` : never : never; type ExtractPathsRecursion = ExtractPathsLogic | keyof T; type ExtractPaths = ExtractPathsRecursion extends string | keyof T ? ExtractPathsRecursion : keyof T; type Split = S extends `${infer T}${D}${infer U}` ? [T, ...Split] : [S]; type RootKey = Split['length'] extends 1 ? true : false; type RecursiveOmit | NestedKeyOf[]> = any; interface WithID { id: string; } type IdentifiedByID = T & WithID; interface Indexed { [key: string]: T; } /** * Returns the range of integers between start (including) and end (excluding). * * https://dev.to/namirsab/comment/2050 * @param start * @param end */ declare const range: (start: number, end: number) => number[]; /** * Check if two arrays are equal. * * @param a * @param b */ declare const equal: (a: T[], b: T[]) => Boolean; /** * Move the `from` indexed item to the `to` indexed item of an array. * * @param items * @param from * @param to */ declare const move: (items: T[], from: number, to: number) => T[]; /** * Swap item `a` with `b`. * * @param items * @param a * @param b */ declare const swap: (items: T[], a: number, b: number) => T[]; /** * Get unique items based on their `identifier`. * * @param array * @param identifier default `'id'` * @returns */ declare const unique: (array: T[], identifier?: string) => T[]; /** * Shuffles the `values` of an array. * * @param array * @returns */ declare const shuffle$1: (values: T[]) => T[]; declare const index$i_equal: typeof equal; declare const index$i_move: typeof move; declare const index$i_range: typeof range; declare const index$i_swap: typeof swap; declare const index$i_unique: typeof unique; declare namespace index$i { export { index$i_equal as equal, index$i_move as move, index$i_range as range, shuffle$1 as shuffle, index$i_swap as swap, index$i_unique as unique }; } declare const copy: (text: string) => void; declare const index$h_copy: typeof copy; declare namespace index$h { export { index$h_copy as copy }; } declare const parse: (value: PossibleDataString) => T | undefined; declare const parseFromString: (value: string) => string | T; declare const stringifyOrDefault: (data: any) => string | undefined; declare const index$g_parse: typeof parse; declare const index$g_parseFromString: typeof parseFromString; declare const index$g_stringifyOrDefault: typeof stringifyOrDefault; declare namespace index$g { export { index$g_parse as parse, index$g_parseFromString as parseFromString, index$g_stringifyOrDefault as stringifyOrDefault }; } declare const placeCaretAtEnd: (el: any) => void; /** * Gets the event path cross-browser. * * Based on https://stackoverflow.com/a/39245638 * * @param event */ declare const getEventPath: (event: Event) => HTMLElement[]; declare const verifyPathInputElement: (path?: HTMLElement[]) => boolean; declare const verifyEventInput: (event: Event) => boolean; /** * Downloads `content` as file with `filename`. * * @param filename * @param content * @param dataString default `'data:text/plain;charset=utf-8,'` */ declare const downloadContent: (filename: string, content: string, dataString?: string) => void; declare const index$f_downloadContent: typeof downloadContent; declare const index$f_getEventPath: typeof getEventPath; declare const index$f_placeCaretAtEnd: typeof placeCaretAtEnd; declare const index$f_verifyEventInput: typeof verifyEventInput; declare const index$f_verifyPathInputElement: typeof verifyPathInputElement; declare namespace index$f { export { index$f_downloadContent as downloadContent, index$f_getEventPath as getEventPath, index$f_placeCaretAtEnd as placeCaretAtEnd, index$f_verifyEventInput as verifyEventInput, index$f_verifyPathInputElement as verifyPathInputElement }; } declare const deleteTypenames: (data: any) => any; declare const index$e_deleteTypenames: typeof deleteTypenames; declare namespace index$e { export { index$e_deleteTypenames as deleteTypenames }; } /** * Load image from URL in browser. * * @param url * @param anonymous */ declare const load: (url: string, anonymous?: boolean) => Promise; declare const index$d_load: typeof load; declare namespace index$d { export { index$d_load as load }; } /** * Identify `items` by an `idEntity` property. * * @param items * @param idEntity */ declare const identify: (items: T[], /** * Identify items by a certain property. Default `id`. */ idEntity?: string) => (T & { [x: string]: string; })[]; type MapType = 'map'; type ObjectType = 'object'; type CreateType = MapType | ObjectType; declare function create(items: T[], type?: O, idKey?: string): Indexed; declare function create(items: T[], type?: M, idKey?: string): Map; type index$c_CreateType = CreateType; type index$c_MapType = MapType; type index$c_ObjectType = ObjectType; declare const index$c_create: typeof create; declare const index$c_identify: typeof identify; declare namespace index$c { export { type index$c_CreateType as CreateType, type index$c_MapType as MapType, type index$c_ObjectType as ObjectType, index$c_create as create, index$c_identify as identify }; } declare enum OPERATION_TYPES { SUM = "SUM", PRODUCT = "PRODUCT", DIFFERENCE = "DIFFERENCE" } /** * Operate on the `values` up to the given `index` based the specific `operation`. * If the `index` is not given it operates to the end. * * @param type * @param values * @param index */ declare const operation: (type: keyof typeof OPERATION_TYPES, values: number[], index?: number) => number; /** * Sum the `values` up to the given `index`. * If the `index` is not given it sums to the end. * * @param values * @param index */ declare const sum: (values: number[], index?: number) => number; /** * Multiply the `values` up to the given `index`. * If the `index` is not given it multiplies to the end. * * @param values * @param index */ declare const product: (values: number[], index?: number) => number; type arithmetic_OPERATION_TYPES = OPERATION_TYPES; declare const arithmetic_OPERATION_TYPES: typeof OPERATION_TYPES; declare const arithmetic_operation: typeof operation; declare const arithmetic_product: typeof product; declare const arithmetic_sum: typeof sum; declare namespace arithmetic { export { arithmetic_OPERATION_TYPES as OPERATION_TYPES, arithmetic_operation as operation, arithmetic_product as product, arithmetic_sum as sum }; } declare const tau: number; declare const constants_tau: typeof tau; declare namespace constants { export { constants_tau as tau }; } /** * Convert the `angle` from radians to degrees. * * @param angle */ declare const toDegrees: (angle: number) => number; /** * Convert the `angle` from degrees to radians. * @param angle */ declare const toRadians: (angle: number) => number; declare const geometry_toDegrees: typeof toDegrees; declare const geometry_toRadians: typeof toRadians; declare namespace geometry { export { geometry_toDegrees as toDegrees, geometry_toRadians as toRadians }; } /** * Return true if `value` is an integer * but not equal to `1`. * * @param value */ declare const checkIntegerNonUnit: (value: number) => boolean; /** * Normalizes the `value` between the `lower` and `upper` limits. * * ``` * normalizeBetween( 20, 0, 100) -> 20 * normalizeBetween(-20, 0, 100) -> 0 * normalizeBetween(120, 0, 100) -> 100 * ``` * * @param value * @param lower * @param upper * @returns */ declare const normalizeBetween: (value: number, lower: number, upper: number) => number; declare const numbers_checkIntegerNonUnit: typeof checkIntegerNonUnit; declare const numbers_normalizeBetween: typeof normalizeBetween; declare namespace numbers { export { numbers_checkIntegerNonUnit as checkIntegerNonUnit, numbers_normalizeBetween as normalizeBetween }; } /** * Generate a random number between the given `maximum` and `minimum` values. * * @param maximum - `1` by default. * @param minimum - `0` by default. * @param integer - `false` by default. If `true` it returns an integer. * @param closedInterval - `true` by default. If `false` it does not include the endpoints. * @returns A rational number by default. */ declare const number: (maximum?: number, minimum?: number, integer?: boolean, closedInterval?: boolean) => number; declare const random_number: typeof number; declare namespace random { export { random_number as number }; } declare const index$b_arithmetic: typeof arithmetic; declare const index$b_constants: typeof constants; declare const index$b_geometry: typeof geometry; declare const index$b_numbers: typeof numbers; declare const index$b_random: typeof random; declare namespace index$b { export { index$b_arithmetic as arithmetic, index$b_constants as constants, index$b_geometry as geometry, index$b_numbers as numbers, index$b_random as random }; } declare const debounce: (func: any, wait: any, immediate?: boolean) => (this: any, ...args: any[]) => void; /** * Source: https://stackoverflow.com/a/57335271 * * @param callback Function to be called. * @param wait Debounce time. */ declare function debouncedCallback(callback: (...args: A) => void, wait: number): (...args: A) => void; declare const index$a_debounce: typeof debounce; declare const index$a_debouncedCallback: typeof debouncedCallback; declare namespace index$a { export { index$a_debounce as debounce, index$a_debouncedCallback as debouncedCallback }; } declare const isIPv4: (value: string | undefined) => boolean; declare const isIPv6: (value: string | undefined) => boolean; declare const isIP: (value: string | undefined) => "ipv4" | "ipv6" | undefined; /** * Checks the value respects ` "://" [ ":" ]`. * * @param value * @returns */ declare const isOrigin: (value: string | undefined) => boolean; declare const index$9_isIP: typeof isIP; declare const index$9_isIPv4: typeof isIPv4; declare const index$9_isIPv6: typeof isIPv6; declare const index$9_isOrigin: typeof isOrigin; declare namespace index$9 { export { index$9_isIP as isIP, index$9_isIPv4 as isIPv4, index$9_isIPv6 as isIPv6, index$9_isOrigin as isOrigin }; } declare const isObject: (entity: any) => boolean; /** * http://blog.nicohaemhouts.com/2015/08/03/accessing-nested-javascript-objects-with-string-key/ * * @param data * @param path * @param separator */ declare const getNested: (data: T, path: string, separator?: string) => any; /** * https://stackoverflow.com/a/52912610 * * @param data * @param update * @param path * @param separator */ declare const updateNested: (data: T, path: string, update: U, separator?: string) => T | undefined; /** * Creates a deep clone of the `data`. * * The default `type` is `json`, meant for deep cloning of json-like objects. * The `any` `type` will handle a deep clone of `Function`, `Date`, and more. * * @param data * @param type */ declare const clone: (data: D, type?: "json" | "any") => D; /** * Convert map to object. * * @param map */ declare const mapToObject: (map: Map) => any; /** * Removes `undefined` or `null` values from key-value object. * * @param object * @returns */ declare const clean: (object: Record, onlyUndefined?: boolean) => Record; /** * Flips the keys and the values of the object. * The values must be `string`s or `number`s. * * ``` * const a = { * b: 'c', * d: 'e', * f: 1, * g: true, // ignored * } as const; * * flip(a) -> { * c: 'b', * e: 'd', * 1: 'f', * } * ``` * * @param obj * @returns */ declare const flip: >(obj: T) => InvertResult; /** * Merges `target` into `object`. * * The `resolvers` can be used to resolve any field within the `object` * using dot-access syntax, e.g. `{ 'key1.key1.key3': () => value }`. * * @param object * @param target * @param resolvers * @param trunk * @returns */ declare const merge: (object: O, target: RecursivePartial, resolvers?: Partial, any | (() => any)>>, trunk?: string) => R; /** * Check `target` equals `object` based on `object`s keys. * * @param object * @param target * @param trunk * @returns */ declare const equals: (object: O, target: O, trunk?: string) => boolean; declare const omit: , K extends NestedKeyOf | NestedKeyOf[]>(object: O, keys: K, trunk?: string) => RecursiveOmit; declare const index$8_clean: typeof clean; declare const index$8_clone: typeof clone; declare const index$8_equals: typeof equals; declare const index$8_flip: typeof flip; declare const index$8_getNested: typeof getNested; declare const index$8_isObject: typeof isObject; declare const index$8_mapToObject: typeof mapToObject; declare const index$8_merge: typeof merge; declare const index$8_omit: typeof omit; declare const index$8_updateNested: typeof updateNested; declare namespace index$8 { export { index$8_clean as clean, index$8_clone as clone, index$8_equals as equals, index$8_flip as flip, index$8_getNested as getNested, index$8_isObject as isObject, index$8_mapToObject as mapToObject, index$8_merge as merge, index$8_omit as omit, index$8_updateNested as updateNested }; } /** * Based on https://stackoverflow.com/a/38815760 */ declare const isBrowser: boolean; declare const isNode: boolean; declare const index$7_isBrowser: typeof isBrowser; declare const index$7_isNode: typeof isNode; declare namespace index$7 { export { index$7_isBrowser as isBrowser, index$7_isNode as isNode }; } declare const compute: (data: string, algorithm?: string) => Promise; declare const index$6_compute: typeof compute; declare namespace index$6 { export { index$6_compute as compute }; } /** * Convert bytes to human readable text, e.g. `12345678` bytes to `12.34 MB`. * * `binary` sets the block size to `1024` or `1000` bytes. * * @param binary * @returns */ declare const humanFormat: (size: number, binary?: boolean) => string; declare const index$5_humanFormat: typeof humanFormat; declare namespace index$5 { export { index$5_humanFormat as humanFormat }; } declare const loadState: (name: string) => any; declare const saveState: (state: S, name: string) => void; declare const index$4_loadState: typeof loadState; declare const index$4_saveState: typeof saveState; declare namespace index$4 { export { index$4_loadState as loadState, index$4_saveState as saveState }; } declare const removeWhitespace: (value: string | undefined) => string; /** * Capitalizes the first letter of the word. * * ``` text * e.g. foo -> Foo * ``` * * @param value */ declare const capitalize: (value: string) => string; /** * Capitalizes the first letter of every word. * * ``` text * e.g. foo boo -> Foo Boo * ``` * * @param value */ declare const capitalizeAll: (value: string) => string; /** * Truncates the `value` to a given `length` adding the `ending`. * * ``` text * e.g. 1234567890 -> 1234… * ``` * * ``` typescript * truncate('1234567890', 4) * ``` * * @param value * @param length default `100` * @param ending default `'…'` * @returns */ declare const truncate: (value: string | undefined, length?: number, ending?: string) => string; /** * Trims the middle of the `value` keeping the lateral `length` * and replacing with the `middle`. * * ``` text * e.g. 12345678901234567890 -> 123456…567890 * ``` * * @param value * @param length default `6` * @param middle default `'…'` * @param startLength * @param endLength * @returns */ declare const trimMiddle: (value: string | undefined, length?: number, middle?: string, startLength?: number, endLength?: number) => string; /** * Given a text string, e.g. 'one two three', * it removes the last word, 'three', returning 'one two'. * * If the text string is one word, 'one', it returns ''. * * @param text Text string. */ declare const removeLastWord: (text: string) => string; /** * Given `PascalCaseValue` it returns `pascal.case.value`. * * @param value * @param lowercase default `true` * @returns */ declare const pascalCaseToDotNotation: (value: string, lowercase?: boolean) => string; /** * Given `PascalCaseValue` it returns `Pascal_Case_Value`. * * @param value * @returns */ declare const pascalCaseToSnakeCase: (value: string) => string; /** * Given `Pascal_Case_Value` it returns `PascalCaseValue`. * * @param value * @returns */ declare const snakeCaseToPascalCase: (value: string) => string; /** * Converts `Camel Case Value` to `camelCaseValue`. * * @param text */ declare const toCamelCase: (value: string) => string; /** * Shuffles the characters of the `text`. * * @param text * @returns */ declare const shuffle: (text: string) => string; /** * Removes the `character` at the start of the `value`. * * @param value * @param character * @param count default `1` * @returns */ declare const trimStart: (value: string, character: string, count?: number) => string; /** * Removes the `character` at the end of the `value`. * * @param value * @param character * @param count default `1` * @returns */ declare const trimEnd: (value: string, character: string, count?: number) => string; /** * Pluralizes a `text` based on a `value`. * * ``` typescript * pluralize(1, 'day'); // '1 day' * pluralize(2, 'day'); // '2 days' * * pluralize(1, 'bus', 'es'); // '1 bus' * pluralize(2, 'bus', 'es'); // '1 buses' * * pluralize(1, 'wolf', { replace: 'wolves' }); // '1 wolf' * pluralize(2, 'wolf', { replace: 'wolves' }); // '2 wolves' * ``` * * @param value * @param text * @param overload `string | { replace: string }` * @returns */ declare function pluralize(value: number, text: string, end: string): string; declare function pluralize(value: number, text: string, options: { replace: string; }): string; declare const index$3_capitalize: typeof capitalize; declare const index$3_capitalizeAll: typeof capitalizeAll; declare const index$3_pascalCaseToDotNotation: typeof pascalCaseToDotNotation; declare const index$3_pascalCaseToSnakeCase: typeof pascalCaseToSnakeCase; declare const index$3_pluralize: typeof pluralize; declare const index$3_removeLastWord: typeof removeLastWord; declare const index$3_removeWhitespace: typeof removeWhitespace; declare const index$3_shuffle: typeof shuffle; declare const index$3_snakeCaseToPascalCase: typeof snakeCaseToPascalCase; declare const index$3_toCamelCase: typeof toCamelCase; declare const index$3_trimEnd: typeof trimEnd; declare const index$3_trimMiddle: typeof trimMiddle; declare const index$3_trimStart: typeof trimStart; declare const index$3_truncate: typeof truncate; declare namespace index$3 { export { index$3_capitalize as capitalize, index$3_capitalizeAll as capitalizeAll, index$3_pascalCaseToDotNotation as pascalCaseToDotNotation, index$3_pascalCaseToSnakeCase as pascalCaseToSnakeCase, index$3_pluralize as pluralize, index$3_removeLastWord as removeLastWord, index$3_removeWhitespace as removeWhitespace, index$3_shuffle as shuffle, index$3_snakeCaseToPascalCase as snakeCaseToPascalCase, index$3_toCamelCase as toCamelCase, index$3_trimEnd as trimEnd, index$3_trimMiddle as trimMiddle, index$3_trimStart as trimStart, index$3_truncate as truncate }; } declare const now: () => number; declare const stamp: () => string; /** * Delay the program flow for `value` time, in milliseconds. * * Default: `500` * * @param value */ declare const delay: (value?: number) => Promise; declare const index$2_delay: typeof delay; declare const index$2_now: typeof now; declare const index$2_stamp: typeof stamp; declare namespace index$2 { export { index$2_delay as delay, index$2_now as now, index$2_stamp as stamp }; } declare const removeTrailingSlash: (value: string) => string; declare const index$1_removeTrailingSlash: typeof removeTrailingSlash; declare namespace index$1 { export { index$1_removeTrailingSlash as removeTrailingSlash }; } /** * Generate a unique identifier with or without `separator`. * * Based on https://stackoverflow.com/a/2117523. * * @param separator */ declare const v4Browser: (separator?: string) => string; declare const v4Node: (separator?: string) => string; declare const generate: (separator?: string, version?: string) => string; /** * Generate multiple, concatenated uuids. * * @param count default `2` * @param separator * @returns */ declare const multiple: (count?: number, separator?: string) => string; declare const index_generate: typeof generate; declare const index_multiple: typeof multiple; declare const index_v4Browser: typeof v4Browser; declare const index_v4Node: typeof v4Node; declare namespace index { export { index_generate as generate, index_multiple as multiple, index_v4Browser as v4Browser, index_v4Node as v4Node }; } export { type AllValues, type ExtractPaths, type ExtractPathsLogic, type ExtractPathsRecursion, type IdentifiedByID, type Indexed, type InvertResult, type NestedKeyOf, type PossibleDataString, type RecursiveOmit, type RecursivePartial, type RootKey, type Split, type WithID, index$i as arrays, index$h as clipboard, index$g as data, index$f as dom, index$e as graphql, index$d as image, index$c as indexing, index$b as mathematics, index$a as meta, index$9 as network, index$8 as objects, index$7 as runtime, index$6 as sha, index$5 as size, index$4 as storage, index$3 as strings, index$2 as time, index$1 as url, index as uuid };