@entrolytics/utilities 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -21
- package/dist/index.cjs +336 -264
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -112
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +121 -112
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +335 -263
- package/dist/index.js.map +1 -1
- package/package.json +29 -27
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/string.ts","../src/date.ts","../src/url.ts","../src/hash.ts","../src/retry.ts","../src/debounce.ts","../src/throttle.ts","../src/storage.ts"],"names":[],"mappings":";;;AAOO,SAAS,QAAA,CAAS,GAAA,EAAa,SAAA,EAAmB,MAAA,GAAS,KAAA,EAAe;AAC/E,EAAA,IAAI,GAAA,CAAI,MAAA,IAAU,SAAA,EAAW,OAAO,GAAA;AACpC,EAAA,OAAO,IAAI,KAAA,CAAM,CAAA,EAAG,SAAA,GAAY,MAAA,CAAO,MAAM,CAAA,GAAI,MAAA;AACnD;AAKO,SAAS,WAAW,GAAA,EAAqB;AAC9C,EAAA,OAAO,GAAA,CAAI,MAAA,CAAO,CAAC,CAAA,CAAE,WAAA,KAAgB,GAAA,CAAI,KAAA,CAAM,CAAC,CAAA,CAAE,WAAA,EAAY;AAChE;AAKO,SAAS,YAAY,GAAA,EAAqB;AAC/C,EAAA,OAAO,GAAA,CACJ,QAAQ,iBAAA,EAAmB,OAAO,EAClC,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA,CACtB,WAAA,EAAY;AACjB;AAKO,SAAS,YAAY,GAAA,EAAqB;AAC/C,EAAA,OAAO,GAAA,CACJ,WAAA,EAAY,CACZ,OAAA,CAAQ,mBAAA,EAAqB,CAAC,CAAA,EAAG,GAAA,KAAQ,GAAA,CAAI,WAAA,EAAa,CAAA;AAC/D;AAK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C,IAAA,IAAI;AACF,MAAA,MAAA,CAAO,eAAe,OAAA,CAAQ,GAAA,EAAK,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AAAA,IAC1D,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,sCAAsC,KAAK,CAAA;AAAA,IAC3D;AAAA,EACF,CAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,GAAA,EAAmB;AACxB,IAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAEnC,IAAA,IAAI;AACF,MAAA,MAAA,CAAO,cAAA,CAAe,WAAW,GAAG,CAAA;AAAA,IACtC,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,yCAAyC,KAAK,CAAA;AAAA,IAC9D;AAAA,EACF,CAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA,GAAc;AACZ,IAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAEnC,IAAA,IAAI;AACF,MAAA,MAAA,CAAO,eAAe,KAAA,EAAM;AAAA,IAC9B,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,mCAAmC,KAAK,CAAA;AAAA,IACxD;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["/**\n * String utility functions\n */\n\n/**\n * Truncate a string to a maximum length\n */\nexport function truncate(str: string, maxLength: number, suffix = '...'): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Capitalize the first letter of a string\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n}\n\n/**\n * Convert string to kebab-case\n */\nexport function 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 * Convert string to camelCase\n */\nexport function toCamelCase(str: string): string {\n return str\n .toLowerCase()\n .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());\n}\n\n/**\n * Convert string to snake_case\n */\nexport function toSnakeCase(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 * Generate a random alphanumeric string\n */\nexport function randomString(length: number): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n\n/**\n * Slugify a string for URLs\n */\nexport function slugify(str: string): string {\n return str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_-]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n","/**\n * Date utility functions\n */\n\n/**\n * Format date to ISO string\n */\nexport function toISOString(date: Date | string | number): string {\n return new Date(date).toISOString();\n}\n\n/**\n * Format date to YYYY-MM-DD\n */\nexport function toDateString(date: Date | string | number): string {\n const d = new Date(date);\n const year = d.getFullYear();\n const month = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/**\n * Get date range for the last N days\n */\nexport function getLastNDays(n: number): { startDate: Date; endDate: Date } {\n const endDate = new Date();\n const startDate = new Date();\n startDate.setDate(startDate.getDate() - n);\n return { startDate, endDate };\n}\n\n/**\n * Check if a date is today\n */\nexport function isToday(date: Date | string | number): boolean {\n const d = new Date(date);\n const today = new Date();\n return d.toDateString() === today.toDateString();\n}\n\n/**\n * Add days to a date\n */\nexport function addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\n/**\n * Get start of day\n */\nexport function startOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\n/**\n * Get end of day\n */\nexport function endOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\n/**\n * Get difference in days between two dates\n */\nexport function daysDifference(date1: Date, date2: Date): number {\n const oneDay = 24 * 60 * 60 * 1000;\n return Math.round(Math.abs((date1.getTime() - date2.getTime()) / oneDay));\n}\n","/**\n * URL utility functions\n */\n\n/**\n * Parse query parameters from URL\n */\nexport function parseQueryParams(url: string): Record<string, string> {\n const params: Record<string, string> = {};\n const urlObj = new URL(url);\n urlObj.searchParams.forEach((value, key) => {\n params[key] = value;\n });\n return params;\n}\n\n/**\n * Build query string from object\n */\nexport function buildQueryString(params: Record<string, unknown>): string {\n const searchParams = new URLSearchParams();\n Object.entries(params).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n searchParams.append(key, String(value));\n }\n });\n return searchParams.toString();\n}\n\n/**\n * Get domain from URL\n */\nexport function getDomain(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.hostname;\n } catch {\n return '';\n }\n}\n\n/**\n * Get pathname from URL\n */\nexport function getPathname(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.pathname;\n } catch {\n return '';\n }\n}\n\n/**\n * Validate URL\n */\nexport function isValidUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Combine URL parts\n */\nexport function combineUrl(base: string, ...paths: string[]): string {\n let url = base.replace(/\\/+$/, '');\n for (const path of paths) {\n url += '/' + path.replace(/^\\/+/, '');\n }\n return url;\n}\n","/**\n * Hashing utility functions\n */\n\n/**\n * Simple hash function for strings (non-cryptographic)\n */\nexport function simpleHash(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash |= 0; // Convert to 32bit integer\n }\n return Math.abs(hash);\n}\n\n/**\n * Generate a simple hash string from input\n */\nexport function hashString(str: string): string {\n return simpleHash(str).toString(36);\n}\n\n/**\n * Generate a deterministic ID from multiple values\n */\nexport function generateId(...values: (string | number)[]): string {\n const combined = values.join('|');\n return hashString(combined);\n}\n","/**\n * Retry utility with exponential backoff\n */\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoffMultiplier?: number;\n maxDelayMs?: number;\n onRetry?: (error: Error, attempt: number) => void;\n}\n\n/**\n * Retry a function with exponential backoff\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const {\n maxAttempts = 3,\n delayMs = 1000,\n backoffMultiplier = 2,\n maxDelayMs = 30000,\n onRetry,\n } = options;\n\n let lastError: Error;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt === maxAttempts) {\n throw lastError;\n }\n\n const delay = Math.min(delayMs * Math.pow(backoffMultiplier, attempt - 1), maxDelayMs);\n\n if (onRetry) {\n onRetry(lastError, attempt);\n }\n\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n throw lastError!;\n}\n","/**\n * Debounce utility\n */\n\n// biome-ignore lint: any is needed for generic function signature\nexport function debounce<T extends (...args: any[]) => any>(\n func: T,\n waitMs: number\n): (...args: Parameters<T>) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n return function debounced(...args: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, waitMs);\n };\n}\n","/**\n * Throttle utility\n */\n\n// biome-ignore lint: any is needed for generic function signature\nexport function throttle<T extends (...args: any[]) => any>(\n func: T,\n limitMs: number\n): (...args: Parameters<T>) => void {\n let inThrottle = false;\n let lastArgs: Parameters<T> | null = null;\n\n return function throttled(...args: Parameters<T>) {\n if (!inThrottle) {\n func(...args);\n inThrottle = true;\n\n setTimeout(() => {\n inThrottle = false;\n if (lastArgs !== null) {\n throttled(...lastArgs);\n lastArgs = null;\n }\n }, limitMs);\n } else {\n lastArgs = args;\n }\n };\n}\n","/**\n * Storage utility functions for browser localStorage/sessionStorage\n */\n\n/**\n * Safe localStorage wrapper\n */\nexport const storage = {\n /**\n * Get item from localStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === 'undefined') return defaultValue ?? null;\n\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in localStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error('Failed to set localStorage item:', error);\n }\n },\n\n /**\n * Remove item from localStorage\n */\n remove(key: string): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.removeItem(key);\n } catch (error) {\n console.error('Failed to remove localStorage item:', error);\n }\n },\n\n /**\n * Clear all localStorage\n */\n clear(): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.clear();\n } catch (error) {\n console.error('Failed to clear localStorage:', error);\n }\n },\n};\n\n/**\n * Safe sessionStorage wrapper\n */\nexport const sessionStorage = {\n /**\n * Get item from sessionStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === 'undefined') return defaultValue ?? null;\n\n try {\n const item = window.sessionStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in sessionStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error('Failed to set sessionStorage item:', error);\n }\n },\n\n /**\n * Remove item from sessionStorage\n */\n remove(key: string): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.removeItem(key);\n } catch (error) {\n console.error('Failed to remove sessionStorage item:', error);\n }\n },\n\n /**\n * Clear all sessionStorage\n */\n clear(): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.clear();\n } catch (error) {\n console.error('Failed to clear sessionStorage:', error);\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/date.ts","../src/debounce.ts","../src/hash.ts","../src/retry.ts","../src/storage.ts","../src/string.ts","../src/throttle.ts","../src/url.ts"],"sourcesContent":["/**\n * Date utility functions\n */\n\n/**\n * Format date to ISO string\n */\nexport function toISOString(date: Date | string | number): string {\n return new Date(date).toISOString();\n}\n\n/**\n * Format date to YYYY-MM-DD\n */\nexport function toDateString(date: Date | string | number): string {\n const d = new Date(date);\n const year = d.getFullYear();\n const month = String(d.getMonth() + 1).padStart(2, \"0\");\n const day = String(d.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n}\n\n/**\n * Get date range for the last N days\n */\nexport function getLastNDays(n: number): { startDate: Date; endDate: Date } {\n const endDate = new Date();\n const startDate = new Date();\n startDate.setDate(startDate.getDate() - n);\n return { startDate, endDate };\n}\n\n/**\n * Check if a date is today\n */\nexport function isToday(date: Date | string | number): boolean {\n const d = new Date(date);\n const today = new Date();\n return d.toDateString() === today.toDateString();\n}\n\n/**\n * Add days to a date\n */\nexport function addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\n/**\n * Get start of day\n */\nexport function startOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\n/**\n * Get end of day\n */\nexport function endOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\n/**\n * Get difference in days between two dates\n */\nexport function daysDifference(date1: Date, date2: Date): number {\n const oneDay = 24 * 60 * 60 * 1000;\n return Math.round(Math.abs((date1.getTime() - date2.getTime()) / oneDay));\n}\n","/**\n * Debounce utility\n */\n\nexport function debounce<T extends (...args: unknown[]) => unknown>(\n func: T,\n waitMs: number,\n): (...args: Parameters<T>) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n return function debounced(...args: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, waitMs);\n };\n}\n","/**\n * Hashing utility functions\n */\n\n/**\n * Simple hash function for strings (non-cryptographic)\n */\nexport function simpleHash(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash |= 0; // Convert to 32bit integer\n }\n return Math.abs(hash);\n}\n\n/**\n * Generate a simple hash string from input\n */\nexport function hashString(str: string): string {\n return simpleHash(str).toString(36);\n}\n\n/**\n * Generate a deterministic ID from multiple values\n */\nexport function generateId(...values: (string | number)[]): string {\n const combined = values.join(\"|\");\n return hashString(combined);\n}\n","/**\n * Retry utility with exponential backoff\n */\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoffMultiplier?: number;\n maxDelayMs?: number;\n onRetry?: (error: Error, attempt: number) => void;\n}\n\n/**\n * Retry a function with exponential backoff\n */\nexport async function retry<T>(fn: () => Promise<T>, options: RetryOptions = {}): Promise<T> {\n const {\n maxAttempts = 3,\n delayMs = 1000,\n backoffMultiplier = 2,\n maxDelayMs = 30000,\n onRetry,\n } = options;\n\n let lastError: Error;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt === maxAttempts) {\n throw lastError;\n }\n\n const delay = Math.min(delayMs * backoffMultiplier ** (attempt - 1), maxDelayMs);\n\n if (onRetry) {\n onRetry(lastError, attempt);\n }\n\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw lastError!;\n}\n","/**\n * Storage utility functions for browser localStorage/sessionStorage\n */\n\n/**\n * Safe localStorage wrapper\n */\nexport const storage = {\n /**\n * Get item from localStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === \"undefined\") return defaultValue ?? null;\n\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in localStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === \"undefined\") return;\n\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error(\"Failed to set localStorage item:\", error);\n }\n },\n\n /**\n * Remove item from localStorage\n */\n remove(key: string): void {\n if (typeof window === \"undefined\") return;\n\n try {\n window.localStorage.removeItem(key);\n } catch (error) {\n console.error(\"Failed to remove localStorage item:\", error);\n }\n },\n\n /**\n * Clear all localStorage\n */\n clear(): void {\n if (typeof window === \"undefined\") return;\n\n try {\n window.localStorage.clear();\n } catch (error) {\n console.error(\"Failed to clear localStorage:\", error);\n }\n },\n};\n\n/**\n * Safe sessionStorage wrapper\n */\nexport const sessionStorage = {\n /**\n * Get item from sessionStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === \"undefined\") return defaultValue ?? null;\n\n try {\n const item = window.sessionStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in sessionStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === \"undefined\") return;\n\n try {\n window.sessionStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error(\"Failed to set sessionStorage item:\", error);\n }\n },\n\n /**\n * Remove item from sessionStorage\n */\n remove(key: string): void {\n if (typeof window === \"undefined\") return;\n\n try {\n window.sessionStorage.removeItem(key);\n } catch (error) {\n console.error(\"Failed to remove sessionStorage item:\", error);\n }\n },\n\n /**\n * Clear all sessionStorage\n */\n clear(): void {\n if (typeof window === \"undefined\") return;\n\n try {\n window.sessionStorage.clear();\n } catch (error) {\n console.error(\"Failed to clear sessionStorage:\", error);\n }\n },\n};\n","/**\n * String utility functions\n */\n\n/**\n * Truncate a string to a maximum length\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Capitalize the first letter of a string\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n}\n\n/**\n * Convert string to kebab-case\n */\nexport function 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 * Convert string to camelCase\n */\nexport function toCamelCase(str: string): string {\n return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());\n}\n\n/**\n * Convert string to snake_case\n */\nexport function toSnakeCase(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 * Generate a random alphanumeric string\n */\nexport function randomString(length: number): string {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n\n/**\n * Slugify a string for URLs\n */\nexport function slugify(str: string): string {\n return str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n","/**\n * Throttle utility\n */\n\nexport function throttle<T extends (...args: unknown[]) => unknown>(\n func: T,\n limitMs: number,\n): (...args: Parameters<T>) => void {\n let inThrottle = false;\n let lastArgs: Parameters<T> | null = null;\n\n return function throttled(...args: Parameters<T>) {\n if (!inThrottle) {\n func(...args);\n inThrottle = true;\n\n setTimeout(() => {\n inThrottle = false;\n if (lastArgs !== null) {\n throttled(...lastArgs);\n lastArgs = null;\n }\n }, limitMs);\n } else {\n lastArgs = args;\n }\n };\n}\n","/**\n * URL utility functions\n */\n\n/**\n * Parse query parameters from URL\n */\nexport function parseQueryParams(url: string): Record<string, string> {\n const params: Record<string, string> = {};\n const urlObj = new URL(url);\n urlObj.searchParams.forEach((value, key) => {\n params[key] = value;\n });\n return params;\n}\n\n/**\n * Build query string from object\n */\nexport function buildQueryString(params: Record<string, unknown>): string {\n const searchParams = new URLSearchParams();\n Object.entries(params).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n if (typeof value === \"string\") {\n searchParams.append(key, value);\n return;\n }\n\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") {\n searchParams.append(key, String(value));\n return;\n }\n\n if (value instanceof Date) {\n searchParams.append(key, value.toISOString());\n return;\n }\n\n searchParams.append(key, JSON.stringify(value));\n }\n });\n return searchParams.toString();\n}\n\n/**\n * Get domain from URL\n */\nexport function getDomain(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.hostname;\n } catch {\n return \"\";\n }\n}\n\n/**\n * Get pathname from URL\n */\nexport function getPathname(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.pathname;\n } catch {\n return \"\";\n }\n}\n\n/**\n * Validate URL\n */\nexport function isValidUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Combine URL parts\n */\nexport function combineUrl(base: string, ...paths: string[]): string {\n let url = base.replace(/\\/+$/, \"\");\n for (const path of paths) {\n url += \"/\" + path.replace(/^\\/+/, \"\");\n }\n return url;\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,YAAY,MAAsC;AAChE,QAAO,IAAI,KAAK,KAAK,CAAC,aAAa;;;;;AAMrC,SAAgB,aAAa,MAAsC;CACjE,MAAM,IAAI,IAAI,KAAK,KAAK;AAIxB,QAAO,GAHM,EAAE,aAAa,CAGb,GAFD,OAAO,EAAE,UAAU,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,CAE/B,GADZ,OAAO,EAAE,SAAS,CAAC,CAAC,SAAS,GAAG,IAAI;;;;;AAOl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AC;AACvC;;AAGF,OAAI,iBAAiB,MAAM;AACzB,iBAAa,OAAO,KAAK,MAAM,aAAa,CAAC;AAC7C;;AAGF,gBAAa,OAAO,KAAK,KAAK,UAAU,MAAM,CAAC;;GAEjD;AACF,QAAO,aAAa,UAAU;;;;;AAMhC,SAAgB,UAAU,KAAqB;AAC7C,KAAI;AAEF,SADe,IAAI,IAAI,IAAI,CACb;SACR;AACN,SAAO;;;;;;AAOX,SAAgB,YAAY,KAAqB;AAC/C,KAAI;AAEF,SADe,IAAI,IAAI,IAAI,CACb;SACR;AACN,SAAO;;;;;;AAOX,SAAgB,WAAW,KAAsB;AAC/C,KAAI;AACF,MAAI,IAAI,IAAI;AACZ,SAAO;SACD;AACN,SAAO;;;;;;AAOX,SAAgB,WAAW,MAAc,GAAG,OAAyB;CACnE,IAAI,MAAM,KAAK,QAAQ,QAAQ,GAAG;AAClC,MAAK,MAAM,QAAQ,MACjB,QAAO,MAAM,KAAK,QAAQ,QAAQ,GAAG;AAEvC,QAAO"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* String utility functions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Truncate a string to a maximum length
|
|
6
|
-
*/
|
|
7
|
-
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Capitalize the first letter of a string
|
|
10
|
-
*/
|
|
11
|
-
declare function capitalize(str: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Convert string to kebab-case
|
|
14
|
-
*/
|
|
15
|
-
declare function toKebabCase(str: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Convert string to camelCase
|
|
18
|
-
*/
|
|
19
|
-
declare function toCamelCase(str: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Convert string to snake_case
|
|
22
|
-
*/
|
|
23
|
-
declare function toSnakeCase(str: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Generate a random alphanumeric string
|
|
26
|
-
*/
|
|
27
|
-
declare function randomString(length: number): string;
|
|
28
|
-
/**
|
|
29
|
-
* Slugify a string for URLs
|
|
30
|
-
*/
|
|
31
|
-
declare function slugify(str: string): string;
|
|
32
|
-
|
|
1
|
+
//#region src/date.d.ts
|
|
33
2
|
/**
|
|
34
3
|
* Date utility functions
|
|
35
4
|
*/
|
|
@@ -45,8 +14,8 @@ declare function toDateString(date: Date | string | number): string;
|
|
|
45
14
|
* Get date range for the last N days
|
|
46
15
|
*/
|
|
47
16
|
declare function getLastNDays(n: number): {
|
|
48
|
-
|
|
49
|
-
|
|
17
|
+
startDate: Date;
|
|
18
|
+
endDate: Date;
|
|
50
19
|
};
|
|
51
20
|
/**
|
|
52
21
|
* Check if a date is today
|
|
@@ -68,35 +37,14 @@ declare function endOfDay(date: Date): Date;
|
|
|
68
37
|
* Get difference in days between two dates
|
|
69
38
|
*/
|
|
70
39
|
declare function daysDifference(date1: Date, date2: Date): number;
|
|
71
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/debounce.d.ts
|
|
72
42
|
/**
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* Parse query parameters from URL
|
|
77
|
-
*/
|
|
78
|
-
declare function parseQueryParams(url: string): Record<string, string>;
|
|
79
|
-
/**
|
|
80
|
-
* Build query string from object
|
|
81
|
-
*/
|
|
82
|
-
declare function buildQueryString(params: Record<string, unknown>): string;
|
|
83
|
-
/**
|
|
84
|
-
* Get domain from URL
|
|
85
|
-
*/
|
|
86
|
-
declare function getDomain(url: string): string;
|
|
87
|
-
/**
|
|
88
|
-
* Get pathname from URL
|
|
89
|
-
*/
|
|
90
|
-
declare function getPathname(url: string): string;
|
|
91
|
-
/**
|
|
92
|
-
* Validate URL
|
|
93
|
-
*/
|
|
94
|
-
declare function isValidUrl(url: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Combine URL parts
|
|
43
|
+
* Debounce utility
|
|
97
44
|
*/
|
|
98
|
-
declare function
|
|
99
|
-
|
|
45
|
+
declare function debounce<T extends (...args: unknown[]) => unknown>(func: T, waitMs: number): (...args: Parameters<T>) => void;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/hash.d.ts
|
|
100
48
|
/**
|
|
101
49
|
* Hashing utility functions
|
|
102
50
|
*/
|
|
@@ -112,32 +60,24 @@ declare function hashString(str: string): string;
|
|
|
112
60
|
* Generate a deterministic ID from multiple values
|
|
113
61
|
*/
|
|
114
62
|
declare function generateId(...values: (string | number)[]): string;
|
|
115
|
-
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/retry.d.ts
|
|
116
65
|
/**
|
|
117
66
|
* Retry utility with exponential backoff
|
|
118
67
|
*/
|
|
119
68
|
interface RetryOptions {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
69
|
+
maxAttempts?: number;
|
|
70
|
+
delayMs?: number;
|
|
71
|
+
backoffMultiplier?: number;
|
|
72
|
+
maxDelayMs?: number;
|
|
73
|
+
onRetry?: (error: Error, attempt: number) => void;
|
|
125
74
|
}
|
|
126
75
|
/**
|
|
127
76
|
* Retry a function with exponential backoff
|
|
128
77
|
*/
|
|
129
78
|
declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
* Debounce utility
|
|
133
|
-
*/
|
|
134
|
-
declare function debounce<T extends (...args: any[]) => any>(func: T, waitMs: number): (...args: Parameters<T>) => void;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Throttle utility
|
|
138
|
-
*/
|
|
139
|
-
declare function throttle<T extends (...args: any[]) => any>(func: T, limitMs: number): (...args: Parameters<T>) => void;
|
|
140
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/storage.d.ts
|
|
141
81
|
/**
|
|
142
82
|
* Storage utility functions for browser localStorage/sessionStorage
|
|
143
83
|
*/
|
|
@@ -145,43 +85,112 @@ declare function throttle<T extends (...args: any[]) => any>(func: T, limitMs: n
|
|
|
145
85
|
* Safe localStorage wrapper
|
|
146
86
|
*/
|
|
147
87
|
declare const storage: {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Get item from localStorage with JSON parsing
|
|
90
|
+
*/
|
|
91
|
+
get<T>(key: string, defaultValue?: T): T | null;
|
|
92
|
+
/**
|
|
93
|
+
* Set item in localStorage with JSON stringification
|
|
94
|
+
*/
|
|
95
|
+
set<T>(key: string, value: T): void;
|
|
96
|
+
/**
|
|
97
|
+
* Remove item from localStorage
|
|
98
|
+
*/
|
|
99
|
+
remove(key: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Clear all localStorage
|
|
102
|
+
*/
|
|
103
|
+
clear(): void;
|
|
164
104
|
};
|
|
165
105
|
/**
|
|
166
106
|
* Safe sessionStorage wrapper
|
|
167
107
|
*/
|
|
168
108
|
declare const sessionStorage: {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Get item from sessionStorage with JSON parsing
|
|
111
|
+
*/
|
|
112
|
+
get<T>(key: string, defaultValue?: T): T | null;
|
|
113
|
+
/**
|
|
114
|
+
* Set item in sessionStorage with JSON stringification
|
|
115
|
+
*/
|
|
116
|
+
set<T>(key: string, value: T): void;
|
|
117
|
+
/**
|
|
118
|
+
* Remove item from sessionStorage
|
|
119
|
+
*/
|
|
120
|
+
remove(key: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Clear all sessionStorage
|
|
123
|
+
*/
|
|
124
|
+
clear(): void;
|
|
185
125
|
};
|
|
186
|
-
|
|
187
|
-
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/string.d.ts
|
|
128
|
+
/**
|
|
129
|
+
* String utility functions
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* Truncate a string to a maximum length
|
|
133
|
+
*/
|
|
134
|
+
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Capitalize the first letter of a string
|
|
137
|
+
*/
|
|
138
|
+
declare function capitalize(str: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Convert string to kebab-case
|
|
141
|
+
*/
|
|
142
|
+
declare function toKebabCase(str: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* Convert string to camelCase
|
|
145
|
+
*/
|
|
146
|
+
declare function toCamelCase(str: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Convert string to snake_case
|
|
149
|
+
*/
|
|
150
|
+
declare function toSnakeCase(str: string): string;
|
|
151
|
+
/**
|
|
152
|
+
* Generate a random alphanumeric string
|
|
153
|
+
*/
|
|
154
|
+
declare function randomString(length: number): string;
|
|
155
|
+
/**
|
|
156
|
+
* Slugify a string for URLs
|
|
157
|
+
*/
|
|
158
|
+
declare function slugify(str: string): string;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/throttle.d.ts
|
|
161
|
+
/**
|
|
162
|
+
* Throttle utility
|
|
163
|
+
*/
|
|
164
|
+
declare function throttle<T extends (...args: unknown[]) => unknown>(func: T, limitMs: number): (...args: Parameters<T>) => void;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/url.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* URL utility functions
|
|
169
|
+
*/
|
|
170
|
+
/**
|
|
171
|
+
* Parse query parameters from URL
|
|
172
|
+
*/
|
|
173
|
+
declare function parseQueryParams(url: string): Record<string, string>;
|
|
174
|
+
/**
|
|
175
|
+
* Build query string from object
|
|
176
|
+
*/
|
|
177
|
+
declare function buildQueryString(params: Record<string, unknown>): string;
|
|
178
|
+
/**
|
|
179
|
+
* Get domain from URL
|
|
180
|
+
*/
|
|
181
|
+
declare function getDomain(url: string): string;
|
|
182
|
+
/**
|
|
183
|
+
* Get pathname from URL
|
|
184
|
+
*/
|
|
185
|
+
declare function getPathname(url: string): string;
|
|
186
|
+
/**
|
|
187
|
+
* Validate URL
|
|
188
|
+
*/
|
|
189
|
+
declare function isValidUrl(url: string): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Combine URL parts
|
|
192
|
+
*/
|
|
193
|
+
declare function combineUrl(base: string, ...paths: string[]): string;
|
|
194
|
+
//#endregion
|
|
195
|
+
export { RetryOptions, addDays, buildQueryString, capitalize, combineUrl, daysDifference, debounce, endOfDay, generateId, getDomain, getLastNDays, getPathname, hashString, isToday, isValidUrl, parseQueryParams, randomString, retry, sessionStorage, simpleHash, slugify, startOfDay, storage, throttle, toCamelCase, toDateString, toISOString, toKebabCase, toSnakeCase, truncate };
|
|
196
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/date.ts","../src/debounce.ts","../src/hash.ts","../src/retry.ts","../src/storage.ts","../src/string.ts","../src/throttle.ts","../src/url.ts"],"mappings":";;AAOA;;;;;iBAAgB,WAAA,CAAY,IAAA,EAAM,IAAA;;;;iBAOlB,YAAA,CAAa,IAAA,EAAM,IAAA;AAWnC;;;AAAA,iBAAgB,YAAA,CAAa,CAAA;EAAc,SAAA,EAAW,IAAA;EAAM,OAAA,EAAS,IAAA;AAAA;;;;iBAUrD,OAAA,CAAQ,IAAA,EAAM,IAAA;AAA9B;;;AAAA,iBASgB,OAAA,CAAQ,IAAA,EAAM,IAAA,EAAM,IAAA,WAAe,IAAA;;AAAnD;;iBASgB,UAAA,CAAW,IAAA,EAAM,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AuB,IAAA,wBAAA,CACrC,IAAA,EAAM,CAAA,EACN,OAAA,eACK,IAAA,EAAM,UAAA,CAAW,CAAA;;;;ANAxB;;;;;iBOAgB,gBAAA,CAAiB,GAAA,WAAc,MAAA;;;;iBAY/B,gBAAA,CAAiB,MAAA,EAAQ,MAAA;APMzC;;;AAAA,iBOsBgB,SAAA,CAAU,GAAA;;;;iBAYV,WAAA,CAAY,GAAA;;;;iBAYZ,UAAA,CAAW,GAAA;;;;iBAYX,UAAA,CAAW,IAAA,aAAiB,KAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* String utility functions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Truncate a string to a maximum length
|
|
6
|
-
*/
|
|
7
|
-
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Capitalize the first letter of a string
|
|
10
|
-
*/
|
|
11
|
-
declare function capitalize(str: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Convert string to kebab-case
|
|
14
|
-
*/
|
|
15
|
-
declare function toKebabCase(str: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Convert string to camelCase
|
|
18
|
-
*/
|
|
19
|
-
declare function toCamelCase(str: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Convert string to snake_case
|
|
22
|
-
*/
|
|
23
|
-
declare function toSnakeCase(str: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Generate a random alphanumeric string
|
|
26
|
-
*/
|
|
27
|
-
declare function randomString(length: number): string;
|
|
28
|
-
/**
|
|
29
|
-
* Slugify a string for URLs
|
|
30
|
-
*/
|
|
31
|
-
declare function slugify(str: string): string;
|
|
32
|
-
|
|
1
|
+
//#region src/date.d.ts
|
|
33
2
|
/**
|
|
34
3
|
* Date utility functions
|
|
35
4
|
*/
|
|
@@ -45,8 +14,8 @@ declare function toDateString(date: Date | string | number): string;
|
|
|
45
14
|
* Get date range for the last N days
|
|
46
15
|
*/
|
|
47
16
|
declare function getLastNDays(n: number): {
|
|
48
|
-
|
|
49
|
-
|
|
17
|
+
startDate: Date;
|
|
18
|
+
endDate: Date;
|
|
50
19
|
};
|
|
51
20
|
/**
|
|
52
21
|
* Check if a date is today
|
|
@@ -68,35 +37,14 @@ declare function endOfDay(date: Date): Date;
|
|
|
68
37
|
* Get difference in days between two dates
|
|
69
38
|
*/
|
|
70
39
|
declare function daysDifference(date1: Date, date2: Date): number;
|
|
71
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/debounce.d.ts
|
|
72
42
|
/**
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* Parse query parameters from URL
|
|
77
|
-
*/
|
|
78
|
-
declare function parseQueryParams(url: string): Record<string, string>;
|
|
79
|
-
/**
|
|
80
|
-
* Build query string from object
|
|
81
|
-
*/
|
|
82
|
-
declare function buildQueryString(params: Record<string, unknown>): string;
|
|
83
|
-
/**
|
|
84
|
-
* Get domain from URL
|
|
85
|
-
*/
|
|
86
|
-
declare function getDomain(url: string): string;
|
|
87
|
-
/**
|
|
88
|
-
* Get pathname from URL
|
|
89
|
-
*/
|
|
90
|
-
declare function getPathname(url: string): string;
|
|
91
|
-
/**
|
|
92
|
-
* Validate URL
|
|
93
|
-
*/
|
|
94
|
-
declare function isValidUrl(url: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Combine URL parts
|
|
43
|
+
* Debounce utility
|
|
97
44
|
*/
|
|
98
|
-
declare function
|
|
99
|
-
|
|
45
|
+
declare function debounce<T extends (...args: unknown[]) => unknown>(func: T, waitMs: number): (...args: Parameters<T>) => void;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/hash.d.ts
|
|
100
48
|
/**
|
|
101
49
|
* Hashing utility functions
|
|
102
50
|
*/
|
|
@@ -112,32 +60,24 @@ declare function hashString(str: string): string;
|
|
|
112
60
|
* Generate a deterministic ID from multiple values
|
|
113
61
|
*/
|
|
114
62
|
declare function generateId(...values: (string | number)[]): string;
|
|
115
|
-
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/retry.d.ts
|
|
116
65
|
/**
|
|
117
66
|
* Retry utility with exponential backoff
|
|
118
67
|
*/
|
|
119
68
|
interface RetryOptions {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
69
|
+
maxAttempts?: number;
|
|
70
|
+
delayMs?: number;
|
|
71
|
+
backoffMultiplier?: number;
|
|
72
|
+
maxDelayMs?: number;
|
|
73
|
+
onRetry?: (error: Error, attempt: number) => void;
|
|
125
74
|
}
|
|
126
75
|
/**
|
|
127
76
|
* Retry a function with exponential backoff
|
|
128
77
|
*/
|
|
129
78
|
declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
* Debounce utility
|
|
133
|
-
*/
|
|
134
|
-
declare function debounce<T extends (...args: any[]) => any>(func: T, waitMs: number): (...args: Parameters<T>) => void;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Throttle utility
|
|
138
|
-
*/
|
|
139
|
-
declare function throttle<T extends (...args: any[]) => any>(func: T, limitMs: number): (...args: Parameters<T>) => void;
|
|
140
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/storage.d.ts
|
|
141
81
|
/**
|
|
142
82
|
* Storage utility functions for browser localStorage/sessionStorage
|
|
143
83
|
*/
|
|
@@ -145,43 +85,112 @@ declare function throttle<T extends (...args: any[]) => any>(func: T, limitMs: n
|
|
|
145
85
|
* Safe localStorage wrapper
|
|
146
86
|
*/
|
|
147
87
|
declare const storage: {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Get item from localStorage with JSON parsing
|
|
90
|
+
*/
|
|
91
|
+
get<T>(key: string, defaultValue?: T): T | null;
|
|
92
|
+
/**
|
|
93
|
+
* Set item in localStorage with JSON stringification
|
|
94
|
+
*/
|
|
95
|
+
set<T>(key: string, value: T): void;
|
|
96
|
+
/**
|
|
97
|
+
* Remove item from localStorage
|
|
98
|
+
*/
|
|
99
|
+
remove(key: string): void;
|
|
100
|
+
/**
|
|
101
|
+
* Clear all localStorage
|
|
102
|
+
*/
|
|
103
|
+
clear(): void;
|
|
164
104
|
};
|
|
165
105
|
/**
|
|
166
106
|
* Safe sessionStorage wrapper
|
|
167
107
|
*/
|
|
168
108
|
declare const sessionStorage: {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Get item from sessionStorage with JSON parsing
|
|
111
|
+
*/
|
|
112
|
+
get<T>(key: string, defaultValue?: T): T | null;
|
|
113
|
+
/**
|
|
114
|
+
* Set item in sessionStorage with JSON stringification
|
|
115
|
+
*/
|
|
116
|
+
set<T>(key: string, value: T): void;
|
|
117
|
+
/**
|
|
118
|
+
* Remove item from sessionStorage
|
|
119
|
+
*/
|
|
120
|
+
remove(key: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Clear all sessionStorage
|
|
123
|
+
*/
|
|
124
|
+
clear(): void;
|
|
185
125
|
};
|
|
186
|
-
|
|
187
|
-
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/string.d.ts
|
|
128
|
+
/**
|
|
129
|
+
* String utility functions
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* Truncate a string to a maximum length
|
|
133
|
+
*/
|
|
134
|
+
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Capitalize the first letter of a string
|
|
137
|
+
*/
|
|
138
|
+
declare function capitalize(str: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Convert string to kebab-case
|
|
141
|
+
*/
|
|
142
|
+
declare function toKebabCase(str: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* Convert string to camelCase
|
|
145
|
+
*/
|
|
146
|
+
declare function toCamelCase(str: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Convert string to snake_case
|
|
149
|
+
*/
|
|
150
|
+
declare function toSnakeCase(str: string): string;
|
|
151
|
+
/**
|
|
152
|
+
* Generate a random alphanumeric string
|
|
153
|
+
*/
|
|
154
|
+
declare function randomString(length: number): string;
|
|
155
|
+
/**
|
|
156
|
+
* Slugify a string for URLs
|
|
157
|
+
*/
|
|
158
|
+
declare function slugify(str: string): string;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/throttle.d.ts
|
|
161
|
+
/**
|
|
162
|
+
* Throttle utility
|
|
163
|
+
*/
|
|
164
|
+
declare function throttle<T extends (...args: unknown[]) => unknown>(func: T, limitMs: number): (...args: Parameters<T>) => void;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/url.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* URL utility functions
|
|
169
|
+
*/
|
|
170
|
+
/**
|
|
171
|
+
* Parse query parameters from URL
|
|
172
|
+
*/
|
|
173
|
+
declare function parseQueryParams(url: string): Record<string, string>;
|
|
174
|
+
/**
|
|
175
|
+
* Build query string from object
|
|
176
|
+
*/
|
|
177
|
+
declare function buildQueryString(params: Record<string, unknown>): string;
|
|
178
|
+
/**
|
|
179
|
+
* Get domain from URL
|
|
180
|
+
*/
|
|
181
|
+
declare function getDomain(url: string): string;
|
|
182
|
+
/**
|
|
183
|
+
* Get pathname from URL
|
|
184
|
+
*/
|
|
185
|
+
declare function getPathname(url: string): string;
|
|
186
|
+
/**
|
|
187
|
+
* Validate URL
|
|
188
|
+
*/
|
|
189
|
+
declare function isValidUrl(url: string): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Combine URL parts
|
|
192
|
+
*/
|
|
193
|
+
declare function combineUrl(base: string, ...paths: string[]): string;
|
|
194
|
+
//#endregion
|
|
195
|
+
export { RetryOptions, addDays, buildQueryString, capitalize, combineUrl, daysDifference, debounce, endOfDay, generateId, getDomain, getLastNDays, getPathname, hashString, isToday, isValidUrl, parseQueryParams, randomString, retry, sessionStorage, simpleHash, slugify, startOfDay, storage, throttle, toCamelCase, toDateString, toISOString, toKebabCase, toSnakeCase, truncate };
|
|
196
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/date.ts","../src/debounce.ts","../src/hash.ts","../src/retry.ts","../src/storage.ts","../src/string.ts","../src/throttle.ts","../src/url.ts"],"mappings":";;AAOA;;;;;iBAAgB,WAAA,CAAY,IAAA,EAAM,IAAA;;;;iBAOlB,YAAA,CAAa,IAAA,EAAM,IAAA;AAWnC;;;AAAA,iBAAgB,YAAA,CAAa,CAAA;EAAc,SAAA,EAAW,IAAA;EAAM,OAAA,EAAS,IAAA;AAAA;;;;iBAUrD,OAAA,CAAQ,IAAA,EAAM,IAAA;AAA9B;;;AAAA,iBASgB,OAAA,CAAQ,IAAA,EAAM,IAAA,EAAM,IAAA,WAAe,IAAA;;AAAnD;;iBASgB,UAAA,CAAW,IAAA,EAAM,IAAA,GAAO,IAAA;;;;iBASxB,QAAA,CAAS,IAAA,EAAM,IAAA,GAAO,IAAA;;;;iBAStB,cAAA,CAAe,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,IAAA;;;;AAhEnD;;iBCHgB,QAAA,eAAuB,IAAA,wBAAA,CACrC,IAAA,EAAM,CAAA,EACN,MAAA,eACK,IAAA,EAAM,UAAA,CAAW,CAAA;;;;ADAxB;;;;;iBEAgB,UAAA,CAAW,GAAA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