UNPKG

@polgubau/utils

Version:

A collection of utility functions for TypeScript

1 lines 49.7 kB
{"version":3,"sources":["../../src/arrays/arrayUtils.ts","../../src/arrays/chunk.ts","../../src/arrays/group-by.ts","../../src/arrays/limit-array.ts","../../src/arrays/remove.ts","../../src/arrays/shuffle.ts","../../src/numbers/clamp/clamp.ts","../../src/storage/cookies/cookies.ts","../../src/parsers/handle-json/handle-json.ts","../../src/storage/localStorage/manageLocalStorage.ts","../../src/functions/copy-clipboard/copy-clipboard.ts","../../src/functions/debounce/debounce.ts","../../src/functions/encryption/encryption.ts","../../src/functions/fuzzy-finder/fuzzyFinder.ts","../../src/functions/generate-uuid/generate-uuid.ts","../../src/functions/sleep/sleep.ts","../../src/accessibility/doc-dir/getDocumentDirection.ts","../../src/comparators/is-client/is-client.ts","../../src/comparators/is-deep-key/isDeepKey.ts","../../src/comparators/is-equal/is-equal.ts","../../src/comparators/is-object/is-object.ts","../../src/objects/clone-deps/clone-deep.ts","../../src/objects/get-main-field/get-main-field.ts","../../src/objects/merge-deep/merge-deep.ts","../../src/objects/merge/merge.ts","../../src/objects/omit/omit.ts","../../src/objects/to-path/toPath.ts","../../src/texts/px/px.ts","../../src/texts/text-transform/text-transform.ts"],"sourcesContent":["/**\n * Returns the first element of an array\n * @param arr\n * @returns the first element of the array\n * @example first([1, 2, 3]) // 1\n */\nexport function first<T>(arr: T[]): T | undefined {\n return arr[0];\n}\n\n/**\n * Returns the last element of an array\n * @param arr\n * @returns the last element of the array\n * @example last([1, 2, 3]) // 3\n */\nexport function last<T>(arr: T[]): T | undefined {\n return arr[arr.length - 1];\n}\n\n\n/**\n * Removes the first element of an array\n * @param arr\n * @returns a new array without the first element\n * @example removeFirst([1, 2, 3]) // [2, 3]\n */\nexport function removeFirst<T>(arr: T[]): T[] {\n return arr.slice(1);\n}\n\n/**\n * Removes the last element of an array\n * @param arr\n * @returns a new array without the last element\n * @example removeLast([1, 2, 3]) // [1, 2]\n */\nexport function removeLast<T>(arr: T[]): T[] {\n return arr.slice(0, arr.length - 1);\n}\n\n\n","/**\n * Chunk an array into smaller arrays of a specified size\n * @param data - the array to chunk\n * @param size - the size of each chunk (default 10)\n * @returns an array of smaller arrays (data[])\n */\nexport const chunk = <T>(data: T[], size = 10): T[][] => {\n return data.reduce((chunks: T[][], item, index) => {\n const chunkIndex = Math.floor(index / size);\n if (!chunks[chunkIndex]) {\n chunks[chunkIndex] = [];\n }\n chunks[chunkIndex].push(item);\n return chunks;\n }, []);\n};","/**\n * Groups the elements of an array based on a provided key-generating function.\n *\n * This function takes an array and a function that generates a key from each element. It returns\n * an object where the keys are the generated keys and the values are arrays of elements that share\n * the same key.\n *\n * @template T - The type of elements in the array.\n * @template K - The type of keys.\n * @param {T[]} arr - The array to group.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record<K, T[]>} An object where each key is associated with an array of elements that\n * share that key.\n *\n * @example\n * const array = [\n * { category: 'fruit', name: 'apple' },\n * { category: 'fruit', name: 'banana' },\n * { category: 'vegetable', name: 'carrot' }\n * ];\n * const result = groupBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: [\n * // { category: 'fruit', name: 'apple' },\n * // { category: 'fruit', name: 'banana' }\n * // ],\n * // vegetable: [\n * // { category: 'vegetable', name: 'carrot' }\n * // ]\n * // }\n */\nexport function groupBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T) => K): Record<K, T[]> {\n const result = {} as Record<K, T[]>;\n\n for (const item of arr) {\n const key = getKeyFromItem(item);\n\n if (result[key] == null) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n","/**\n * Limit array to a certain number of elements and return the remaining count.\n * It is useful for displaying the first few elements and showing the remaining count.\n * @param arr <T>[]\n * @param limit number\n * @returns { limitedArray: T[], remaining: number }\n */\nexport const limitArray = <T>(arr: T[], limit = 3): { limitedArray: T[]; remaining: number } => {\n const limitedArray = arr.slice(0, limit);\n const remaining = arr.length - limit;\n\n return {\n limitedArray,\n remaining,\n };\n};\n","/**\n * Removes the element at the specified index from the array.\n * This modifies the original array.\n * @param arr - The array from which to remove the element.\n * @param index - The index of the element to remove.\n * @returns The modified array with the element removed.\n * @example remove([1, 2, 3], 1) // [1, 3]\n */\nexport function remove<T>(arr: T[], index: number): T[] {\n // Adjust the index if it's negative\n const adjustedIndex = index < 0 ? arr.length + index : index;\n\n // If the adjusted index is out of bounds, return the original array\n if (adjustedIndex < 0 || adjustedIndex >= arr.length) {\n return arr;\n }\n\n // Remove the element at the specified index\n arr.splice(adjustedIndex, 1);\n return arr;\n}\n","/**\n * Randomizes the order of elements in an array using the Fisher-Yates algorithm.\n *\n * This function takes an array and returns a new array with its elements shuffled in a random order.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to shuffle.\n * @returns {T[]} A new array with its elements shuffled in random order.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const shuffledArray = shuffle(array);\n * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]\n */\nexport function shuffle<T>(arr: readonly T[]): T[] {\n const result = arr.slice();\n\n /**\n * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n for (let i = result.length - 1; i >= 1; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n let temp = result[i];\n let resultJ = result[j];\n\n if (!(resultJ && temp)) {\n continue;\n }\n\n [temp, resultJ] = [resultJ, temp];\n }\n\n return result;\n}\n","/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, maximum: number): number;\nexport function clamp(value: number, minimum: number, maximum: number): number;\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n","// cookieUtils.ts\n/**\n * Sets a cookie with the specified name, value, and optional expiration in days.\n * @param {string} name - The name of the cookie.\n * @param {string} value - The value to be stored in the cookie.\n * @param {number} [days] - Optional number of days until the cookie expires.\n */\nexport const setCookie = (name: string, value: string, days?: number): void => {\n const expirationDate = new Date();\n expirationDate.setDate(expirationDate.getDate() + (days ?? 0));\n\n const cookieValue = encodeURIComponent(value) + (days ? `; expires=${expirationDate.toUTCString()}` : \"\");\n document.cookie = `${name}=${cookieValue}; path=/`;\n};\n\n/**\n * Retrieves the value of a cookie by its name.\n * @param {string} name - The name of the cookie to retrieve.\n * @returns {string|null} The value of the cookie if found, or null if not found.\n */\nexport const getCookie = (name: string): string | undefined => {\n const cookies = document.cookie.split(\"; \");\n for (const cookie of cookies) {\n const [cookieName, cookieValue] = cookie.split(\"=\");\n if (cookieName === name) {\n return decodeURIComponent(cookieValue ?? \"\");\n }\n }\n return undefined;\n};\n/**\n * Deletes a cookie by setting its expiration date to the past.\n * @param {string} name - The name of the cookie to delete.\n */\nexport const deleteCookie = (name: string): void => {\n document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n};\n","/**\n * @name parseJSON\n * @description A wrapper for \"JSON.parse()\"\" to support \"undefined\" value, if fails -> throw an error\n * @param value - string | null\n * @returns T | undefined\n * Author: Pol Gubau Amores\n */\n\nconst errorLabel = \"parsing error on value: \";\n\nexport function parseJSON<T>(value: string | null): T | undefined {\n\ttry {\n\t\tif (!value) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn JSON.parse(value ?? \"\");\n\t} catch {\n\t\tconsole.error(errorLabel, { value });\n\t\tthrow new Error(errorLabel + value);\n\t}\n}\n\n// A wrapper for \"JSON.parse()\"\" to support \"undefined\" value\nexport function saveParseJson<T>(value: string | null): T | undefined {\n\ttry {\n\t\tif (!value) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn JSON.parse(value ?? \"\");\n\t} catch {\n\t\tconsole.error(errorLabel, { value });\n\t\treturn undefined;\n\t}\n}\n\n/** stringify\n * @param value - T\n * @returns string | undefined\n */\n\nexport function stringify<T>(value: T): string | undefined {\n\ttry {\n\t\treturn JSON.stringify(value);\n\t} catch {\n\t\tconsole.error(errorLabel, { value });\n\t\treturn undefined;\n\t}\n}\n\nexport const json = {\n\tsaveParse: saveParseJson,\n\tparse: parseJSON,\n\tstringify,\n};\n","import { json } from \"../../parsers/handle-json/handle-json\";\n\n// Function to get a value from localStorage\nexport function getLocalStorage(key: string, initialValue: unknown) {\n const value = localStorage.getItem(key);\n if (!value) {\n setToLocalStorage(key, initialValue);\n return initialValue;\n }\n return json.saveParse(value);\n}\n\n// Function to set a value in localStorage\nexport function setToLocalStorage(key: string, value: unknown): void {\n localStorage.setItem(key, JSON.stringify(value));\n}\n\n// Function to remove a value from localStorage\nexport function removeFromLocalStorage(key: string): void {\n localStorage.removeItem(key);\n}\n","type CopyFn = (text: string) => void; // Return success\n\nexport const copyToClipboard: CopyFn = async (text) => {\n if (!navigator?.clipboard) {\n console.warn(\"Clipboard not supported\");\n return false;\n }\n\n // Try to save to clipboard then save it in the state if worked\n await navigator.clipboard.writeText(text);\n\n return true;\n};\n","/**\n * Creates a debounced function that delays invoking the provided function until after the specified delay.\n *\n * @param fn - The function to debounce.\n * @param delay - The number of milliseconds to delay.\n * @returns A new debounced function.\n */\n// biome-ignore lint/complexity/noBannedTypes: <explanation>\nexport function debounce(fn: Function, delay: number) {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n let timer: any;\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n return (...args: any[]) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n fn(...args);\n }, delay);\n };\n}\n","const encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nasync function getKey(key: string): Promise<CryptoKey> {\n const keyBytes = encoder.encode(key);\n if (keyBytes.length < 32) {\n throw new Error(\"Key must be at least 32 characters long\");\n }\n\n return await crypto.subtle.importKey(\n \"raw\",\n keyBytes.slice(0, 32), // Forzamos a 256 bits (32 bytes)\n { name: \"AES-GCM\" },\n false,\n [\"encrypt\", \"decrypt\"],\n );\n}\n\n/**\n * Encrypts a text using AES-GCM.\n * @param text - Text to encrypt\n * @param key - Key to encrypt the text\n * @returns Encrypted text in base64\n */\nexport async function encrypt(text: string, key: string): Promise<string> {\n const keyMaterial = await getKey(key);\n const iv = crypto.getRandomValues(new Uint8Array(12));\n const encrypted = await crypto.subtle.encrypt(\n { name: \"AES-GCM\", iv },\n keyMaterial,\n encoder.encode(text),\n );\n\n // Convertir a Base64 seguro\n const buffer = new Uint8Array([...iv, ...new Uint8Array(encrypted)]);\n return btoa(String.fromCharCode(...buffer));\n}\n\n/**\n * Decrypts an encrypted text using AES-GCM.\n * @param encryptedText - Encrypted text in base64\n * @param key - Key to decrypt the text\n * @returns Decrypted text\n */\nexport async function decrypt(encryptedText: string, key: string): Promise<string> {\n const keyMaterial = await getKey(key);\n const data = Uint8Array.from(atob(encryptedText), (c) => c.charCodeAt(0));\n\n const iv = data.slice(0, 12);\n const encryptedData = data.slice(12);\n const decrypted = await crypto.subtle.decrypt(\n { name: \"AES-GCM\", iv },\n keyMaterial,\n encryptedData,\n );\n\n return decoder.decode(decrypted);\n}\n","// The scores are arranged so that a continuous match of characters will\n// result in a total score of 1.\n//\n// The best case, this character is a match, and either this is the start\n// of the string, or the previous character was also a match.\nconst MATCH_CONTINUOUS = 1;\n// A new match at the start of a word scores better than a new match\n// elsewhere as it's more likely that the user will type the starts\n// of fragments.\n// NOTE: We score word jumps between spaces slightly higher than slashes, brackets\n// hyphens, etc.\nconst MATCH_NEW_WORD_SPACE = 0.9;\nconst MATCH_NEW_WORD_NON_SPACE = 0.8;\n// Any other match isn't ideal, but we include it for completeness.\nconst MATCH_CHARACTER_JUMP = 0.17;\n// If the user transposed two letters, it should be significantly penalized.\n//\n// i.e. \"ouch\" is more likely than \"curtain\" when \"uc\" is typed.\nconst PENALTY_TRANSPOSITION = 0.1;\n// The goodness of a match should decay slightly with each missing\n// character.\n//\n// i.e. \"bad\" is more likely than \"bard\" when \"bd\" is typed.\n//\n// This will not change the order of suggestions based on SCORE_* until\n// 100 characters are inserted between matches.\nconst PENALTY_SKIPPED_CHAR = 0.999;\n// The goodness of an exact-case match should be higher than a\n// case-insensitive match by a small amount.\n//\n// i.e. \"HTML\" is more likely than \"haml\" when \"HM\" is typed.\n//\n// This will not change the order of suggestions based on SCORE_* until\n// 1000 characters are inserted between matches.\nconst PENALTY_CASE_DIFFERENCE = 0.9999;\n// Match higher for letters closer to the beginning of the word\n// If the word has more characters than the user typed, it should\n// be penalised slightly.\n//\n// i.e. \"html\" is more likely than \"html5\" if I type \"html\".\n//\n// However, it may well be the case that there's a sensible secondary\n// ordering (like alphabetical) that it makes sense to rely on when\n// there are many prefix matches, so we don't make the penalty increase\n// with the number of tokens.\nconst PENALTY_INCOMPLETE_MATCH = 0.99;\n\nconst IS_GAP_REGEXP = /[\\\\\\/_+.#\"@\\[\\(\\{&]/;\nconst IS_SPACE_REGEXP = /[\\s-]/;\nconst COUNT_SPACE_REGEXP = /[\\s-]/g;\n\nexport function fuzzyFinderInner(\n string: string,\n abbreviation: string,\n lowerString: string,\n lowerAbbreviation: string,\n stringIndex: number,\n abbreviationIndex: number,\n memoizedResults: Record<string, number>,\n) {\n if (abbreviationIndex === abbreviation.length) {\n if (stringIndex === string.length) {\n return MATCH_CONTINUOUS;\n }\n return PENALTY_INCOMPLETE_MATCH;\n }\n\n const memoizeKey = `${stringIndex},${abbreviationIndex}`;\n if (memoizedResults[memoizeKey] !== undefined) {\n return memoizedResults[memoizeKey];\n }\n\n const abbreviationChar = lowerAbbreviation.charAt(abbreviationIndex);\n let index = lowerString.indexOf(abbreviationChar, stringIndex);\n let highScore = 0;\n\n let score: number;\n let transposedScore: number;\n let spaceBreaks: RegExpMatchArray | null;\n\n while (index >= 0) {\n score = fuzzyFinderInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n index + 1,\n abbreviationIndex + 1,\n memoizedResults,\n );\n if (score > highScore) {\n if (index === stringIndex) {\n score *= MATCH_CONTINUOUS;\n } else if (IS_GAP_REGEXP.test(string.charAt(index - 1))) {\n score *= MATCH_NEW_WORD_NON_SPACE;\n } else if (IS_SPACE_REGEXP.test(string.charAt(index - 1))) {\n score *= MATCH_NEW_WORD_SPACE;\n spaceBreaks = string.slice(stringIndex, index - 1).match(COUNT_SPACE_REGEXP);\n\n if (spaceBreaks && stringIndex > 0) {\n score *= PENALTY_SKIPPED_CHAR ** spaceBreaks.length;\n }\n } else {\n score *= MATCH_CHARACTER_JUMP;\n if (stringIndex > 0) {\n score *= PENALTY_SKIPPED_CHAR ** (index - stringIndex);\n }\n }\n\n if (string.charAt(index) !== abbreviation.charAt(abbreviationIndex)) {\n score *= PENALTY_CASE_DIFFERENCE;\n }\n }\n\n if (\n (score < PENALTY_TRANSPOSITION &&\n lowerString.charAt(index - 1) === lowerAbbreviation.charAt(abbreviationIndex + 1)) ||\n (lowerAbbreviation.charAt(abbreviationIndex + 1) === lowerAbbreviation.charAt(abbreviationIndex) && // allow duplicate letters. Ref #7428\n lowerString.charAt(index - 1) !== lowerAbbreviation.charAt(abbreviationIndex))\n ) {\n transposedScore = fuzzyFinderInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n index + 1,\n abbreviationIndex + 2,\n memoizedResults,\n );\n\n if (transposedScore * PENALTY_TRANSPOSITION > score) {\n score = transposedScore * PENALTY_TRANSPOSITION;\n }\n }\n\n if (score > highScore) {\n highScore = score;\n }\n\n index = lowerString.indexOf(abbreviationChar, index + 1);\n }\n\n memoizedResults[memoizeKey] = highScore;\n return highScore;\n}\n\nfunction formatInput(string: string) {\n return string.toLowerCase().replace(COUNT_SPACE_REGEXP, \" \"); // convert all valid space characters to space so they match each other\n}\n\nexport function fuzzyFinder(string: string, abbreviation: string, aliases: string[]): number {\n const s = aliases && aliases.length > 0 ? `${`${string} ${aliases.join(\" \")}`}` : string;\n return fuzzyFinderInner(s, abbreviation, formatInput(string), formatInput(abbreviation), 0, 0, {});\n}\n","export const generateUUID = (limit?: number): string => {\n // if limit is 0, return an empty string (why would you do this?)\n if (limit === 0) {\n return \"\";\n }\n\n // Generate a random array of 16 bytes (128 bits)\n const randomBytes = new Uint8Array(16);\n crypto.getRandomValues(randomBytes);\n\n // Set version (4) and variant (10) bits\n randomBytes[6] = (randomBytes[6] & 0x0f) | 0x40;\n randomBytes[8] = (randomBytes[8] & 0x3f) | 0x80;\n\n // Map bytes to hexadecimal and insert hyphens\n const hexBytes = Array.from(randomBytes, (byte) => byte.toString(16).padStart(2, \"0\"));\n\n // Join bytes into UUID format\n const uuid = `${hexBytes.slice(0, 4).join(\"\")}-${hexBytes\n .slice(4, 6)\n .join(\"\")}-${hexBytes.slice(6, 8).join(\"\")}-${hexBytes.slice(8, 10).join(\"\")}-${hexBytes.slice(10).join(\"\")}`;\n\n // Apply the limit if provided\n return limit ? uuid.slice(0, limit) : uuid;\n};\n","/**\n * Pauses the execution for a specified duration.\n *\n * @param {number | `${number}ms`} ms - The duration to sleep. It can be a number representing milliseconds or a string in the format `${number}ms`.\n * @returns {Promise<void>} A promise that resolves after the specified duration.\n *\n * @example Sleep for 1000 milliseconds\n * await sleep(1000);\n *\n * @example Sleep for 2 seconds\n * await sleep(\"2000ms\");\n */\nexport const sleep = (ms: number | `${number}ms`): Promise<void> => {\n let duration: number;\n if (typeof ms === \"string\") {\n duration = Number.parseInt(ms);\n } else {\n duration = ms;\n }\n return new Promise((resolve) => setTimeout(resolve, duration));\n};\n","/**\n * @name DirEnum\n * @description Enum for the different directions, rtl, ltr and auto\n * @property {string} rtl - Right to left direction\n * @property {string} ltr - Left to right direction\n * @property {string} auto - Automatic direction\n * @example\n * <Tooltip dir={DirEnum.rtl} ... // Right to left direction\n * <Tooltip dir={DirEnum.ltr} ... // Left to right direction\n * <Tooltip dir={DirEnum.auto} ... // Automatic direction\n * @see getDocumentDirection for the usage of this enum\n * @author Pol Gubau Amores - https://polgubau.com\n */\nexport enum DirEnum {\n\trtl = \"rtl\",\n\tltr = \"ltr\",\n\tauto = \"auto\",\n}\nexport type Dir = `${DirEnum}`;\n\nexport function getDocumentDirection(): Dir {\n\tif (typeof window === \"undefined\" || !window.document) {\n\t\treturn \"ltr\";\n\t}\n\n\tconst dirAttribute = document.documentElement.getAttribute(\"dir\") as Dir;\n\tif (dirAttribute === DirEnum.auto || !dirAttribute) {\n\t\treturn window.getComputedStyle(document.documentElement).direction as Dir;\n\t}\n\treturn dirAttribute;\n}\n","export const isClient: () => boolean = () => {\n return typeof window !== \"undefined\";\n};\n","/**\n * Checks if a given key is a deep key.\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @param {PropertyKey} key - The key to check.\n * @returns {boolean} - Returns true if the key is a deep key, otherwise false.\n *\n * Examples:\n *\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // false\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n */\nexport function isDeepKey(key: PropertyKey): boolean {\n switch (typeof key) {\n case \"number\":\n case \"symbol\": {\n return false;\n }\n case \"string\": {\n return key.includes(\".\") || key.includes(\"[\") || key.includes(\"]\");\n }\n default: {\n return false;\n }\n }\n}\n","export function isEqual<T>(array1: T[], array2: T[]): boolean {\n if (array1.length !== array2.length) {\n return false;\n }\n\n for (let i = 0; i < array1.length; i++) {\n if (array1[i] !== array2[i]) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Check if provided parameter is plain object\n * @param item\n * @returns boolean\n */\nexport function isObject(item: unknown): item is Record<string, unknown> {\n return item !== null && typeof item === \"object\" && item.constructor === Object;\n}\n","import { isObject } from \"../../comparators\";\n\n/**\n * Deep clone an object\n * A deep clone is a clone of the source object and all of its children, and their children, and so on.\n * @param source <T> - The source object to clone\n * @returns <T> - A deep clone of the source object\n */\nexport function cloneDeep<T>(source: T): T {\n if (!isObject(source)) {\n return source;\n }\n\n const output: Record<string, unknown> = {};\n\n for (const key in source) {\n output[key] = cloneDeep(source[key]);\n }\n\n return output as T;\n}\n"," export const DEFAULT_KEYS = [\n \"displayName\",\n \"name\",\n \"label\",\n \"title\",\n \"main\",\n \"code\",\n \"value\",\n \"userName\",\n \"locale\",\n \"id\",\n \"fullName\",\n \"shortName\",\n];\n\n/**\n * Retrieves the main field from an item object based on a predefined list of labels to highlight.\n *\n * @param item - The item object from which to extract the main field.\n * @returns An object containing the key and value of the main field.\n *\n * The function searches for the first label in the `labelsToHighlight` array that exists in the item object.\n * If a label is found, it returns an object with the label as the key and the corresponding value from the item.\n * If no label is found, it returns the first key-value pair from the item object.\n */\nexport const getMainField = (\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n item: Record<string, any>,\n): {\n key: string;\n value: string;\n} => {\n // search for the first time a label is found in labelsToHighlight (1st position has preference over 2nd position)\n\n const label = DEFAULT_KEYS.find((label) => {\n const value = item?.[label];\n if (value) {\n return true;\n }\n });\n\n if (label) {\n const value = item[label];\n return { key: label, value };\n }\n\n const object = {\n key: Object.keys(item)[0],\n value: item[Object.keys(item)[0] as string],\n };\n\n return object;\n};\n","import { isObject } from \"../../comparators\";\nimport { cloneDeep } from \"../clone-deps/clone-deep\";\n\n/**\n * Merge and deep copy the values of all of the enumerable own properties of target object from source object to a new object\n * @param target The target object to get properties from.\n * @param source The source object from which to copy properties.\n * @return A new merged and deep copied object.\n */\nexport function mergeDeep<T extends object, S extends object>(target: T, source: S): T & S {\n if (isObject(source) && Object.keys(source).length === 0) {\n return cloneDeep({ ...target, ...source });\n }\n\n const output = { ...target, ...source };\n\n if (isObject(source) && isObject(target)) {\n for (const key in source) {\n if (isObject(source[key]) && key in target && isObject(target[key])) {\n (output as Record<string, unknown>)[key] = mergeDeep(target[key] as object, source[key] as object);\n } else {\n (output as Record<string, unknown>)[key] = isObject(source[key]) ? cloneDeep(source[key]) : source[key];\n }\n }\n }\n\n return output;\n}\n","/**\n * Merges the properties of the source object into the target object.\n *\n * This function performs a deep merge, meaning nested objects and arrays are merged recursively.\n * If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is undefined, it will not overwrite a defined property in the target object.\n *\n * Note that this function mutates the target object.\n *\n * @param {T} target - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S} source - The source object whose properties will be merged into the target object.\n * @returns {T & S} The updated target object with properties from the source object merged in.\n *\n * @template T - Type of the target object.\n * @template S - Type of the source object.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.info(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.info(result);\n * // Output: { a: [3, 2], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.info(result);\n * // Output: { a: [1, 2, 3] }\n */\n\nexport function isObjectLike(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\nexport function merge<T, S>(target: T, source: S): T & S;\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport function merge(target: any, source: any) {\n const sourceKeys = Object.keys(source);\n\n for (const key of sourceKeys) {\n const sourceValue = source[key];\n const targetValue = target[key];\n\n if (Array.isArray(sourceValue)) {\n target[key] = merge(targetValue ?? [], sourceValue);\n } else if (isObjectLike(targetValue) && isObjectLike(sourceValue)) {\n target[key] = merge(targetValue ?? {}, sourceValue);\n } else if (targetValue === undefined || sourceValue !== undefined) {\n target[key] = sourceValue;\n }\n }\n\n return target;\n}\n","/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n","/**\n * Converts a deep key string into an array of path segments.\n *\n * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path.\n *\n * @param {string} deepKey - The deep key string to convert.\n * @returns {string[]} An array of strings, each representing a segment of the path.\n *\n * Examples:\n *\n * toPath('a.b.c') // Returns ['a', 'b', 'c']\n * toPath('a[b][c]') // Returns ['a', 'b', 'c']\n * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c']\n * toPath('a[\"b.c\"].d') // Returns ['a', 'b.c', 'd']\n * toPath('') // Returns []\n * toPath('.a[b].c.d[e][\"f.g\"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']\n */\nexport function toPath(deepKey: string): string[] {\n const result: string[] = [];\n const length = deepKey.length;\n\n if (length === 0) {\n return result;\n }\n\n let index = 0;\n let key = \"\";\n let quoteChar = \"\";\n let bracket = false;\n\n // Leading dot\n if (deepKey.charCodeAt(0) === 46) {\n result.push(\"\");\n index++;\n }\n\n while (index < length) {\n const char = deepKey[index];\n\n if (quoteChar) {\n if (char === \"\\\\\" && index + 1 < length) {\n // Escape character\n index++;\n key += deepKey[index];\n } else if (char === quoteChar) {\n // End of quote\n quoteChar = \"\";\n } else {\n key += char;\n }\n } else if (bracket) {\n if (char === '\"' || char === \"'\") {\n // Start of quoted string inside brackets\n quoteChar = char;\n } else if (char === \"]\") {\n // End of bracketed segment\n bracket = false;\n result.push(key);\n key = \"\";\n } else {\n key += char;\n }\n } else if (char === \"[\") {\n // Start of bracketed segment\n bracket = true;\n if (key) {\n result.push(key);\n key = \"\";\n }\n } else if (char === \".\") {\n if (key) {\n result.push(key);\n key = \"\";\n }\n } else {\n key += char;\n }\n\n index++;\n }\n\n if (key) {\n result.push(key);\n }\n\n return result;\n}\n","/**\n * @name px\n * @description Converts the specified number to a pixel string\n * @param arg <string | number> The number to convert\n * @returns <string> The pixel string\n * @example\n * const pxString = px(10);\n * console.info(pxString); // 10px\n * const pxString = px('10'); // 10px\n *\n * @author Pol Gubau Amores - https://polgubau.com\n */\nexport function px(arg: string | number) {\n return `${arg.toString()}px`;\n}\n","/**\n * Converts a string to camel case.\n * @param {string} str - The string to convert.\n * @returns {string} The camel-cased string.\n * @example\n * ```javascript\n * toCamelCase('hello-world'); // 'helloWorld'\n * toCamelCase('hello_world'); // 'helloWorld'\n * ```\n */\nfunction toCamelCase(str: string): string {\n return str.replace(/[-_](.)/g, (_, c: string) => c.toUpperCase());\n}\n\n/**\n * Converts a string to title case.\n * @param {string} str - The string to convert.\n * @returns {string} The title-cased string.\n */\nfunction toTitleCase(str: string): string {\n return str.replace(/\\w\\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase());\n}\n/**\n * Converts a string to kebab case.\n * @param {string} str - The string to convert.\n * @returns {string} The kebab-cased string.\n */\nfunction toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/\\s+/g, \"-\")\n .toLowerCase();\n}\n\n/**\n * Converts a string to upper case.\n * @param {string} str - The string to convert.\n * @returns {string} The uppercased string.\n */\nfunction toUpperCase(str: string): string {\n return str.toUpperCase();\n}\n\n/**\n * Converts a string to lower case.\n * @param {string} str - The string to convert.\n * @returns {string} The lowercased string.\n */\nfunction toLowerCase(str: string): string {\n return str.toLowerCase();\n}\n/**\n * Capitalizes the first letter of a string.\n * @param {string} str - The string to capitalize.\n * @returns {string} The capitalized string.\n */\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Removes all whitespace from a string.\n * @param {string} str - The string to remove whitespace from.\n * @returns {string} The whitespace-free string.\n */\nfunction removeWhitespace(str: string): string {\n return str.replace(/\\s/g, \"\");\n}\n\n/**\n * Reverses a string.\n * @param {string} str - The string to reverse.\n * @returns {string} The reversed string.\n */\nfunction reverseString(str: string): string {\n return str.split(\"\").reverse().join(\"\");\n}\n\n/**\n * Truncates a string to a specified length.\n * @param {string} str - The string to truncate.\n * @param {number} length - The maximum length of the truncated string.\n * @param {string} suffix - Optional suffix to append to truncated string. Defaults to '...'.\n * @returns {string} The truncated string.\n */\n\nfunction truncateString(str: string, length = 50, suffix = \"...\"): string {\n if (str.length === 0) {\n return str;\n }\n return str.length > length ? str.substring(0, length - suffix.length) + suffix : str;\n}\n\n/**\n * Formats a string to be more human-readable.\n * @param {string} str - The string to format.\n * @returns {string} The formatted string.\n * @example\n * ```javascript\n * formatString('helloWorld'); // 'Hello World'\n * formatString('helloWorldAgain'); // 'Hello World Again'\n * ```\n *\n */\nfunction formatString(str: string): string {\n const result = str.replace(/([a-z])([A-Z])/g, \"$1 $2\");\n return capitalize(result.replace(/([A-Z])([A-Z][a-z])/g, \"$1 $2\").trim());\n}\n\n/**\n * @name randomString\n * @description Generates a random string of a specified length.\n * @param {number} length - The length of the random string to generate.\n * @returns {string} The random string.\n * @example ```javascript\n * randomString(10); // 'aBcDeFgHiJ'\n * randomString(5); // 'aBcDe'\n * ```\n */\nconst randomString = (length = 4): string => {\n const characters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n let result = \"\";\n\n for (let i = 0; i < length; i++) {\n const randomIndex = Math.floor(Math.random() * characters.length);\n result += characters.charAt(randomIndex);\n }\n return result;\n};\n\n// input: Global Wizard Flow\n// output: globalwizardflow\n/**\n * @name lowerAndNoSpace\n * @description Converts a string to lowercase and removes all whitespace.\n * @param {string} str - The string to convert.\n * @returns {string} The converted string.\n * @example ```javascript\n * lowerAndNoSpace('Global Wizard Flow'); // 'globalwizardflow'\n * lowerAndNoSpace('Global Wizard Flow'); // 'globalwizardflow'\n * ```\n * */\nconst lowerAndNoSpace = (str: string): string => {\n return str.toLowerCase().replace(/\\s/g, \"\");\n};\n\nexport {\n toCamelCase,\n toTitleCase,\n toKebabCase,\n toUpperCase,\n toLowerCase,\n capitalize,\n removeWhitespace,\n reverseString,\n truncateString,\n formatString,\n randomString,\n lowerAndNoSpace,\n};\n"],"mappings":"AAMO,SAASA,EAASC,EAAyB,CAChD,OAAOA,EAAI,CAAC,CACd,CAQO,SAASC,EAAQD,EAAyB,CAC/C,OAAOA,EAAIA,EAAI,OAAS,CAAC,CAC3B,CASO,SAASE,EAAeF,EAAe,CAC5C,OAAOA,EAAI,MAAM,CAAC,CACpB,CAQO,SAASG,EAAcH,EAAe,CAC3C,OAAOA,EAAI,MAAM,EAAGA,EAAI,OAAS,CAAC,CACpC,CCjCO,IAAMI,EAAQ,CAAIC,EAAWC,EAAO,KAClCD,EAAK,OAAO,CAACE,EAAeC,EAAMC,IAAU,CACjD,IAAMC,EAAa,KAAK,MAAMD,EAAQH,CAAI,EAC1C,OAAKC,EAAOG,CAAU,IACpBH,EAAOG,CAAU,EAAI,CAAC,GAExBH,EAAOG,CAAU,EAAE,KAAKF,CAAI,EACrBD,CACT,EAAG,CAAC,CAAC,ECkBA,SAASI,EAAkCC,EAAmBC,EAAgD,CACnH,IAAMC,EAAS,CAAC,EAEhB,QAAWC,KAAQH,EAAK,CACtB,IAAMI,EAAMH,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CACA,OAAOJ,CACT,EAcMK,GAAmBpB,GAChBA,EAAI,YAAY,EAAE,QAAQ,MAAO,EAAE","names":["first","arr","last","removeFirst","removeLast","chunk","data","size","chunks","item","index","chunkIndex","groupBy","arr","getKeyFromItem","result","item","key","limitArray","arr","limit","limitedArray","remaining","remove","arr","index","adjustedIndex","shuffle","arr","result","i","j","temp","resultJ","clamp","value","bound1","bound2","setCookie","name","value","days","expirationDate","cookieValue","getCookie","cookies","cookie","cookieName","deleteCookie","errorLabel","parseJSON","value","saveParseJson","stringify","json","getLocalStorage","key","initialValue","value","json","setToLocalStorage","removeFromLocalStorage","copyToClipboard","text","debounce","fn","delay","timer","args","encoder","decoder","getKey","key","keyBytes","encrypt","text","keyMaterial","iv","encrypted","buffer","decrypt","encryptedText","data","c","encryptedData","decrypted","IS_GAP_REGEXP","IS_SPACE_REGEXP","COUNT_SPACE_REGEXP","fuzzyFinderInner","string","abbreviation","lowerString","lowerAbbreviation","stringIndex","abbreviationIndex","memoizedResults","memoizeKey","abbreviationChar","index","highScore","score","transposedScore","spaceBreaks","formatInput","fuzzyFinder","aliases","s","generateUUID","limit","randomBytes","hexBytes","byte","uuid","sleep","ms","duration","resolve","DirEnum","getDocumentDirection","dirAttribute","isClient","isDeepKey","key","isEqual","array1","array2","i","isObject","item","cloneDeep","source","isObject","output","key","DEFAULT_KEYS","getMainField","item","label","value","mergeDeep","target","source","isObject","cloneDeep","output","key","isObjectLike","value","merge","target","source","sourceKeys","key","sourceValue","targetValue","omit","obj","keys","result","key","toPath","deepKey","result","length","index","key","quoteChar","bracket","char","px","arg","toCamelCase","str","_","c","toTitleCase","txt","toKebabCase","toUpperCase","toLowerCase","capitalize","removeWhitespace","reverseString","truncateString","length","suffix","formatString","result","randomString","characters","i","randomIndex","lowerAndNoSpace"]}