@gzl10/ts-helpers 4.2.1
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/CHANGELOG.md +320 -0
- package/README.md +233 -0
- package/USAGE-GUIDE.md +800 -0
- package/dist/browser/async.js +15 -0
- package/dist/browser/async.js.map +1 -0
- package/dist/browser/chunk-4O7ZPIJN.js +383 -0
- package/dist/browser/chunk-4O7ZPIJN.js.map +1 -0
- package/dist/browser/chunk-75XNTC34.js +60 -0
- package/dist/browser/chunk-75XNTC34.js.map +1 -0
- package/dist/browser/chunk-C3D7YZVE.js +299 -0
- package/dist/browser/chunk-C3D7YZVE.js.map +1 -0
- package/dist/browser/chunk-CZL6C2EI.js +452 -0
- package/dist/browser/chunk-CZL6C2EI.js.map +1 -0
- package/dist/browser/chunk-D4FZFIVA.js +240 -0
- package/dist/browser/chunk-D4FZFIVA.js.map +1 -0
- package/dist/browser/chunk-IL7NG7IC.js +72 -0
- package/dist/browser/chunk-IL7NG7IC.js.map +1 -0
- package/dist/browser/chunk-NSBPE2FW.js +17 -0
- package/dist/browser/chunk-NSBPE2FW.js.map +1 -0
- package/dist/browser/chunk-SLQVNPTH.js +27 -0
- package/dist/browser/chunk-SLQVNPTH.js.map +1 -0
- package/dist/browser/chunk-WG7ILCUB.js +195 -0
- package/dist/browser/chunk-WG7ILCUB.js.map +1 -0
- package/dist/browser/chunk-WJA4JDMZ.js +278 -0
- package/dist/browser/chunk-WJA4JDMZ.js.map +1 -0
- package/dist/browser/chunk-ZFVYLUTT.js +65 -0
- package/dist/browser/chunk-ZFVYLUTT.js.map +1 -0
- package/dist/browser/chunk-ZYTSVMTI.js +263 -0
- package/dist/browser/chunk-ZYTSVMTI.js.map +1 -0
- package/dist/browser/dates.js +78 -0
- package/dist/browser/dates.js.map +1 -0
- package/dist/browser/environment-detection.js +21 -0
- package/dist/browser/environment-detection.js.map +1 -0
- package/dist/browser/environment.js +34 -0
- package/dist/browser/environment.js.map +1 -0
- package/dist/browser/errors.js +18 -0
- package/dist/browser/errors.js.map +1 -0
- package/dist/browser/index.js +412 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/math.js +51 -0
- package/dist/browser/math.js.map +1 -0
- package/dist/browser/number.js +10 -0
- package/dist/browser/number.js.map +1 -0
- package/dist/browser/objects.js +31 -0
- package/dist/browser/objects.js.map +1 -0
- package/dist/browser/strings.js +80 -0
- package/dist/browser/strings.js.map +1 -0
- package/dist/browser/validation-core.js +54 -0
- package/dist/browser/validation-core.js.map +1 -0
- package/dist/browser/validation-crypto.js +28 -0
- package/dist/browser/validation-crypto.js.map +1 -0
- package/dist/browser/validators.js +98 -0
- package/dist/browser/validators.js.map +1 -0
- package/dist/cjs/async.js +86 -0
- package/dist/cjs/async.js.map +1 -0
- package/dist/cjs/dates.js +285 -0
- package/dist/cjs/dates.js.map +1 -0
- package/dist/cjs/environment-detection.js +84 -0
- package/dist/cjs/environment-detection.js.map +1 -0
- package/dist/cjs/environment.js +261 -0
- package/dist/cjs/environment.js.map +1 -0
- package/dist/cjs/errors.js +80 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +2035 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/math.js +388 -0
- package/dist/cjs/math.js.map +1 -0
- package/dist/cjs/number.js +37 -0
- package/dist/cjs/number.js.map +1 -0
- package/dist/cjs/objects.js +249 -0
- package/dist/cjs/objects.js.map +1 -0
- package/dist/cjs/strings.js +253 -0
- package/dist/cjs/strings.js.map +1 -0
- package/dist/cjs/validation.js +450 -0
- package/dist/cjs/validation.js.map +1 -0
- package/dist/esm/async.js +15 -0
- package/dist/esm/async.js.map +1 -0
- package/dist/esm/chunk-4O7ZPIJN.js +383 -0
- package/dist/esm/chunk-4O7ZPIJN.js.map +1 -0
- package/dist/esm/chunk-75XNTC34.js +60 -0
- package/dist/esm/chunk-75XNTC34.js.map +1 -0
- package/dist/esm/chunk-BDOBKBKA.js +72 -0
- package/dist/esm/chunk-BDOBKBKA.js.map +1 -0
- package/dist/esm/chunk-C3D7YZVE.js +299 -0
- package/dist/esm/chunk-C3D7YZVE.js.map +1 -0
- package/dist/esm/chunk-CZL6C2EI.js +452 -0
- package/dist/esm/chunk-CZL6C2EI.js.map +1 -0
- package/dist/esm/chunk-EBLSTOEC.js +263 -0
- package/dist/esm/chunk-EBLSTOEC.js.map +1 -0
- package/dist/esm/chunk-NSBPE2FW.js +17 -0
- package/dist/esm/chunk-NSBPE2FW.js.map +1 -0
- package/dist/esm/chunk-SLQVNPTH.js +27 -0
- package/dist/esm/chunk-SLQVNPTH.js.map +1 -0
- package/dist/esm/chunk-WG7ILCUB.js +195 -0
- package/dist/esm/chunk-WG7ILCUB.js.map +1 -0
- package/dist/esm/chunk-WJA4JDMZ.js +278 -0
- package/dist/esm/chunk-WJA4JDMZ.js.map +1 -0
- package/dist/esm/chunk-ZFVYLUTT.js +65 -0
- package/dist/esm/chunk-ZFVYLUTT.js.map +1 -0
- package/dist/esm/dates.js +78 -0
- package/dist/esm/dates.js.map +1 -0
- package/dist/esm/environment-detection.js +21 -0
- package/dist/esm/environment-detection.js.map +1 -0
- package/dist/esm/environment.js +34 -0
- package/dist/esm/environment.js.map +1 -0
- package/dist/esm/errors.js +18 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +380 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/math.js +51 -0
- package/dist/esm/math.js.map +1 -0
- package/dist/esm/number.js +10 -0
- package/dist/esm/number.js.map +1 -0
- package/dist/esm/objects.js +31 -0
- package/dist/esm/objects.js.map +1 -0
- package/dist/esm/strings.js +80 -0
- package/dist/esm/strings.js.map +1 -0
- package/dist/esm/validation.js +54 -0
- package/dist/esm/validation.js.map +1 -0
- package/dist/node/async.js +93 -0
- package/dist/node/async.js.map +1 -0
- package/dist/node/csv.js +102 -0
- package/dist/node/csv.js.map +1 -0
- package/dist/node/data.js +880 -0
- package/dist/node/data.js.map +1 -0
- package/dist/node/dates.js +324 -0
- package/dist/node/dates.js.map +1 -0
- package/dist/node/environment.js +278 -0
- package/dist/node/environment.js.map +1 -0
- package/dist/node/errors.js +89 -0
- package/dist/node/errors.js.map +1 -0
- package/dist/node/index.js +3151 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/json.js +107 -0
- package/dist/node/json.js.map +1 -0
- package/dist/node/math.js +413 -0
- package/dist/node/math.js.map +1 -0
- package/dist/node/number.js +42 -0
- package/dist/node/number.js.map +1 -0
- package/dist/node/objects.js +264 -0
- package/dist/node/objects.js.map +1 -0
- package/dist/node/strings.js +293 -0
- package/dist/node/strings.js.map +1 -0
- package/dist/node/tree.js +89 -0
- package/dist/node/tree.js.map +1 -0
- package/dist/node/validation-core.js +477 -0
- package/dist/node/validation-core.js.map +1 -0
- package/dist/node/validation-crypto.js +179 -0
- package/dist/node/validation-crypto.js.map +1 -0
- package/dist/node/validation.js +677 -0
- package/dist/node/validation.js.map +1 -0
- package/dist/node/validators.js +123 -0
- package/dist/node/validators.js.map +1 -0
- package/dist/node-esm/async.js +15 -0
- package/dist/node-esm/async.js.map +1 -0
- package/dist/node-esm/chunk-3YOF7NPT.js +299 -0
- package/dist/node-esm/chunk-3YOF7NPT.js.map +1 -0
- package/dist/node-esm/chunk-64TBXJQS.js +263 -0
- package/dist/node-esm/chunk-64TBXJQS.js.map +1 -0
- package/dist/node-esm/chunk-75XNTC34.js +60 -0
- package/dist/node-esm/chunk-75XNTC34.js.map +1 -0
- package/dist/node-esm/chunk-C4PKXIPB.js +278 -0
- package/dist/node-esm/chunk-C4PKXIPB.js.map +1 -0
- package/dist/node-esm/chunk-CMDFZME3.js +452 -0
- package/dist/node-esm/chunk-CMDFZME3.js.map +1 -0
- package/dist/node-esm/chunk-DZZPUYMP.js +74 -0
- package/dist/node-esm/chunk-DZZPUYMP.js.map +1 -0
- package/dist/node-esm/chunk-HTSEHRHI.js +195 -0
- package/dist/node-esm/chunk-HTSEHRHI.js.map +1 -0
- package/dist/node-esm/chunk-JCAUVOPH.js +27 -0
- package/dist/node-esm/chunk-JCAUVOPH.js.map +1 -0
- package/dist/node-esm/chunk-KBHE3K2F.js +505 -0
- package/dist/node-esm/chunk-KBHE3K2F.js.map +1 -0
- package/dist/node-esm/chunk-LYTET5NX.js +65 -0
- package/dist/node-esm/chunk-LYTET5NX.js.map +1 -0
- package/dist/node-esm/chunk-PZ5AY32C.js +10 -0
- package/dist/node-esm/chunk-PZ5AY32C.js.map +1 -0
- package/dist/node-esm/chunk-UKGXL2QO.js +383 -0
- package/dist/node-esm/chunk-UKGXL2QO.js.map +1 -0
- package/dist/node-esm/chunk-XAEYT23H.js +164 -0
- package/dist/node-esm/chunk-XAEYT23H.js.map +1 -0
- package/dist/node-esm/csv.js +63 -0
- package/dist/node-esm/csv.js.map +1 -0
- package/dist/node-esm/data.js +32 -0
- package/dist/node-esm/data.js.map +1 -0
- package/dist/node-esm/dates.js +78 -0
- package/dist/node-esm/dates.js.map +1 -0
- package/dist/node-esm/environment.js +34 -0
- package/dist/node-esm/environment.js.map +1 -0
- package/dist/node-esm/errors.js +18 -0
- package/dist/node-esm/errors.js.map +1 -0
- package/dist/node-esm/index.js +426 -0
- package/dist/node-esm/index.js.map +1 -0
- package/dist/node-esm/json.js +68 -0
- package/dist/node-esm/json.js.map +1 -0
- package/dist/node-esm/math.js +51 -0
- package/dist/node-esm/math.js.map +1 -0
- package/dist/node-esm/number.js +10 -0
- package/dist/node-esm/number.js.map +1 -0
- package/dist/node-esm/objects.js +31 -0
- package/dist/node-esm/objects.js.map +1 -0
- package/dist/node-esm/strings.js +80 -0
- package/dist/node-esm/strings.js.map +1 -0
- package/dist/node-esm/tree.js +8 -0
- package/dist/node-esm/tree.js.map +1 -0
- package/dist/node-esm/validation-core.js +54 -0
- package/dist/node-esm/validation-core.js.map +1 -0
- package/dist/node-esm/validation-crypto.js +26 -0
- package/dist/node-esm/validation-crypto.js.map +1 -0
- package/dist/node-esm/validation.js +606 -0
- package/dist/node-esm/validation.js.map +1 -0
- package/dist/node-esm/validators.js +98 -0
- package/dist/node-esm/validators.js.map +1 -0
- package/dist/types/async-C8gvbSG-.d.ts +453 -0
- package/dist/types/async.d.ts +1 -0
- package/dist/types/csv.d.ts +226 -0
- package/dist/types/data.d.ts +1561 -0
- package/dist/types/dates-hTiE0Z11.d.ts +298 -0
- package/dist/types/dates.d.ts +1 -0
- package/dist/types/environment-B8eLS7KT.d.ts +420 -0
- package/dist/types/environment-detection.d.ts +102 -0
- package/dist/types/environment.d.ts +1 -0
- package/dist/types/errors.d.ts +147 -0
- package/dist/types/index.d.ts +211 -0
- package/dist/types/json.d.ts +284 -0
- package/dist/types/math-BQ9Lwdp7.d.ts +2060 -0
- package/dist/types/math.d.ts +1 -0
- package/dist/types/number-CYnQfLWj.d.ts +44 -0
- package/dist/types/number.d.ts +1 -0
- package/dist/types/objects-BohS8GCS.d.ts +1185 -0
- package/dist/types/objects.d.ts +1 -0
- package/dist/types/strings-CiqRPYLL.d.ts +1349 -0
- package/dist/types/strings.d.ts +1 -0
- package/dist/types/tree.d.ts +284 -0
- package/dist/types/validation-core-DfHF8rCG.d.ts +238 -0
- package/dist/types/validation-crypto-browser.d.ts +56 -0
- package/dist/types/validation-crypto-node.d.ts +31 -0
- package/dist/types/validation.d.ts +1 -0
- package/dist/types/validators.d.ts +216 -0
- package/package.json +253 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/async.ts"],"sourcesContent":["/**\n * Asynchronous utilities and operations\n * Consolidated from core/async module\n */\n\n/* eslint-disable no-await-in-loop */\n\nimport { TsHelpersError, TsHelpersErrorCode } from './errors'\n\n// =============================================================================\n// DELAY UTILITIES\n// =============================================================================\n\n/**\n * Creates an asynchronous delay for the specified number of milliseconds\n *\n * Pauses async execution without blocking the event loop. Uses Promise with setTimeout\n * internally to schedule resumption after the specified delay.\n *\n * Common use cases:\n * - Rate limiting API calls\n * - Retry delays with exponential backoff\n * - Animation/transition timing\n * - Polling intervals\n * - Debouncing operations\n *\n * @param ms - Milliseconds to sleep (delay duration)\n * @returns Promise that resolves after the specified delay\n *\n * @example\n * ```typescript\n * // Basic delay\n * console.log('Starting...')\n * await sleep(2000) // Wait 2 seconds\n * console.log('Done!')\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Rate-limited API calls\n * async function fetchAllUsers(userIds: string[]): Promise<User[]> {\n * const users: User[] = []\n *\n * for (const id of userIds) {\n * const user = await api.getUser(id)\n * users.push(user)\n *\n * // Rate limit: 100ms between requests (max 10 req/sec)\n * await sleep(100)\n * }\n *\n * return users\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Exponential backoff retry\n * async function fetchWithRetry(url: string, maxRetries = 3): Promise<Response> {\n * let lastError: Error | null = null\n *\n * for (let attempt = 0; attempt < maxRetries; attempt++) {\n * try {\n * return await fetch(url)\n * } catch (error) {\n * lastError = error as Error\n * const delay = Math.pow(2, attempt) * 1000 // 1s, 2s, 4s\n * console.log(`Retry ${attempt + 1}/${maxRetries} in ${delay}ms`)\n * await sleep(delay)\n * }\n * }\n *\n * throw lastError\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Polling with timeout\n * async function pollUntilReady(\n * checkFn: () => Promise<boolean>,\n * timeoutMs = 30000\n * ): Promise<boolean> {\n * const startTime = Date.now()\n *\n * while (Date.now() - startTime < timeoutMs) {\n * if (await checkFn()) {\n * return true\n * }\n * await sleep(1000) // Poll every second\n * }\n *\n * throw new Error('Timeout waiting for ready state')\n * }\n *\n * // Usage: Wait for service to be ready\n * await pollUntilReady(async () => {\n * const response = await fetch('/health')\n * return response.ok\n * })\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Animated progress bar\n * async function animateProgress(element: HTMLElement): Promise<void> {\n * for (let i = 0; i <= 100; i += 5) {\n * element.style.width = `${i}%`\n * await sleep(50) // 50ms per step = 1 second total\n * }\n * }\n * ```\n *\n * @see {@link wait} for alias with same functionality\n * @see {@link runBatch} for controlled concurrent execution\n */\nexport const sleep = (ms: number): Promise<void> => {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n/**\n * Simple alias for sleep - Pauses execution for specified milliseconds\n *\n * Identical to {@link sleep}, provided for semantic clarity in code.\n * Use `wait` when the context emphasizes waiting for a condition or event.\n *\n * @param ms - Milliseconds to wait\n * @returns Promise that resolves after the specified delay\n *\n * @example\n * ```typescript\n * // Semantically clearer in some contexts\n * await wait(1000) // Wait 1 second before continuing\n *\n * // vs sleep (implies intentional delay)\n * await sleep(1000) // Sleep for 1 second\n * ```\n *\n * @see {@link sleep} for full documentation and examples\n */\nexport const wait = (ms: number): Promise<void> => sleep(ms)\n\n// =============================================================================\n// BATCH PROCESSING\n// =============================================================================\n\n/**\n * Executes an array of Promises in batches to control concurrency\n *\n * Processes promises in sequential batches, waiting for each batch to complete before\n * starting the next. Prevents overwhelming systems with too many concurrent requests.\n *\n * Algorithm:\n * 1. Divide promises into batches of size `batchSize`\n * 2. Execute each batch with Promise.all (parallel within batch)\n * 3. Wait for batch completion before starting next batch\n * 4. Collect and return all results in original order\n *\n * Use cases:\n * - Rate-limited API calls (respect API quotas)\n * - Database bulk operations (avoid connection pool exhaustion)\n * - File system operations (prevent file descriptor limits)\n * - Memory-intensive operations (control memory usage)\n *\n * @param jobs - Array of Promises to execute\n * @param batchSize - Number of promises to execute concurrently per batch (default: 50)\n * @returns Promise resolving to array of all results in original order\n *\n * @example\n * ```typescript\n * // Basic batch processing\n * const urls = ['url1', 'url2', ..., 'url100'] // 100 URLs\n * const fetchPromises = urls.map(url => fetch(url))\n *\n * // Execute 10 at a time instead of all 100 simultaneously\n * const responses = await runBatch(fetchPromises, 10)\n * // Batch 1: urls 0-9 (parallel)\n * // Batch 2: urls 10-19 (parallel) - starts after batch 1 completes\n * // ... 10 batches total\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Bulk user data fetch respecting API rate limits\n * async function fetchUsersInBatches(userIds: string[]): Promise<User[]> {\n * console.log(`Fetching ${userIds.length} users in batches of 20...`)\n *\n * const fetchPromises = userIds.map(id =>\n * fetch(`/api/users/${id}`).then(res => res.json())\n * )\n *\n * const users = await runBatch(fetchPromises, 20)\n *\n * console.log(`✅ Fetched ${users.length} users`)\n * return users\n * }\n *\n * // Fetches 1000 users: 50 batches of 20, not 1000 simultaneous requests\n * const allUsers = await fetchUsersInBatches(userIdArray)\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Database bulk insert with connection pool limits\n * async function bulkInsertUsers(users: User[]): Promise<void> {\n * // Database pool has 10 connections, use batch size of 5 for safety\n * const insertPromises = users.map(user =>\n * db.query('INSERT INTO users VALUES ($1, $2)', [user.name, user.email])\n * )\n *\n * await runBatch(insertPromises, 5)\n * console.log(`✅ Inserted ${users.length} users`)\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Image processing pipeline\n * async function processImages(imagePaths: string[]): Promise<Buffer[]> {\n * console.log(`Processing ${imagePaths.length} images...`)\n *\n * const processingPromises = imagePaths.map(async path => {\n * const img = await loadImage(path)\n * const resized = await resize(img, { width: 800, height: 600 })\n * const compressed = await compress(resized, { quality: 80 })\n * return compressed\n * })\n *\n * // Process 3 images at a time to avoid memory exhaustion\n * const processed = await runBatch(processingPromises, 3)\n *\n * console.log(`✅ Processed ${processed.length} images`)\n * return processed\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Parallel file uploads with progress tracking\n * async function uploadFilesWithProgress(\n * files: File[]\n * ): Promise<UploadResult[]> {\n * let completed = 0\n *\n * const uploadPromises = files.map(async file => {\n * const result = await uploadToS3(file)\n * completed++\n * console.log(`Progress: ${completed}/${files.length} (${((completed/files.length)*100).toFixed(1)}%)`)\n * return result\n * })\n *\n * // Upload 5 files at a time\n * return await runBatch(uploadPromises, 5)\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Scraping with politeness delay\n * async function scrapeWebsites(urls: string[]): Promise<ScrapedData[]> {\n * const scrapePromises = urls.map(async url => {\n * const html = await fetch(url).then(r => r.text())\n * const data = parseHTML(html)\n *\n * // Polite delay between requests in same batch\n * await sleep(200)\n *\n * return data\n * })\n *\n * // Only 3 concurrent requests to avoid overwhelming target server\n * return await runBatch(scrapePromises, 3)\n * }\n * ```\n *\n * @see {@link sleep} for adding delays between operations\n * @see {@link handleOperation} for dynamic operation execution\n */\nexport async function runBatch<T>(jobs: Promise<T>[], batchSize: number = 50): Promise<T[]> {\n if (batchSize <= 0) {\n throw new TsHelpersError('Batch size must be greater than 0', {\n code: TsHelpersErrorCode.INVALID_OPERATION,\n data: { batchSize },\n })\n }\n\n const results: T[] = []\n const batches = Math.ceil(jobs.length / batchSize)\n\n for (let i = 0; i < batches; i++) {\n const batchStart = i * batchSize\n const batchEnd = batchStart + batchSize\n const batch = jobs.slice(batchStart, batchEnd)\n\n const batchResults = await Promise.all(batch.map(job => job))\n results.push(...batchResults)\n }\n\n return results\n}\n\n// =============================================================================\n// DYNAMIC OPERATION UTILITIES\n// =============================================================================\n\n/**\n * Dynamically executes an operation on a target object by name\n *\n * Invokes methods on objects using string-based operation names. Supports nested\n * method access using 'parent/child' slash notation for organized operation namespacing.\n *\n * Features:\n * - Dynamic method invocation by string name\n * - Nested method access with '/' separator (e.g., 'api/getUser')\n * - Automatic error handling with descriptive messages\n * - Type-safe return value with generics\n *\n * Use cases:\n * - Dynamic API route handlers\n * - Plugin architectures with string-based commands\n * - RPC (Remote Procedure Call) implementations\n * - Command pattern implementations\n * - Configuration-driven operations\n *\n * @param target - Object containing methods to execute\n * @param operation - Method name or 'parent/child' path to execute\n * @param args - Arguments to pass to the operation\n * @returns Promise resolving to operation result\n * @throws {TsHelpersError} If operation doesn't exist on target\n *\n * @example\n * ```typescript\n * // Basic operation execution\n * const api = {\n * getUser: async (id: string) => ({ id, name: 'John' }),\n * createUser: async (data: any) => ({ id: '123', ...data })\n * }\n *\n * const user = await handleOperation<User>(api, 'getUser', 'user-123')\n * // { id: 'user-123', name: 'John' }\n * ```\n *\n * @example\n * ```typescript\n * // Nested operations with slash notation\n * const service = {\n * users: {\n * list: async () => [{ id: '1' }, { id: '2' }],\n * create: async (data: any) => ({ id: 'new', ...data }),\n * delete: async (id: string) => ({ success: true })\n * },\n * posts: {\n * list: async () => [{ id: 'post-1' }],\n * create: async (data: any) => ({ id: 'new-post', ...data })\n * }\n * }\n *\n * // Execute nested operation\n * const users = await handleOperation(service, 'users/list')\n * const newUser = await handleOperation(service, 'users/create', { name: 'Alice' })\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Dynamic API router\n * interface ApiRequest {\n * operation: string\n * params: any[]\n * }\n *\n * const apiHandlers = {\n * user: {\n * get: async (id: string) => db.users.findById(id),\n * create: async (data: UserInput) => db.users.create(data),\n * update: async (id: string, data: Partial<UserInput>) =>\n * db.users.update(id, data),\n * delete: async (id: string) => db.users.delete(id)\n * },\n * product: {\n * search: async (query: string) => db.products.search(query),\n * list: async (page: number) => db.products.list(page)\n * }\n * }\n *\n * async function handleApiRequest(req: ApiRequest): Promise<any> {\n * try {\n * return await handleOperation(\n * apiHandlers,\n * req.operation,\n * ...req.params\n * )\n * } catch (error) {\n * console.error(`Failed to execute ${req.operation}:`, error)\n * throw error\n * }\n * }\n *\n * // Usage\n * await handleApiRequest({ operation: 'user/get', params: ['user-123'] })\n * await handleApiRequest({ operation: 'product/search', params: ['laptop'] })\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: Plugin system with dynamic commands\n * interface Plugin {\n * name: string\n * commands: Record<string, (...args: any[]) => Promise<any>>\n * }\n *\n * class PluginManager {\n * private plugins: Map<string, Plugin> = new Map()\n *\n * register(plugin: Plugin): void {\n * this.plugins.set(plugin.name, plugin)\n * }\n *\n * async executeCommand(\n * pluginName: string,\n * command: string,\n * ...args: any[]\n * ): Promise<any> {\n * const plugin = this.plugins.get(pluginName)\n * if (!plugin) throw new Error(`Plugin ${pluginName} not found`)\n *\n * return handleOperation(plugin.commands, command, ...args)\n * }\n * }\n *\n * // Register plugins\n * const manager = new PluginManager()\n * manager.register({\n * name: 'fileOps',\n * commands: {\n * read: async (path: string) => fs.readFile(path, 'utf-8'),\n * write: async (path: string, content: string) =>\n * fs.writeFile(path, content)\n * }\n * })\n *\n * // Execute plugin commands dynamically\n * await manager.executeCommand('fileOps', 'read', './config.json')\n * ```\n *\n * @example\n * ```typescript\n * // Real-world: RPC-style service calls\n * const rpcService = {\n * math: {\n * add: async (a: number, b: number) => a + b,\n * multiply: async (a: number, b: number) => a * b\n * },\n * string: {\n * reverse: async (s: string) => s.split('').reverse().join(''),\n * uppercase: async (s: string) => s.toUpperCase()\n * }\n * }\n *\n * async function rpcCall(method: string, ...params: any[]): Promise<any> {\n * console.log(`RPC Call: ${method}(${params.join(', ')})`)\n * const result = await handleOperation(rpcService, method, ...params)\n * console.log(`RPC Result: ${result}`)\n * return result\n * }\n *\n * await rpcCall('math/add', 5, 3) // RPC Result: 8\n * await rpcCall('string/reverse', 'hello') // RPC Result: olleh\n * ```\n *\n * @example\n * ```typescript\n * // Error handling\n * try {\n * await handleOperation(api, 'nonexistent/method')\n * } catch (error) {\n * console.error(error.message)\n * // \"Operation [nonexistent/method] does not exist\"\n * console.error(error.code)\n * // TsHelpersErrorCode.INVALID_OPERATION\n * }\n * ```\n *\n * @see {@link TsHelpersError} for error structure\n * @see {@link TsHelpersErrorCode} for error codes\n */\nexport function handleOperation<T>(\n target: Record<string, any>,\n operation: string,\n ...args: any[]\n): Promise<T> {\n if (operation.includes('/')) {\n const [parentOp, childOp] = operation.split('/')\n\n if (!target[parentOp] || !target[parentOp][childOp]) {\n throw new TsHelpersError(`Operation [${operation}] does not exist`, {\n code: TsHelpersErrorCode.INVALID_OPERATION,\n data: { operation, parentOp, childOp },\n })\n }\n\n return target[parentOp][childOp](...args)\n }\n\n if (!target[operation]) {\n throw new TsHelpersError(`Operation [${operation}] does not exist`, {\n code: TsHelpersErrorCode.INVALID_OPERATION,\n data: { operation },\n })\n }\n\n return target[operation](...args)\n}\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoHO,IAAM,QAAQ,CAAC,OAA8B;AAClD,SAAO,IAAI,QAAQ,aAAW,WAAW,SAAS,EAAE,CAAC;AACvD;AAsBO,IAAM,OAAO,CAAC,OAA8B,MAAM,EAAE;AA0I3D,eAAsB,SAAY,MAAoB,YAAoB,IAAkB;AAC1F,MAAI,aAAa,GAAG;AAClB,UAAM,IAAI,eAAe,qCAAqC;AAAA,MAC5D;AAAA,MACA,MAAM,EAAE,UAAU;AAAA,IACpB,CAAC;AAAA,EACH;AAEA,QAAM,UAAe,CAAC;AACtB,QAAM,UAAU,KAAK,KAAK,KAAK,SAAS,SAAS;AAEjD,WAAS,IAAI,GAAG,IAAI,SAAS,KAAK;AAChC,UAAM,aAAa,IAAI;AACvB,UAAM,WAAW,aAAa;AAC9B,UAAM,QAAQ,KAAK,MAAM,YAAY,QAAQ;AAE7C,UAAM,eAAe,MAAM,QAAQ,IAAI,MAAM,IAAI,SAAO,GAAG,CAAC;AAC5D,YAAQ,KAAK,GAAG,YAAY;AAAA,EAC9B;AAEA,SAAO;AACT;AA0LO,SAAS,gBACd,QACA,cACG,MACS;AACZ,MAAI,UAAU,SAAS,GAAG,GAAG;AAC3B,UAAM,CAAC,UAAU,OAAO,IAAI,UAAU,MAAM,GAAG;AAE/C,QAAI,CAAC,OAAO,QAAQ,KAAK,CAAC,OAAO,QAAQ,EAAE,OAAO,GAAG;AACnD,YAAM,IAAI,eAAe,cAAc,SAAS,oBAAoB;AAAA,QAClE;AAAA,QACA,MAAM,EAAE,WAAW,UAAU,QAAQ;AAAA,MACvC,CAAC;AAAA,IACH;AAEA,WAAO,OAAO,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;AAAA,EAC1C;AAEA,MAAI,CAAC,OAAO,SAAS,GAAG;AACtB,UAAM,IAAI,eAAe,cAAc,SAAS,oBAAoB;AAAA,MAClE;AAAA,MACA,MAAM,EAAE,UAAU;AAAA,IACpB,CAAC;AAAA,EACH;AAEA,SAAO,OAAO,SAAS,EAAE,GAAG,IAAI;AAClC;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addDays,
|
|
3
|
+
addMonths,
|
|
4
|
+
addNowDays,
|
|
5
|
+
addNowMonths,
|
|
6
|
+
addNowSeconds,
|
|
7
|
+
addNowYears,
|
|
8
|
+
addSeconds,
|
|
9
|
+
addYears,
|
|
10
|
+
areDatesEqualWithTolerance,
|
|
11
|
+
dayOfWeek,
|
|
12
|
+
diffBusinessDays,
|
|
13
|
+
diffDays,
|
|
14
|
+
diffMilliSeconds,
|
|
15
|
+
diffMonths,
|
|
16
|
+
diffYears,
|
|
17
|
+
excelToDate,
|
|
18
|
+
format,
|
|
19
|
+
formatForMysql,
|
|
20
|
+
formatNow,
|
|
21
|
+
fromNow,
|
|
22
|
+
getFirstDayOfYear,
|
|
23
|
+
getFirstWorkdayAfterMonths,
|
|
24
|
+
getFirstWorkdayOfMonth,
|
|
25
|
+
getLastDayOfYear,
|
|
26
|
+
getLastWorkdayOfMonth,
|
|
27
|
+
isDateTime,
|
|
28
|
+
isEqualsDateTimeByDay,
|
|
29
|
+
isExpired,
|
|
30
|
+
isNew,
|
|
31
|
+
isWeekday,
|
|
32
|
+
longString,
|
|
33
|
+
now,
|
|
34
|
+
toDate,
|
|
35
|
+
toDateFromString,
|
|
36
|
+
toISO,
|
|
37
|
+
weekOfYear
|
|
38
|
+
} from "./chunk-C3D7YZVE.js";
|
|
39
|
+
import "./chunk-NSBPE2FW.js";
|
|
40
|
+
export {
|
|
41
|
+
addDays,
|
|
42
|
+
addMonths,
|
|
43
|
+
addNowDays,
|
|
44
|
+
addNowMonths,
|
|
45
|
+
addNowSeconds,
|
|
46
|
+
addNowYears,
|
|
47
|
+
addSeconds,
|
|
48
|
+
addYears,
|
|
49
|
+
areDatesEqualWithTolerance,
|
|
50
|
+
dayOfWeek,
|
|
51
|
+
diffBusinessDays,
|
|
52
|
+
diffDays,
|
|
53
|
+
diffMilliSeconds,
|
|
54
|
+
diffMonths,
|
|
55
|
+
diffYears,
|
|
56
|
+
excelToDate,
|
|
57
|
+
format,
|
|
58
|
+
formatForMysql,
|
|
59
|
+
formatNow,
|
|
60
|
+
fromNow,
|
|
61
|
+
getFirstDayOfYear,
|
|
62
|
+
getFirstWorkdayAfterMonths,
|
|
63
|
+
getFirstWorkdayOfMonth,
|
|
64
|
+
getLastDayOfYear,
|
|
65
|
+
getLastWorkdayOfMonth,
|
|
66
|
+
isDateTime,
|
|
67
|
+
isEqualsDateTimeByDay,
|
|
68
|
+
isExpired,
|
|
69
|
+
isNew,
|
|
70
|
+
isWeekday,
|
|
71
|
+
longString,
|
|
72
|
+
now,
|
|
73
|
+
toDate,
|
|
74
|
+
toDateFromString,
|
|
75
|
+
toISO,
|
|
76
|
+
weekOfYear
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCryptoCapabilities,
|
|
3
|
+
getEnvironmentType,
|
|
4
|
+
isBrowserEnv,
|
|
5
|
+
isNodeCryptoAvailable,
|
|
6
|
+
isNodeEnv,
|
|
7
|
+
isWebCryptoAvailable,
|
|
8
|
+
isWorkerEnvironment
|
|
9
|
+
} from "./chunk-BDOBKBKA.js";
|
|
10
|
+
import "./chunk-EBLSTOEC.js";
|
|
11
|
+
import "./chunk-NSBPE2FW.js";
|
|
12
|
+
export {
|
|
13
|
+
getCryptoCapabilities,
|
|
14
|
+
getEnvironmentType,
|
|
15
|
+
isBrowserEnv,
|
|
16
|
+
isNodeCryptoAvailable,
|
|
17
|
+
isNodeEnv,
|
|
18
|
+
isWebCryptoAvailable,
|
|
19
|
+
isWorkerEnvironment
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=environment-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
detectHostname,
|
|
3
|
+
detectProtocol,
|
|
4
|
+
getEnvironmentInfo,
|
|
5
|
+
isBrowser,
|
|
6
|
+
isBrowserEnvironment,
|
|
7
|
+
isDevelopment,
|
|
8
|
+
isLocalhost,
|
|
9
|
+
isNode,
|
|
10
|
+
isNodeEnvironment,
|
|
11
|
+
isNonProduction,
|
|
12
|
+
isPrivateIP,
|
|
13
|
+
isProduction,
|
|
14
|
+
isTest,
|
|
15
|
+
parseEnvValue
|
|
16
|
+
} from "./chunk-EBLSTOEC.js";
|
|
17
|
+
import "./chunk-NSBPE2FW.js";
|
|
18
|
+
export {
|
|
19
|
+
detectHostname,
|
|
20
|
+
detectProtocol,
|
|
21
|
+
getEnvironmentInfo,
|
|
22
|
+
isBrowser,
|
|
23
|
+
isBrowserEnvironment,
|
|
24
|
+
isDevelopment,
|
|
25
|
+
isLocalhost,
|
|
26
|
+
isNode,
|
|
27
|
+
isNodeEnvironment,
|
|
28
|
+
isNonProduction,
|
|
29
|
+
isPrivateIP,
|
|
30
|
+
isProduction,
|
|
31
|
+
isTest,
|
|
32
|
+
parseEnvValue
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataError,
|
|
3
|
+
TsHelpersError,
|
|
4
|
+
TsHelpersErrorCode,
|
|
5
|
+
createCryptoError,
|
|
6
|
+
createMathError,
|
|
7
|
+
createValidationError
|
|
8
|
+
} from "./chunk-75XNTC34.js";
|
|
9
|
+
import "./chunk-NSBPE2FW.js";
|
|
10
|
+
export {
|
|
11
|
+
DataError,
|
|
12
|
+
TsHelpersError,
|
|
13
|
+
TsHelpersErrorCode,
|
|
14
|
+
createCryptoError,
|
|
15
|
+
createMathError,
|
|
16
|
+
createValidationError
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateAlphaNumericString,
|
|
3
|
+
generateAlphaString,
|
|
4
|
+
generateComplexString,
|
|
5
|
+
generateEmail,
|
|
6
|
+
generateHexColor,
|
|
7
|
+
generatePassword,
|
|
8
|
+
generateRandomInteger,
|
|
9
|
+
generateSpanishCIF,
|
|
10
|
+
generateSpanishIBAN,
|
|
11
|
+
generateSpanishNIE,
|
|
12
|
+
generateSpanishNIF,
|
|
13
|
+
generateSpanishPostalCode,
|
|
14
|
+
generateUsername,
|
|
15
|
+
generateUsernameFromEmail,
|
|
16
|
+
isValidCIF,
|
|
17
|
+
isValidEmail,
|
|
18
|
+
isValidJSON,
|
|
19
|
+
isValidNIE,
|
|
20
|
+
isValidNIF,
|
|
21
|
+
isValidSpanishIBAN,
|
|
22
|
+
isValidSpanishPhone,
|
|
23
|
+
isValidSpanishPostalCode,
|
|
24
|
+
isValidURL,
|
|
25
|
+
validateNIF,
|
|
26
|
+
validation_core_exports
|
|
27
|
+
} from "./chunk-CZL6C2EI.js";
|
|
28
|
+
import {
|
|
29
|
+
environment_detection_exports,
|
|
30
|
+
getCryptoCapabilities,
|
|
31
|
+
getEnvironmentType,
|
|
32
|
+
isBrowserEnv,
|
|
33
|
+
isNodeCryptoAvailable,
|
|
34
|
+
isNodeEnv,
|
|
35
|
+
isWebCryptoAvailable,
|
|
36
|
+
isWorkerEnvironment
|
|
37
|
+
} from "./chunk-BDOBKBKA.js";
|
|
38
|
+
import {
|
|
39
|
+
detectHostname,
|
|
40
|
+
detectProtocol,
|
|
41
|
+
environment_exports,
|
|
42
|
+
getEnvironmentInfo,
|
|
43
|
+
isBrowser,
|
|
44
|
+
isBrowserEnvironment,
|
|
45
|
+
isDevelopment,
|
|
46
|
+
isLocalhost,
|
|
47
|
+
isNode,
|
|
48
|
+
isNodeEnvironment,
|
|
49
|
+
isNonProduction,
|
|
50
|
+
isPrivateIP,
|
|
51
|
+
isProduction,
|
|
52
|
+
isTest,
|
|
53
|
+
parseEnvValue
|
|
54
|
+
} from "./chunk-EBLSTOEC.js";
|
|
55
|
+
import {
|
|
56
|
+
capitalizeEachWord,
|
|
57
|
+
capitalizeFirst,
|
|
58
|
+
cleanJsonChars,
|
|
59
|
+
contains,
|
|
60
|
+
countOccurrences,
|
|
61
|
+
endsWith,
|
|
62
|
+
ensureEndsWith,
|
|
63
|
+
ensureStartsWith,
|
|
64
|
+
envKeyToPath,
|
|
65
|
+
escapeHtmlChars,
|
|
66
|
+
isEmail,
|
|
67
|
+
isEmpty,
|
|
68
|
+
matchPathPattern,
|
|
69
|
+
padEnd,
|
|
70
|
+
padStart,
|
|
71
|
+
pathToEnvKey,
|
|
72
|
+
removeAccents,
|
|
73
|
+
repeatString,
|
|
74
|
+
replaceAllOccurrences,
|
|
75
|
+
reverseString,
|
|
76
|
+
sanitizeString,
|
|
77
|
+
startsWith,
|
|
78
|
+
strings_exports,
|
|
79
|
+
stripFromEnd,
|
|
80
|
+
stripFromStart,
|
|
81
|
+
toCamelCase,
|
|
82
|
+
toKebabCase,
|
|
83
|
+
toLowerCase,
|
|
84
|
+
toPascalCase,
|
|
85
|
+
toSnakeCase,
|
|
86
|
+
toUpperCase,
|
|
87
|
+
toUrlSlug,
|
|
88
|
+
trim,
|
|
89
|
+
trimEnd,
|
|
90
|
+
trimStart,
|
|
91
|
+
truncateString,
|
|
92
|
+
unescapeHtmlChars,
|
|
93
|
+
unescapeUnicode
|
|
94
|
+
} from "./chunk-WJA4JDMZ.js";
|
|
95
|
+
import {
|
|
96
|
+
calculateDifferences,
|
|
97
|
+
comparator,
|
|
98
|
+
deepEqual,
|
|
99
|
+
deleteArrayElementsBy,
|
|
100
|
+
formatToReadableString,
|
|
101
|
+
generateCrcHash,
|
|
102
|
+
getDeepValue,
|
|
103
|
+
getShallowProperties,
|
|
104
|
+
hasSameType,
|
|
105
|
+
objects_exports,
|
|
106
|
+
setDeepValue,
|
|
107
|
+
updateArrayElementById,
|
|
108
|
+
updateArrayElementsBy
|
|
109
|
+
} from "./chunk-WG7ILCUB.js";
|
|
110
|
+
import {
|
|
111
|
+
addDays,
|
|
112
|
+
addMonths,
|
|
113
|
+
addNowDays,
|
|
114
|
+
addNowMonths,
|
|
115
|
+
addNowSeconds,
|
|
116
|
+
addNowYears,
|
|
117
|
+
addSeconds,
|
|
118
|
+
addYears,
|
|
119
|
+
areDatesEqualWithTolerance,
|
|
120
|
+
dates_exports,
|
|
121
|
+
dayOfWeek,
|
|
122
|
+
diffBusinessDays,
|
|
123
|
+
diffDays,
|
|
124
|
+
diffMilliSeconds,
|
|
125
|
+
diffMonths,
|
|
126
|
+
diffYears,
|
|
127
|
+
excelToDate,
|
|
128
|
+
format,
|
|
129
|
+
formatForMysql,
|
|
130
|
+
formatNow,
|
|
131
|
+
fromNow,
|
|
132
|
+
getFirstDayOfYear,
|
|
133
|
+
getFirstWorkdayAfterMonths,
|
|
134
|
+
getFirstWorkdayOfMonth,
|
|
135
|
+
getLastDayOfYear,
|
|
136
|
+
getLastWorkdayOfMonth,
|
|
137
|
+
isDateTime,
|
|
138
|
+
isEqualsDateTimeByDay,
|
|
139
|
+
isExpired,
|
|
140
|
+
isNew,
|
|
141
|
+
isWeekday,
|
|
142
|
+
longString,
|
|
143
|
+
now,
|
|
144
|
+
toDate,
|
|
145
|
+
toDateFromString,
|
|
146
|
+
toISO,
|
|
147
|
+
weekOfYear
|
|
148
|
+
} from "./chunk-C3D7YZVE.js";
|
|
149
|
+
import {
|
|
150
|
+
calculateAggregations,
|
|
151
|
+
calculateAnnuityPayment,
|
|
152
|
+
calculateCorrelation,
|
|
153
|
+
calculateEuclideanDistance,
|
|
154
|
+
calculateFutureValue,
|
|
155
|
+
calculateHistogram,
|
|
156
|
+
calculateIQR,
|
|
157
|
+
calculateIRR,
|
|
158
|
+
calculateManhattanDistance,
|
|
159
|
+
calculateMedian,
|
|
160
|
+
calculateMode,
|
|
161
|
+
calculateNPV,
|
|
162
|
+
calculatePercentile,
|
|
163
|
+
calculatePresentValue,
|
|
164
|
+
calculateQuartiles,
|
|
165
|
+
calculateStandardDeviation,
|
|
166
|
+
calculateTrendSlope,
|
|
167
|
+
calculateVariance,
|
|
168
|
+
detectOutliers,
|
|
169
|
+
math_exports,
|
|
170
|
+
normalizeToRange,
|
|
171
|
+
scaleToRange,
|
|
172
|
+
simpleKMeans
|
|
173
|
+
} from "./chunk-4O7ZPIJN.js";
|
|
174
|
+
import {
|
|
175
|
+
isNumericValue,
|
|
176
|
+
number_exports,
|
|
177
|
+
roundToDecimals
|
|
178
|
+
} from "./chunk-SLQVNPTH.js";
|
|
179
|
+
import {
|
|
180
|
+
async_exports,
|
|
181
|
+
handleOperation,
|
|
182
|
+
runBatch,
|
|
183
|
+
sleep,
|
|
184
|
+
wait
|
|
185
|
+
} from "./chunk-ZFVYLUTT.js";
|
|
186
|
+
import "./chunk-75XNTC34.js";
|
|
187
|
+
import "./chunk-NSBPE2FW.js";
|
|
188
|
+
|
|
189
|
+
// src/universal/index.ts
|
|
190
|
+
var g = {
|
|
191
|
+
// Core validation functions (no crypto)
|
|
192
|
+
...validation_core_exports,
|
|
193
|
+
// String functions
|
|
194
|
+
...strings_exports,
|
|
195
|
+
// Object/Array functions
|
|
196
|
+
...objects_exports,
|
|
197
|
+
// Date functions
|
|
198
|
+
...dates_exports,
|
|
199
|
+
// Math functions
|
|
200
|
+
...math_exports,
|
|
201
|
+
// Async functions
|
|
202
|
+
...async_exports,
|
|
203
|
+
// Number utilities
|
|
204
|
+
...number_exports,
|
|
205
|
+
// Environment utilities (original)
|
|
206
|
+
...environment_exports,
|
|
207
|
+
// Enhanced environment detection
|
|
208
|
+
...environment_detection_exports
|
|
209
|
+
};
|
|
210
|
+
var universal_default = g;
|
|
211
|
+
export {
|
|
212
|
+
addDays,
|
|
213
|
+
addMonths,
|
|
214
|
+
addNowDays,
|
|
215
|
+
addNowMonths,
|
|
216
|
+
addNowSeconds,
|
|
217
|
+
addNowYears,
|
|
218
|
+
addSeconds,
|
|
219
|
+
addYears,
|
|
220
|
+
areDatesEqualWithTolerance,
|
|
221
|
+
async_exports as async,
|
|
222
|
+
calculateAggregations,
|
|
223
|
+
calculateAnnuityPayment,
|
|
224
|
+
calculateCorrelation,
|
|
225
|
+
calculateDifferences,
|
|
226
|
+
calculateEuclideanDistance,
|
|
227
|
+
calculateFutureValue,
|
|
228
|
+
calculateHistogram,
|
|
229
|
+
calculateIQR,
|
|
230
|
+
calculateIRR,
|
|
231
|
+
calculateManhattanDistance,
|
|
232
|
+
calculateMedian,
|
|
233
|
+
calculateMode,
|
|
234
|
+
calculateNPV,
|
|
235
|
+
calculatePercentile,
|
|
236
|
+
calculatePresentValue,
|
|
237
|
+
calculateQuartiles,
|
|
238
|
+
calculateStandardDeviation,
|
|
239
|
+
calculateTrendSlope,
|
|
240
|
+
calculateVariance,
|
|
241
|
+
capitalizeEachWord,
|
|
242
|
+
capitalizeFirst,
|
|
243
|
+
cleanJsonChars,
|
|
244
|
+
comparator,
|
|
245
|
+
contains,
|
|
246
|
+
countOccurrences,
|
|
247
|
+
dates_exports as dates,
|
|
248
|
+
dayOfWeek,
|
|
249
|
+
deepEqual,
|
|
250
|
+
universal_default as default,
|
|
251
|
+
deleteArrayElementsBy,
|
|
252
|
+
detectHostname,
|
|
253
|
+
detectOutliers,
|
|
254
|
+
detectProtocol,
|
|
255
|
+
diffBusinessDays,
|
|
256
|
+
diffDays,
|
|
257
|
+
diffMilliSeconds,
|
|
258
|
+
diffMonths,
|
|
259
|
+
diffYears,
|
|
260
|
+
endsWith,
|
|
261
|
+
ensureEndsWith,
|
|
262
|
+
ensureStartsWith,
|
|
263
|
+
envKeyToPath,
|
|
264
|
+
environment_exports as environment,
|
|
265
|
+
escapeHtmlChars,
|
|
266
|
+
excelToDate,
|
|
267
|
+
format,
|
|
268
|
+
formatForMysql,
|
|
269
|
+
formatNow,
|
|
270
|
+
formatToReadableString,
|
|
271
|
+
fromNow,
|
|
272
|
+
generateAlphaNumericString,
|
|
273
|
+
generateAlphaString,
|
|
274
|
+
generateComplexString,
|
|
275
|
+
generateCrcHash,
|
|
276
|
+
generateEmail,
|
|
277
|
+
generateHexColor,
|
|
278
|
+
generatePassword,
|
|
279
|
+
generateRandomInteger,
|
|
280
|
+
generateSpanishCIF,
|
|
281
|
+
generateSpanishIBAN,
|
|
282
|
+
generateSpanishNIE,
|
|
283
|
+
generateSpanishNIF,
|
|
284
|
+
generateSpanishPostalCode,
|
|
285
|
+
generateUsername,
|
|
286
|
+
generateUsernameFromEmail,
|
|
287
|
+
getCryptoCapabilities,
|
|
288
|
+
getDeepValue,
|
|
289
|
+
getEnvironmentInfo,
|
|
290
|
+
getEnvironmentType,
|
|
291
|
+
getFirstDayOfYear,
|
|
292
|
+
getFirstWorkdayAfterMonths,
|
|
293
|
+
getFirstWorkdayOfMonth,
|
|
294
|
+
getLastDayOfYear,
|
|
295
|
+
getLastWorkdayOfMonth,
|
|
296
|
+
getShallowProperties,
|
|
297
|
+
handleOperation,
|
|
298
|
+
hasSameType,
|
|
299
|
+
isBrowser,
|
|
300
|
+
isBrowserEnv,
|
|
301
|
+
isBrowserEnvironment,
|
|
302
|
+
isDateTime,
|
|
303
|
+
isDevelopment,
|
|
304
|
+
isEmail,
|
|
305
|
+
isEmpty,
|
|
306
|
+
isEqualsDateTimeByDay,
|
|
307
|
+
isExpired,
|
|
308
|
+
isLocalhost,
|
|
309
|
+
isNew,
|
|
310
|
+
isNode,
|
|
311
|
+
isNodeCryptoAvailable,
|
|
312
|
+
isNodeEnv,
|
|
313
|
+
isNodeEnvironment,
|
|
314
|
+
isNonProduction,
|
|
315
|
+
isNumericValue,
|
|
316
|
+
isPrivateIP,
|
|
317
|
+
isProduction,
|
|
318
|
+
isTest,
|
|
319
|
+
isValidCIF,
|
|
320
|
+
isValidEmail,
|
|
321
|
+
isValidJSON,
|
|
322
|
+
isValidNIE,
|
|
323
|
+
isValidNIF,
|
|
324
|
+
isValidSpanishIBAN,
|
|
325
|
+
isValidSpanishPhone,
|
|
326
|
+
isValidSpanishPostalCode,
|
|
327
|
+
isValidURL,
|
|
328
|
+
isWebCryptoAvailable,
|
|
329
|
+
isWeekday,
|
|
330
|
+
isWorkerEnvironment,
|
|
331
|
+
longString,
|
|
332
|
+
matchPathPattern,
|
|
333
|
+
math_exports as math,
|
|
334
|
+
normalizeToRange,
|
|
335
|
+
now,
|
|
336
|
+
number_exports as number,
|
|
337
|
+
objects_exports as objects,
|
|
338
|
+
padEnd,
|
|
339
|
+
padStart,
|
|
340
|
+
parseEnvValue,
|
|
341
|
+
pathToEnvKey,
|
|
342
|
+
removeAccents,
|
|
343
|
+
repeatString,
|
|
344
|
+
replaceAllOccurrences,
|
|
345
|
+
reverseString,
|
|
346
|
+
roundToDecimals,
|
|
347
|
+
runBatch,
|
|
348
|
+
sanitizeString,
|
|
349
|
+
scaleToRange,
|
|
350
|
+
setDeepValue,
|
|
351
|
+
simpleKMeans,
|
|
352
|
+
sleep,
|
|
353
|
+
startsWith,
|
|
354
|
+
strings_exports as strings,
|
|
355
|
+
stripFromEnd,
|
|
356
|
+
stripFromStart,
|
|
357
|
+
toCamelCase,
|
|
358
|
+
toDate,
|
|
359
|
+
toDateFromString,
|
|
360
|
+
toISO,
|
|
361
|
+
toKebabCase,
|
|
362
|
+
toLowerCase,
|
|
363
|
+
toPascalCase,
|
|
364
|
+
toSnakeCase,
|
|
365
|
+
toUpperCase,
|
|
366
|
+
toUrlSlug,
|
|
367
|
+
trim,
|
|
368
|
+
trimEnd,
|
|
369
|
+
trimStart,
|
|
370
|
+
truncateString,
|
|
371
|
+
unescapeHtmlChars,
|
|
372
|
+
unescapeUnicode,
|
|
373
|
+
updateArrayElementById,
|
|
374
|
+
updateArrayElementsBy,
|
|
375
|
+
validateNIF,
|
|
376
|
+
validation_core_exports as validation,
|
|
377
|
+
wait,
|
|
378
|
+
weekOfYear
|
|
379
|
+
};
|
|
380
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/universal/index.ts"],"sourcesContent":["/**\n * Universal exports - Safe for all environments\n * No crypto dependencies - browser and Node.js compatible\n */\n\n// Import universal modules (safe for all environments)\nimport * as validationCore from './validation-core'\nimport * as environmentDetection from './environment-detection'\nimport * as stringFunctions from '../strings'\nimport * as objectFunctions from '../objects'\nimport * as dateFunctions from '../dates'\nimport * as mathFunctions from '../math'\nimport * as asyncFunctions from '../async'\nimport * as environmentModule from '../environment'\nimport * as numberModule from '../number'\n\n// NOTE: data, csv, json, tree modules are NOT included in universal build\n// because they have Node.js dependencies (fs/promises, path)\n// These are available in Node.js specific builds\n\n// Create flat API object - universal functions only (safe for browser)\nconst g = {\n // Core validation functions (no crypto)\n ...validationCore,\n\n // String functions\n ...stringFunctions,\n\n // Object/Array functions\n ...objectFunctions,\n\n // Date functions\n ...dateFunctions,\n\n // Math functions\n ...mathFunctions,\n\n // Async functions\n ...asyncFunctions,\n\n // Number utilities\n ...numberModule,\n\n // Environment utilities (original)\n ...environmentModule,\n\n // Enhanced environment detection\n ...environmentDetection,\n}\n\n// Export both default and named exports\nexport default g\n\n// Named exports for specific imports\nexport {\n validationCore as validation,\n stringFunctions as strings,\n objectFunctions as objects,\n dateFunctions as dates,\n mathFunctions as math,\n asyncFunctions as async,\n environmentModule as environment,\n numberModule as number,\n}\n\n// Re-export individual functions for tree-shaking\nexport * from './validation-core'\nexport * from './environment-detection'\nexport * from '../strings'\nexport * from '../objects'\nexport * from '../dates'\nexport * from '../math'\nexport * from '../async'\nexport * from '../environment'\nexport * from '../number'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,IAAI;AAAA;AAAA,EAER,GAAG;AAAA;AAAA,EAGH,GAAG;AAAA;AAAA,EAGH,GAAG;AAAA;AAAA,EAGH,GAAG;AAAA;AAAA,EAGH,GAAG;AAAA;AAAA,EAGH,GAAG;AAAA;AAAA,EAGH,GAAG;AAAA;AAAA,EAGH,GAAG;AAAA;AAAA,EAGH,GAAG;AACL;AAGA,IAAO,oBAAQ;","names":[]}
|
package/dist/esm/math.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateAggregations,
|
|
3
|
+
calculateAnnuityPayment,
|
|
4
|
+
calculateCorrelation,
|
|
5
|
+
calculateEuclideanDistance,
|
|
6
|
+
calculateFutureValue,
|
|
7
|
+
calculateHistogram,
|
|
8
|
+
calculateIQR,
|
|
9
|
+
calculateIRR,
|
|
10
|
+
calculateManhattanDistance,
|
|
11
|
+
calculateMedian,
|
|
12
|
+
calculateMode,
|
|
13
|
+
calculateNPV,
|
|
14
|
+
calculatePercentile,
|
|
15
|
+
calculatePresentValue,
|
|
16
|
+
calculateQuartiles,
|
|
17
|
+
calculateStandardDeviation,
|
|
18
|
+
calculateTrendSlope,
|
|
19
|
+
calculateVariance,
|
|
20
|
+
detectOutliers,
|
|
21
|
+
normalizeToRange,
|
|
22
|
+
scaleToRange,
|
|
23
|
+
simpleKMeans
|
|
24
|
+
} from "./chunk-4O7ZPIJN.js";
|
|
25
|
+
import "./chunk-SLQVNPTH.js";
|
|
26
|
+
import "./chunk-NSBPE2FW.js";
|
|
27
|
+
export {
|
|
28
|
+
calculateAggregations,
|
|
29
|
+
calculateAnnuityPayment,
|
|
30
|
+
calculateCorrelation,
|
|
31
|
+
calculateEuclideanDistance,
|
|
32
|
+
calculateFutureValue,
|
|
33
|
+
calculateHistogram,
|
|
34
|
+
calculateIQR,
|
|
35
|
+
calculateIRR,
|
|
36
|
+
calculateManhattanDistance,
|
|
37
|
+
calculateMedian,
|
|
38
|
+
calculateMode,
|
|
39
|
+
calculateNPV,
|
|
40
|
+
calculatePercentile,
|
|
41
|
+
calculatePresentValue,
|
|
42
|
+
calculateQuartiles,
|
|
43
|
+
calculateStandardDeviation,
|
|
44
|
+
calculateTrendSlope,
|
|
45
|
+
calculateVariance,
|
|
46
|
+
detectOutliers,
|
|
47
|
+
normalizeToRange,
|
|
48
|
+
scaleToRange,
|
|
49
|
+
simpleKMeans
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateDifferences,
|
|
3
|
+
comparator,
|
|
4
|
+
deepEqual,
|
|
5
|
+
deleteArrayElementsBy,
|
|
6
|
+
formatToReadableString,
|
|
7
|
+
generateCrcHash,
|
|
8
|
+
getDeepValue,
|
|
9
|
+
getShallowProperties,
|
|
10
|
+
hasSameType,
|
|
11
|
+
setDeepValue,
|
|
12
|
+
updateArrayElementById,
|
|
13
|
+
updateArrayElementsBy
|
|
14
|
+
} from "./chunk-WG7ILCUB.js";
|
|
15
|
+
import "./chunk-C3D7YZVE.js";
|
|
16
|
+
import "./chunk-NSBPE2FW.js";
|
|
17
|
+
export {
|
|
18
|
+
calculateDifferences,
|
|
19
|
+
comparator,
|
|
20
|
+
deepEqual,
|
|
21
|
+
deleteArrayElementsBy,
|
|
22
|
+
formatToReadableString,
|
|
23
|
+
generateCrcHash,
|
|
24
|
+
getDeepValue,
|
|
25
|
+
getShallowProperties,
|
|
26
|
+
hasSameType,
|
|
27
|
+
setDeepValue,
|
|
28
|
+
updateArrayElementById,
|
|
29
|
+
updateArrayElementsBy
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|