@react-hive/honey-utils 2.0.0 → 2.2.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 +3 -0
- package/dist/README.md +3 -0
- package/dist/dom.d.ts +22 -0
- package/dist/function.d.ts +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +71 -1
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -465,6 +465,7 @@ function divide(a: number, b: number): number {
|
|
|
465
465
|
- `noop(): void` - A no-operation function.
|
|
466
466
|
- `invokeIfFunction<Args extends any[], Result>(input: ((...args: Args) => Result) | Result, ...args: Args): Result` - Invokes the input if it's a function, otherwise returns it as-is.
|
|
467
467
|
- `delay(delayMs: number): Promise<void>` - Creates a promise that resolves after the specified delay in milliseconds.
|
|
468
|
+
- `timeout<T>(promise: Promise<T>, timeoutMs: number, message?: string): Promise<T>` - Wraps a promise with a timeout. If the promise does not settle within the given duration, it rejects with a timeout error.
|
|
468
469
|
- `retry<Task, TaskResult>(task: Task, options?: RetryOptions): Function` - Wraps an asynchronous function with retry logic, with configurable max attempts, delay between retries, exponential backoff, and retry callbacks.
|
|
469
470
|
|
|
470
471
|
### Type Guards
|
|
@@ -504,6 +505,8 @@ function divide(a: number, b: number): number {
|
|
|
504
505
|
- `parse2DMatrix(element: HTMLElement): { translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number }` - Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.
|
|
505
506
|
- `cloneBlob(blob: Blob): Blob` - Creates a clone of a Blob object with the same content and type as the original.
|
|
506
507
|
- `convertBlobToFile(blob: Blob, fileName: string): File` - Converts a Blob object into a File object with the specified name.
|
|
508
|
+
- `getDOMRectIntersectionRatio(sourceRect: DOMRect, targetRect: DOMRect): number` - Calculates the ratio of the `targetRect` that is overlapped by the `sourceRect`. Returns a number between `0` (no overlap) and `1` (fully covered).
|
|
509
|
+
- `getElementOffsetRect(element: HTMLElement): DOMRect` - Returns a `DOMRect` representing the element's layout position using `offsetLeft`, `offsetTop`, and `clientWidth`/`clientHeight`.
|
|
507
510
|
|
|
508
511
|
### Asynchronous Utilities
|
|
509
512
|
|
package/dist/README.md
CHANGED
|
@@ -465,6 +465,7 @@ function divide(a: number, b: number): number {
|
|
|
465
465
|
- `noop(): void` - A no-operation function.
|
|
466
466
|
- `invokeIfFunction<Args extends any[], Result>(input: ((...args: Args) => Result) | Result, ...args: Args): Result` - Invokes the input if it's a function, otherwise returns it as-is.
|
|
467
467
|
- `delay(delayMs: number): Promise<void>` - Creates a promise that resolves after the specified delay in milliseconds.
|
|
468
|
+
- `timeout<T>(promise: Promise<T>, timeoutMs: number, message?: string): Promise<T>` - Wraps a promise with a timeout. If the promise does not settle within the given duration, it rejects with a timeout error.
|
|
468
469
|
- `retry<Task, TaskResult>(task: Task, options?: RetryOptions): Function` - Wraps an asynchronous function with retry logic, with configurable max attempts, delay between retries, exponential backoff, and retry callbacks.
|
|
469
470
|
|
|
470
471
|
### Type Guards
|
|
@@ -504,6 +505,8 @@ function divide(a: number, b: number): number {
|
|
|
504
505
|
- `parse2DMatrix(element: HTMLElement): { translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number }` - Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.
|
|
505
506
|
- `cloneBlob(blob: Blob): Blob` - Creates a clone of a Blob object with the same content and type as the original.
|
|
506
507
|
- `convertBlobToFile(blob: Blob, fileName: string): File` - Converts a Blob object into a File object with the specified name.
|
|
508
|
+
- `getDOMRectIntersectionRatio(sourceRect: DOMRect, targetRect: DOMRect): number` - Calculates the ratio of the `targetRect` that is overlapped by the `sourceRect`. Returns a number between `0` (no overlap) and `1` (fully covered).
|
|
509
|
+
- `getElementOffsetRect(element: HTMLElement): DOMRect` - Returns a `DOMRect` representing the element's layout position using `offsetLeft`, `offsetTop`, and `clientWidth`/`clientHeight`.
|
|
507
510
|
|
|
508
511
|
### Asynchronous Utilities
|
|
509
512
|
|
package/dist/dom.d.ts
CHANGED
|
@@ -50,4 +50,26 @@ export declare const cloneBlob: (blob: Blob) => Blob;
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
export declare const convertBlobToFile: (blob: Blob, fileName: string) => File;
|
|
53
|
+
/**
|
|
54
|
+
* Calculates the intersection ratio between two DOM rectangles.
|
|
55
|
+
*
|
|
56
|
+
* The ratio represents the proportion of the `targetRect` that is covered by `sourceRect`.
|
|
57
|
+
* A value of `1` means `sourceRect` completely covers `targetRect`, and `0` means no overlap.
|
|
58
|
+
*
|
|
59
|
+
* @param sourceRect - The rectangle used to measure overlap against the target.
|
|
60
|
+
* @param targetRect - The rectangle whose covered area is measured.
|
|
61
|
+
*
|
|
62
|
+
* @returns A number between `0` and `1` representing the intersection ratio.
|
|
63
|
+
*/
|
|
64
|
+
export declare const getDOMRectIntersectionRatio: (sourceRect: DOMRect, targetRect: DOMRect) => number;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the bounding DOMRect of an element based on offset and client dimensions.
|
|
67
|
+
*
|
|
68
|
+
* This utility is useful when you need a stable, layout-based rect
|
|
69
|
+
* without triggering a reflow via `getBoundingClientRect()`.
|
|
70
|
+
*
|
|
71
|
+
* @param element - The target HTML element.
|
|
72
|
+
* @returns A `DOMRect` representing the element’s offset position and size.
|
|
73
|
+
*/
|
|
74
|
+
export declare const getElementOffsetRect: (element: HTMLElement) => DOMRect;
|
|
53
75
|
export {};
|
package/dist/function.d.ts
CHANGED
|
@@ -38,6 +38,29 @@ export declare const invokeIfFunction: <Args extends unknown[], Result>(input: (
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export declare const delay: (delayMs: number) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Wraps a promise with a timeout. If the promise does not settle within the specified time,
|
|
43
|
+
* it will reject with a timeout error.
|
|
44
|
+
*
|
|
45
|
+
* @template T - The type of the promise result.
|
|
46
|
+
*
|
|
47
|
+
* @param promise - The promise to wrap.
|
|
48
|
+
* @param timeoutMs - Timeout duration in milliseconds.
|
|
49
|
+
* @param errorMessage - Optional custom error message.
|
|
50
|
+
*
|
|
51
|
+
* @returns A promise that resolves or rejects with the original promise,
|
|
52
|
+
* or rejects with a timeout error if the duration is exceeded.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* // Rejects if fetch takes longer than 3 seconds
|
|
57
|
+
* const response = await timeout(fetch('/api/data'), 3000);
|
|
58
|
+
*
|
|
59
|
+
* // With custom message
|
|
60
|
+
* await timeout(fetchData(), 2000, 'Too long');
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const timeout: <T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string) => Promise<T>;
|
|
41
64
|
interface RetryOptions {
|
|
42
65
|
/**
|
|
43
66
|
* Maximum number of retry attempts before failing.
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,
|
|
1
|
+
(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){if(!e)throw new Error(t)}e.r(t),e.d(t,{assert:()=>n,calculateEuclideanDistance:()=>K,calculateMovingSpeed:()=>U,calculatePercentage:()=>G,camelToDashCase:()=>$,chunk:()=>k,cloneBlob:()=>Q,compact:()=>v,compose:()=>j,convertBlobToFile:()=>ee,delay:()=>Z,difference:()=>E,everyAsync:()=>X,filterParallel:()=>F,filterSequential:()=>R,findAsync:()=>I,getDOMRectIntersectionRatio:()=>te,getElementOffsetRect:()=>ne,hashString:()=>z,intersection:()=>D,invokeIfFunction:()=>W,isArray:()=>y,isBool:()=>c,isDate:()=>g,isDefined:()=>o,isEmptyArray:()=>p,isEmptyObject:()=>f,isFiniteNumber:()=>O,isFunction:()=>m,isInteger:()=>P,isMap:()=>b,isNil:()=>a,isNilOrEmptyString:()=>i,isNull:()=>r,isNumber:()=>l,isObject:()=>u,isPromise:()=>h,isRegExp:()=>w,isSet:()=>M,isString:()=>s,isSymbol:()=>S,isUndefined:()=>A,isValidDate:()=>d,noop:()=>V,parse2DMatrix:()=>J,pipe:()=>T,reduceAsync:()=>Y,retry:()=>H,runParallel:()=>N,runSequential:()=>C,someAsync:()=>B,splitStringIntoWords:()=>q,timeout:()=>_,toKebabCase:()=>L,unique:()=>x});const r=e=>null===e,a=e=>null==e,i=e=>""===e||a(e),o=e=>null!=e,s=e=>"string"==typeof e,l=e=>"number"==typeof e,c=e=>"boolean"==typeof e,u=e=>"object"==typeof e,f=e=>u(e)&&!r(e)&&0===Object.keys(e).length,y=e=>Array.isArray(e),p=e=>y(e)&&0===e.length,m=e=>"function"==typeof e,h=e=>m(e?.then),g=e=>e instanceof Date,d=e=>g(e)&&!isNaN(e.getTime()),w=e=>e instanceof RegExp,b=e=>e instanceof Map,M=e=>e instanceof Set,S=e=>"symbol"==typeof e,A=e=>void 0===e,O=e=>l(e)&&isFinite(e),P=e=>l(e)&&Number.isInteger(e),v=e=>e.filter(Boolean),x=e=>[...new Set(e)],k=(e,t)=>(n(t>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),D=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return x(t).filter(e=>n.every(t=>t.includes(e)))},E=(e,t)=>e.filter(e=>!t.includes(e)),T=(...e)=>t=>e.reduce((e,t)=>t(e),t),j=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),C=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},N=async(e,t)=>Promise.all(e.map(t)),R=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const a=e[r];await t(a,r,e)&&n.push(a)}return n},F=async(e,t)=>{const n=await N(e,async(e,n,r)=>!!await t(e,n,r)&&e);return v(n)},B=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},X=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},Y=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},I=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},L=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),$=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},q=e=>e.split(" ").filter(Boolean),z=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},V=()=>{},W=(e,...t)=>"function"==typeof e?e(...t):e,Z=e=>new Promise(t=>setTimeout(t,e)),_=async(e,t,n="Operation timed out")=>{let r=null;const a=new Promise((e,a)=>{r=setTimeout(()=>a(new Error(n)),t)});try{return await Promise.race([e,a])}finally{r&&clearTimeout(r)}},H=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...i)=>{let o;for(let s=1;s<=t;s++)try{return await e(...i)}catch(e){if(o=e,s<t){a?.(s,e);const t=r?n*2**(s-1):n;await Z(t)}}throw o},K=(e,t,n,r)=>{const a=n-e,i=r-t;return Math.hypot(a,i)},U=(e,t)=>Math.abs(e/t),G=(e,t)=>e*t/100,J=e=>{const t=window.getComputedStyle(e).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,a,i,o,s]=t[1].split(", ").map(parseFloat);return{translateX:o,translateY:s,scaleX:n,scaleY:i,skewX:a,skewY:r}},Q=e=>new Blob([e],{type:e.type}),ee=(e,t)=>new File([e],t,{type:e.type}),te=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top))/(t.width*t.height),ne=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight);module.exports=t})();
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,KCLhD,SAASC,EAAOC,EAAgBC,GACrC,IAAKD,EACH,MAAM,IAAIE,MAAMD,EAEpB,C,o5BASO,MAAME,EAAUL,GAA4C,OAAVA,EAS5CM,EAASN,GACpBA,QAcWO,EAAsBP,GACvB,KAAVA,GAAgBM,EAAMN,GASXQ,EAAgBR,GAC3BA,QASWS,EAAYT,GAAqD,iBAAVA,EASvDU,EAAYV,GAAqD,iBAAVA,EASvDW,EAAUX,GAAsD,kBAAVA,EAStDY,EAAYZ,GAAqD,iBAAVA,EASvDa,EAAiBb,GAC5BY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AAOF,EAChBK,EAASF,EAAOF,EAEtB,OAAOzE,KAAK8E,MAAMF,EAAQC,IAWfE,EAAuB,CAACC,EAAkBC,IACrDjF,KAAKkF,IAAIF,EAAWC,GAUTE,EAAsB,CAACnI,EAAeoI,IACzCpI,EAAQoI,EAAc,IClBnBC,EAAiBC,IAC5B,MAGMC,EAHiBC,OAAOC,iBAAiBH,GACTI,iBAAiB,aAEpBC,MAAM,oBACzC,IAAKJ,EACH,MAAO,CACLK,WAAY,EACZC,WAAY,EACZC,OAAQ,EACRC,OAAQ,EACRC,MAAO,EACPC,MAAO,GAIX,MAAOH,EAAQG,EAAOD,EAAOD,EAAQH,EAAYC,GAAcN,EAAY,GACxErC,MAAM,MACNpB,IAAIoE,YAEP,MAAO,CACLN,aACAC,aACAC,SACAC,SACAC,QACAC,UAWSE,EAAaC,GAAqB,IAAIC,KAAK,CAACD,GAAO,CAAEE,KAAMF,EAAKE,OAqBhEC,EAAoB,CAACH,EAAYI,IAC5C,IAAIC,KAAK,CAACL,GAAOI,EAAU,CACzBF,KAAMF,EAAKE,O","sources":["webpack://@react-hive/honey-utils/webpack/bootstrap","webpack://@react-hive/honey-utils/webpack/runtime/define property getters","webpack://@react-hive/honey-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-utils/webpack/runtime/make namespace object","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/async.ts","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/math.ts","webpack://@react-hive/honey-utils/./src/dom.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n\n/**\n * Checks if a value is null.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is null; otherwise, `false`.\n */\nexport const isNull = (value: unknown): value is null => value === null;\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n\n/**\n * Checks whether the provided value is considered \"empty\".\n *\n * A value is considered empty if it is:\n * - `null`\n * - `undefined`\n * - `''`\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is empty; otherwise, `false`.\n */\nexport const isNilOrEmptyString = (value: unknown): value is null | undefined =>\n value === '' || isNil(value);\n\n/**\n * Checks if a value is neither `null` nor `undefined`.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is defined (not `null` or `undefined`); otherwise, `false`.\n */\nexport const isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== null && value !== undefined;\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a string; otherwise, `false`.\n */\nexport const isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Checks if a value is a number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a number; otherwise, `false`.\n */\nexport const isNumber = (value: unknown): value is number => typeof value === 'number';\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a boolean; otherwise, `false`.\n */\nexport const isBool = (value: unknown): value is boolean => typeof value === 'boolean';\n\n/**\n * Checks if a value is an object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an object; otherwise, `false`.\n */\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\n/**\n * Checks if a value is an empty object (no own enumerable properties).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty object; otherwise, `false`.\n */\nexport const isEmptyObject = (value: unknown): value is Record<string, never> =>\n isObject(value) && !isNull(value) && Object.keys(value).length === 0;\n\n/**\n * Checks if a value is an array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an array; otherwise, `false`.\n */\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n\n/**\n * Checks if a value is an empty array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty array; otherwise, `false`.\n */\nexport const isEmptyArray = (value: unknown): value is [] => isArray(value) && value.length === 0;\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a function; otherwise, `false`.\n */\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is a Promise.\n *\n * @template T - The type of the value that the Promise resolves to.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Promise; otherwise, `false`.\n */\nexport const isPromise = <T = unknown>(value: unknown): value is Promise<T> =>\n isFunction((value as Promise<T>)?.then);\n\n/**\n * Checks if a value is a Date object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Date object; otherwise, `false`.\n */\nexport const isDate = (value: unknown): value is Date => value instanceof Date;\n\n/**\n * Checks if a value is a valid Date object (not Invalid Date).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a valid Date object; otherwise, `false`.\n */\nexport const isValidDate = (value: unknown): value is Date =>\n isDate(value) && !isNaN(value.getTime());\n\n/**\n * Checks if a value is a RegExp object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a RegExp object; otherwise, `false`.\n */\nexport const isRegExp = (value: unknown): value is RegExp => value instanceof RegExp;\n\n/**\n * Checks if a value is a Map.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Map; otherwise, `false`.\n */\nexport const isMap = (value: unknown): value is Map<unknown, unknown> => value instanceof Map;\n\n/**\n * Checks if a value is a Set.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Set; otherwise, `false`.\n */\nexport const isSet = (value: unknown): value is Set<unknown> => value instanceof Set;\n\n/**\n * Checks if a value is a Symbol.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Symbol; otherwise, `false`.\n */\nexport const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol';\n\n/**\n * Checks if a value is undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is undefined; otherwise, `false`.\n */\nexport const isUndefined = (value: unknown): value is undefined => value === undefined;\n\n/**\n * Checks if a value is a finite number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a finite number; otherwise, `false`.\n */\nexport const isFiniteNumber = (value: unknown): value is number =>\n isNumber(value) && isFinite(value);\n\n/**\n * Checks if a value is an integer.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an integer; otherwise, `false`.\n */\nexport const isInteger = (value: unknown): value is number =>\n isNumber(value) && Number.isInteger(value);\n","import { assert } from './guards';\n\n/**\n * Represents all falsy values.\n */\ntype Falsy = false | null | undefined | 0 | '';\n\n/**\n * Removes all falsy values from an array.\n *\n * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.\n *\n * Useful for cleaning up arrays with optional, nullable, or conditionally included items.\n *\n * @template T - The type of the truthy items.\n *\n * @param array - An array possibly containing falsy values.\n *\n * @returns A new array containing only truthy values of type `T`.\n *\n * @example\n * ```ts\n * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]\n * ```\n */\nexport const compact = <T>(array: (T | Falsy)[]): T[] => array.filter(Boolean) as T[];\n\n/**\n * Returns a new array with duplicate values removed.\n *\n * Uses Set for efficient duplicate removal while preserving the original order.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array that may contain duplicate values.\n *\n * @returns A new array with only unique values, maintaining the original order.\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]\n * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']\n * ```\n */\nexport const unique = <T>(array: T[]): T[] => [...new Set(array)];\n\n/**\n * Splits an array into chunks of the specified size.\n *\n * Useful for pagination, batch processing, or creating grid layouts.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array to be chunked.\n * @param size - The size of each chunk. Must be greater than 0.\n *\n * @returns An array of chunks, where each chunk is an array of the specified size\n * (except possibly the last chunk, which may be smaller).\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]\n * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]\n * ```\n */\nexport const chunk = <T>(array: T[], size: number): T[][] => {\n assert(size > 0, 'Chunk size must be greater than 0');\n\n return Array.from({ length: Math.ceil(array.length / size) }, (_, index) =>\n array.slice(index * size, (index + 1) * size),\n );\n};\n\n/**\n * Returns an array containing elements that exist in all provided arrays.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param arrays - Two or more arrays to find common elements from.\n *\n * @returns A new array containing only the elements that exist in all input arrays.\n *\n * @example\n * ```ts\n * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]\n * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']\n * ```\n */\nexport const intersection = <T>(...arrays: T[][]): T[] => {\n if (arrays.length === 0) {\n return [];\n }\n\n if (arrays.length === 1) {\n return [...arrays[0]];\n }\n\n const [first, ...rest] = arrays;\n const uniqueFirst = unique(first);\n\n return uniqueFirst.filter(item => rest.every(array => array.includes(item)));\n};\n\n/**\n * Returns elements from the first array that don't exist in the second array.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param array - The source array.\n * @param exclude - The array containing elements to exclude.\n *\n * @returns A new array with elements from the first array that don't exist in the second array.\n *\n * @example\n * ```ts\n * difference([1, 2, 3, 4], [2, 4]); // [1, 3]\n * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']\n * ```\n */\nexport const difference = <T>(array: T[], exclude: T[]): T[] =>\n array.filter(item => !exclude.includes(item));\n\ntype PipeFn = (arg: unknown) => unknown;\n\ntype Pipe = {\n <A, B>(fn1: (a: A) => B): (a: A) => B;\n <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;\n <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;\n <A, B, C, D, E>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n ): (a: A) => E;\n <A, B, C, D, E, F>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n fn5: (e: E) => F,\n ): (a: A) => F;\n (...fns: PipeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from left to right.\n *\n * Useful for building a data processing pipeline where the output of one function becomes the input of the next.\n *\n * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from left to right.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = pipe(add, double, toStr)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const pipe: Pipe =\n (...fns: PipeFn[]) =>\n (arg: unknown) =>\n fns.reduce((prev, fn) => fn(prev), arg);\n\ntype ComposeFn = (arg: unknown) => unknown;\n\ntype Compose = {\n <A, R>(fn1: (a: A) => R): (a: A) => R;\n <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;\n <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;\n <A, B, C, D, R>(\n fn1: (d: D) => R,\n fn2: (c: C) => D,\n fn3: (b: B) => C,\n fn4: (a: A) => B,\n ): (a: A) => R;\n <A, B, C, D, E, R>(\n fn1: (e: E) => R,\n fn2: (d: D) => E,\n fn3: (c: C) => D,\n fn4: (b: B) => C,\n fn5: (a: A) => B,\n ): (a: A) => R;\n (...fns: ComposeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from **right to left**.\n *\n * Often used for building functional pipelines where the innermost function runs first.\n * Types are inferred up to 5 chained functions for full type safety.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from right to left.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = compose(toStr, double, add)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const compose: Compose =\n (...fns: ComposeFn[]) =>\n (arg: unknown) =>\n fns.reduceRight((prev, fn) => fn(prev), arg);\n","import { compact } from './array';\n\n/**\n * Asynchronously iterates over an array and executes an async function on each item sequentially,\n * collecting the results.\n *\n * Useful when order or timing matters (e.g., rate limits, UI updates, animations).\n *\n * @param array - The array of items to iterate over.\n * @param fn - An async function to execute for each item. Must return a value.\n *\n * @returns A promise that resolves with an array of results from each function call.\n *\n * @example\n * ```ts\n * const results = await runSequential([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runSequential = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => {\n const results: Result[] = [];\n\n for (let i = 0; i < array.length; i++) {\n results.push(await fn(array[i], i, array));\n }\n\n return results;\n};\n\n/**\n * Executes an asynchronous operation on each element of an array and waits for all promises to resolve.\n *\n * @param array - The array of items to operate on.\n * @param fn - The asynchronous operation to perform on each item.\n *\n * @returns A promise that resolves with an array of results after all operations are completed.\n *\n * @example\n * ```ts\n * const results = await runParallel([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runParallel = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => Promise.all(array.map(fn));\n\n/**\n * Asynchronously filters an array using a predicate function, executing **sequentially**.\n *\n * Useful for rate-limited or stateful async operations where execution order matters.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a `boolean` indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Sequentially filter even numbers with delay\n * const result = await filterSequential([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterSequential = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results: Item[] = [];\n\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n\n if (await predicate(item, i, array)) {\n results.push(item);\n }\n }\n\n return results;\n};\n\n/**\n * Asynchronously filters an array based on a provided async predicate function.\n *\n * Each item is passed to the `predicate` function in parallel, and only the items\n * for which the predicate resolves to `true` are included in the final result.\n *\n * Useful for filtering based on asynchronous conditions such as API calls,\n * file system access, or any other delayed operations.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a boolean indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Filter numbers that are even after a simulated delay\n * const result = await filterParallel([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterParallel = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results = await runParallel(array, async (item, index, array) =>\n (await predicate(item, index, array)) ? item : false,\n );\n\n return compact(results);\n};\n\n/**\n * Asynchronously checks if at least one element in the array satisfies the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if any item passes the condition.\n */\nexport const someAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Asynchronously checks if all elements in the array satisfy the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if all items pass the condition.\n */\nexport const everyAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (!(await predicate(array[i], i, array))) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Asynchronously reduces an array to a single accumulated value.\n *\n * @template Item - The type of items in the array.\n * @template Accumulator - The type of the accumulated result.\n *\n * @param array - The array to reduce.\n * @param fn - The async reducer function that processes each item and returns the updated accumulator.\n * @param initialValue - The initial accumulator value.\n *\n * @returns A promise that resolves to the final accumulated result.\n */\nexport const reduceAsync = async <Item, Accumulator>(\n array: Item[],\n fn: (accumulator: Accumulator, item: Item, index: number, array: Item[]) => Promise<Accumulator>,\n initialValue: Accumulator,\n): Promise<Accumulator> => {\n let accumulator = initialValue;\n\n for (let i = 0; i < array.length; i++) {\n accumulator = await fn(accumulator, array[i], i, array);\n }\n\n return accumulator;\n};\n\n/**\n * Asynchronously finds the first element that satisfies the async condition.\n *\n * @param array - The array of items to search.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to the found item or null if none match.\n */\nexport const findAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item | null> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return array[i];\n }\n }\n\n return null;\n};\n","/**\n * Converts a string to kebab-case format.\n *\n * This function transforms camelCase or PascalCase strings into kebab-case by inserting\n * hyphens between lowercase and uppercase letters, then converting everything to lowercase.\n *\n * @param input - The string to convert to kebab-case.\n *\n * @returns The kebab-case formatted string.\n *\n * @example\n * ```ts\n * toKebabCase('helloWorld'); // → 'hello-world'\n * toKebabCase('HelloWorld'); // → 'hello-world'\n * toKebabCase('hello123World'); // → 'hello123-world'\n * ```\n */\nexport const toKebabCase = (input: string): string =>\n input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Converts a camelCase string to dash-case format.\n *\n * This function transforms camelCase strings into dash-case by inserting\n * hyphens before uppercase letters and converting them to lowercase.\n * The function ensures that no hyphen is added at the start of the output string,\n * even if the input begins with an uppercase letter.\n *\n * @param input - The camelCase string to convert to dash-case.\n *\n * @returns The dash-case formatted string.\n *\n * @example\n * ```ts\n * camelToDashCase('helloWorld'); // → 'hello-world'\n * camelToDashCase('HelloWorld'); // → 'hello-world'\n * camelToDashCase('backgroundColor'); // → 'background-color'\n * ```\n */\nexport const camelToDashCase = (input: string): string => {\n // First handle the first character separately to avoid adding a hyphen at the start\n const firstChar = input.charAt(0);\n const restOfString = input.slice(1);\n \n // Convert the first character to lowercase without adding a hyphen\n const firstCharProcessed = firstChar.toLowerCase();\n \n // Process the rest of the string normally, adding hyphens before uppercase letters\n const restProcessed = restOfString.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);\n \n return firstCharProcessed + restProcessed;\n};\n\n/**\n * Splits a string into an array of filtered from redundant spaces words.\n *\n * @param input - The input string to be split.\n *\n * @returns An array of words from the input string.\n */\nexport const splitStringIntoWords = (input: string): string[] => input.split(' ').filter(Boolean);\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param input - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (input: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < input.length; i++) {\n hash = (hash * 33) ^ input.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends unknown[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n\n/**\n * Creates a promise that resolves after the specified delay.\n *\n * Useful for creating artificial delays, implementing timeouts, or spacing operations.\n *\n * @param delayMs - The delay in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n *\n * @example\n * ```ts\n * // Wait for 1 second\n * await delay(1000);\n * console.log('This logs after 1 second');\n *\n * // Use with other async operations\n * async function fetchWithTimeout() {\n * const timeoutPromise = delay(5000).then(() => {\n * throw new Error('Request timed out');\n * });\n *\n * return Promise.race([fetchData(), timeoutPromise]);\n * }\n * ```\n */\nexport const delay = (delayMs: number): Promise<void> =>\n new Promise(resolve => setTimeout(resolve, delayMs));\n\ninterface RetryOptions {\n /**\n * Maximum number of retry attempts before failing.\n *\n * @default 3\n */\n maxAttempts?: number;\n /**\n * Delay in milliseconds between retry attempts.\n * If `backoff` is true, this is the base delay for exponential backoff.\n *\n * @default 300\n */\n delayMs?: number;\n /**\n * Whether to use exponential backoff for delays between attempts.\n * When enabled, the delay is multiplied by 2 ^ (`attempt` - 1).\n *\n * @default true\n */\n backoff?: boolean;\n /**\n * Optional callback triggered before each retry attempt.\n *\n * @param attempt - The current attempt number (starting from 1).\n * @param error - The error that caused the retry.\n */\n onRetry?: (attempt: number, error: unknown) => void;\n}\n\n/**\n * Wraps an asynchronous function with retry logic.\n *\n * The returned function will attempt to call the original function up to `maxAttempts` times,\n * with a delay between retries. If all attempts fail, the last encountered error is thrown.\n *\n * Useful for operations that may fail intermittently, such as network requests.\n *\n * @template Task - The type of the async function to wrap.\n * @template TaskResult - The result type of the async function.\n *\n * @param task - The async function to wrap with retry logic.\n * @param options - Configuration options for retry behavior.\n *\n * @returns A function that wraps the original function with retry support.\n *\n * @example\n * ```ts\n * async function fetchData() {\n * const response = await fetch('/api/data');\n *\n * if (!response.ok) {\n * throw new Error('Network error');\n * }\n *\n * return await response.json();\n * }\n *\n * const fetchWithRetry = retry(fetchData, {\n * maxAttempts: 5,\n * delayMs: 500,\n * onRetry: (attempt, error) => {\n * console.warn(`Attempt ${attempt} failed:`, error);\n * }\n * });\n *\n * fetchWithRetry()\n * .then(data => console.log('Success:', data))\n * .catch(error => console.error('Failed after retries:', error));\n * ```\n */\nexport const retry = <Task extends (...args: unknown[]) => Promise<TaskResult>, TaskResult>(\n task: Task,\n { maxAttempts = 3, delayMs = 300, backoff = true, onRetry }: RetryOptions = {},\n): ((...args: Parameters<Task>) => Promise<TaskResult>) => {\n return async (...args: Parameters<Task>): Promise<TaskResult> => {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await task(...args);\n } catch (e) {\n lastError = e;\n\n if (attempt < maxAttempts) {\n onRetry?.(attempt, e);\n\n const delayTime = backoff ? delayMs * 2 ** (attempt - 1) : delayMs;\n await delay(delayTime);\n }\n }\n }\n\n throw lastError;\n };\n};\n","/**\n * Calculates the Euclidean distance between two points in 2D space.\n *\n * @param startX - The X coordinate of the starting point.\n * @param startY - The Y coordinate of the starting point.\n * @param endX - The X coordinate of the ending point.\n * @param endY - The Y coordinate of the ending point.\n *\n * @returns The Euclidean distance between the two points.\n */\nexport const calculateEuclideanDistance = (\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n): number => {\n const deltaX = endX - startX;\n const deltaY = endY - startY;\n\n return Math.hypot(deltaX, deltaY);\n};\n\n/**\n * Calculates the moving speed.\n *\n * @param distance - The distance.\n * @param elapsedTime - The time taken to move the distance.\n *\n * @returns The calculated speed, which is the absolute value of delta divided by elapsed time.\n */\nexport const calculateMovingSpeed = (distance: number, elapsedTime: number): number =>\n Math.abs(distance / elapsedTime);\n\n/**\n * Calculates the specified percentage of a given value.\n *\n * @param value - The value to calculate the percentage of.\n * @param percentage - The percentage to calculate.\n *\n * @returns The calculated percentage of the value.\n */\nexport const calculatePercentage = (value: number, percentage: number): number => {\n return (value * percentage) / 100;\n};\n","interface HTMLElementTransformationValues {\n translateX: number;\n translateY: number;\n scaleX: number;\n scaleY: number;\n skewX: number;\n skewY: number;\n}\n\n/**\n * Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.\n *\n * Only works with 2D transforms (i.e., `matrix(a, b, c, d, e, f)`).\n *\n * @param element - The element with a CSS transform applied.\n * @returns An object with parsed transformation values.\n *\n * @example\n * ```ts\n * const values = parse2DMatrix(myElement);\n * console.log(values.translateX);\n * console.log(values.scaleX);\n * ```\n */\nexport const parse2DMatrix = (element: HTMLElement): HTMLElementTransformationValues => {\n const computedStyles = window.getComputedStyle(element);\n const transformValue = computedStyles.getPropertyValue('transform');\n\n const matrixMatch = transformValue.match(/^matrix\\((.+)\\)$/);\n if (!matrixMatch) {\n return {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n skewX: 0,\n skewY: 0,\n };\n }\n\n const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrixMatch[1]\n .split(', ')\n .map(parseFloat);\n\n return {\n translateX,\n translateY,\n scaleX,\n scaleY,\n skewX,\n skewY,\n };\n};\n\n/**\n * Creates a clone of a Blob object.\n *\n * @param blob - The Blob object to clone.\n *\n * @returns A new Blob with the same content and type as the original.\n */\nexport const cloneBlob = (blob: Blob): Blob => new Blob([blob], { type: blob.type });\n\n/**\n * Converts a `Blob` object into a `File` object with the specified name.\n *\n * This is useful when you receive a `Blob` (e.g., from canvas, fetch, or file manipulation)\n * and need to convert it into a `File` to upload via `FormData` or file inputs.\n *\n * @param blob - The `Blob` to convert.\n * @param fileName - The desired name for the resulting file (including extension).\n *\n * @returns A `File` instance with the same content and MIME type as the input `Blob`.\n *\n * @example\n * ```ts\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const file = convertBlobToFile(blob, 'hello.txt');\n *\n * console.log(file instanceof File); // true\n * ```\n */\nexport const convertBlobToFile = (blob: Blob, fileName: string): File =>\n new File([blob], fileName, {\n type: blob.type,\n });\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","assert","condition","message","Error","isNull","isNil","isNilOrEmptyString","isDefined","isString","isNumber","isBool","isObject","isEmptyObject","keys","length","isArray","Array","isEmptyArray","isFunction","isPromise","then","isDate","Date","isValidDate","isNaN","getTime","isRegExp","RegExp","isMap","Map","isSet","Set","isSymbol","isUndefined","undefined","isFiniteNumber","isFinite","isInteger","Number","compact","array","filter","Boolean","unique","chunk","size","from","Math","ceil","_","index","slice","intersection","arrays","first","rest","item","every","includes","difference","exclude","pipe","fns","arg","reduce","prev","fn","compose","reduceRight","runSequential","async","results","i","push","runParallel","Promise","all","map","filterSequential","predicate","filterParallel","someAsync","everyAsync","reduceAsync","initialValue","accumulator","findAsync","toKebabCase","input","replace","toLowerCase","camelToDashCase","firstChar","charAt","restOfString","letter","splitStringIntoWords","split","hashString","hash","charCodeAt","toString","noop","invokeIfFunction","args","delay","delayMs","resolve","setTimeout","retry","task","maxAttempts","backoff","onRetry","lastError","attempt","e","delayTime","calculateEuclideanDistance","startX","startY","endX","endY","deltaX","deltaY","hypot","calculateMovingSpeed","distance","elapsedTime","abs","calculatePercentage","percentage","parse2DMatrix","element","matrixMatch","window","getComputedStyle","getPropertyValue","match","translateX","translateY","scaleX","scaleY","skewX","skewY","parseFloat","cloneBlob","blob","Blob","type","convertBlobToFile","fileName","File"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,KCLhD,SAASC,EAAOC,EAAgBC,GACrC,IAAKD,EACH,MAAM,IAAIE,MAAMD,EAEpB,C,k+BASO,MAAME,EAAUL,GAA4C,OAAVA,EAS5CM,EAASN,GACpBA,QAcWO,EAAsBP,GACvB,KAAVA,GAAgBM,EAAMN,GASXQ,EAAgBR,GAC3BA,QASWS,EAAYT,GAAqD,iBAAVA,EASvDU,EAAYV,GAAqD,iBAAVA,EASvDW,EAAUX,GAAsD,kBAAVA,EAStDY,EAAYZ,GAAqD,iBAAVA,EASvDa,EAAiBb,GAC5BY,EAASZ,KAAWK,EAAOL,IAAwC,IAA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iC,WAAYjC,EAAQkC,UAAWlC,EAAQmC,YAAanC,EAAQoC,c","sources":["webpack://@react-hive/honey-utils/webpack/bootstrap","webpack://@react-hive/honey-utils/webpack/runtime/define property getters","webpack://@react-hive/honey-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-utils/webpack/runtime/make namespace object","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/async.ts","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/math.ts","webpack://@react-hive/honey-utils/./src/dom.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n\n/**\n * Checks if a value is null.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is null; otherwise, `false`.\n */\nexport const isNull = (value: unknown): value is null => value === null;\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n\n/**\n * Checks whether the provided value is considered \"empty\".\n *\n * A value is considered empty if it is:\n * - `null`\n * - `undefined`\n * - `''`\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is empty; otherwise, `false`.\n */\nexport const isNilOrEmptyString = (value: unknown): value is null | undefined =>\n value === '' || isNil(value);\n\n/**\n * Checks if a value is neither `null` nor `undefined`.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is defined (not `null` or `undefined`); otherwise, `false`.\n */\nexport const isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== null && value !== undefined;\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a string; otherwise, `false`.\n */\nexport const isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Checks if a value is a number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a number; otherwise, `false`.\n */\nexport const isNumber = (value: unknown): value is number => typeof value === 'number';\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a boolean; otherwise, `false`.\n */\nexport const isBool = (value: unknown): value is boolean => typeof value === 'boolean';\n\n/**\n * Checks if a value is an object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an object; otherwise, `false`.\n */\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\n/**\n * Checks if a value is an empty object (no own enumerable properties).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty object; otherwise, `false`.\n */\nexport const isEmptyObject = (value: unknown): value is Record<string, never> =>\n isObject(value) && !isNull(value) && Object.keys(value).length === 0;\n\n/**\n * Checks if a value is an array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an array; otherwise, `false`.\n */\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n\n/**\n * Checks if a value is an empty array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty array; otherwise, `false`.\n */\nexport const isEmptyArray = (value: unknown): value is [] => isArray(value) && value.length === 0;\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a function; otherwise, `false`.\n */\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is a Promise.\n *\n * @template T - The type of the value that the Promise resolves to.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Promise; otherwise, `false`.\n */\nexport const isPromise = <T = unknown>(value: unknown): value is Promise<T> =>\n isFunction((value as Promise<T>)?.then);\n\n/**\n * Checks if a value is a Date object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Date object; otherwise, `false`.\n */\nexport const isDate = (value: unknown): value is Date => value instanceof Date;\n\n/**\n * Checks if a value is a valid Date object (not Invalid Date).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a valid Date object; otherwise, `false`.\n */\nexport const isValidDate = (value: unknown): value is Date =>\n isDate(value) && !isNaN(value.getTime());\n\n/**\n * Checks if a value is a RegExp object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a RegExp object; otherwise, `false`.\n */\nexport const isRegExp = (value: unknown): value is RegExp => value instanceof RegExp;\n\n/**\n * Checks if a value is a Map.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Map; otherwise, `false`.\n */\nexport const isMap = (value: unknown): value is Map<unknown, unknown> => value instanceof Map;\n\n/**\n * Checks if a value is a Set.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Set; otherwise, `false`.\n */\nexport const isSet = (value: unknown): value is Set<unknown> => value instanceof Set;\n\n/**\n * Checks if a value is a Symbol.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Symbol; otherwise, `false`.\n */\nexport const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol';\n\n/**\n * Checks if a value is undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is undefined; otherwise, `false`.\n */\nexport const isUndefined = (value: unknown): value is undefined => value === undefined;\n\n/**\n * Checks if a value is a finite number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a finite number; otherwise, `false`.\n */\nexport const isFiniteNumber = (value: unknown): value is number =>\n isNumber(value) && isFinite(value);\n\n/**\n * Checks if a value is an integer.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an integer; otherwise, `false`.\n */\nexport const isInteger = (value: unknown): value is number =>\n isNumber(value) && Number.isInteger(value);\n","import { assert } from './guards';\n\n/**\n * Represents all falsy values.\n */\ntype Falsy = false | null | undefined | 0 | '';\n\n/**\n * Removes all falsy values from an array.\n *\n * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.\n *\n * Useful for cleaning up arrays with optional, nullable, or conditionally included items.\n *\n * @template T - The type of the truthy items.\n *\n * @param array - An array possibly containing falsy values.\n *\n * @returns A new array containing only truthy values of type `T`.\n *\n * @example\n * ```ts\n * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]\n * ```\n */\nexport const compact = <T>(array: (T | Falsy)[]): T[] => array.filter(Boolean) as T[];\n\n/**\n * Returns a new array with duplicate values removed.\n *\n * Uses Set for efficient duplicate removal while preserving the original order.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array that may contain duplicate values.\n *\n * @returns A new array with only unique values, maintaining the original order.\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]\n * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']\n * ```\n */\nexport const unique = <T>(array: T[]): T[] => [...new Set(array)];\n\n/**\n * Splits an array into chunks of the specified size.\n *\n * Useful for pagination, batch processing, or creating grid layouts.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array to be chunked.\n * @param size - The size of each chunk. Must be greater than 0.\n *\n * @returns An array of chunks, where each chunk is an array of the specified size\n * (except possibly the last chunk, which may be smaller).\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]\n * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]\n * ```\n */\nexport const chunk = <T>(array: T[], size: number): T[][] => {\n assert(size > 0, 'Chunk size must be greater than 0');\n\n return Array.from({ length: Math.ceil(array.length / size) }, (_, index) =>\n array.slice(index * size, (index + 1) * size),\n );\n};\n\n/**\n * Returns an array containing elements that exist in all provided arrays.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param arrays - Two or more arrays to find common elements from.\n *\n * @returns A new array containing only the elements that exist in all input arrays.\n *\n * @example\n * ```ts\n * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]\n * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']\n * ```\n */\nexport const intersection = <T>(...arrays: T[][]): T[] => {\n if (arrays.length === 0) {\n return [];\n }\n\n if (arrays.length === 1) {\n return [...arrays[0]];\n }\n\n const [first, ...rest] = arrays;\n const uniqueFirst = unique(first);\n\n return uniqueFirst.filter(item => rest.every(array => array.includes(item)));\n};\n\n/**\n * Returns elements from the first array that don't exist in the second array.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param array - The source array.\n * @param exclude - The array containing elements to exclude.\n *\n * @returns A new array with elements from the first array that don't exist in the second array.\n *\n * @example\n * ```ts\n * difference([1, 2, 3, 4], [2, 4]); // [1, 3]\n * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']\n * ```\n */\nexport const difference = <T>(array: T[], exclude: T[]): T[] =>\n array.filter(item => !exclude.includes(item));\n\ntype PipeFn = (arg: unknown) => unknown;\n\ntype Pipe = {\n <A, B>(fn1: (a: A) => B): (a: A) => B;\n <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;\n <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;\n <A, B, C, D, E>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n ): (a: A) => E;\n <A, B, C, D, E, F>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n fn5: (e: E) => F,\n ): (a: A) => F;\n (...fns: PipeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from left to right.\n *\n * Useful for building a data processing pipeline where the output of one function becomes the input of the next.\n *\n * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from left to right.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = pipe(add, double, toStr)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const pipe: Pipe =\n (...fns: PipeFn[]) =>\n (arg: unknown) =>\n fns.reduce((prev, fn) => fn(prev), arg);\n\ntype ComposeFn = (arg: unknown) => unknown;\n\ntype Compose = {\n <A, R>(fn1: (a: A) => R): (a: A) => R;\n <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;\n <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;\n <A, B, C, D, R>(\n fn1: (d: D) => R,\n fn2: (c: C) => D,\n fn3: (b: B) => C,\n fn4: (a: A) => B,\n ): (a: A) => R;\n <A, B, C, D, E, R>(\n fn1: (e: E) => R,\n fn2: (d: D) => E,\n fn3: (c: C) => D,\n fn4: (b: B) => C,\n fn5: (a: A) => B,\n ): (a: A) => R;\n (...fns: ComposeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from **right to left**.\n *\n * Often used for building functional pipelines where the innermost function runs first.\n * Types are inferred up to 5 chained functions for full type safety.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from right to left.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = compose(toStr, double, add)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const compose: Compose =\n (...fns: ComposeFn[]) =>\n (arg: unknown) =>\n fns.reduceRight((prev, fn) => fn(prev), arg);\n","import { compact } from './array';\n\n/**\n * Asynchronously iterates over an array and executes an async function on each item sequentially,\n * collecting the results.\n *\n * Useful when order or timing matters (e.g., rate limits, UI updates, animations).\n *\n * @param array - The array of items to iterate over.\n * @param fn - An async function to execute for each item. Must return a value.\n *\n * @returns A promise that resolves with an array of results from each function call.\n *\n * @example\n * ```ts\n * const results = await runSequential([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runSequential = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => {\n const results: Result[] = [];\n\n for (let i = 0; i < array.length; i++) {\n results.push(await fn(array[i], i, array));\n }\n\n return results;\n};\n\n/**\n * Executes an asynchronous operation on each element of an array and waits for all promises to resolve.\n *\n * @param array - The array of items to operate on.\n * @param fn - The asynchronous operation to perform on each item.\n *\n * @returns A promise that resolves with an array of results after all operations are completed.\n *\n * @example\n * ```ts\n * const results = await runParallel([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runParallel = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => Promise.all(array.map(fn));\n\n/**\n * Asynchronously filters an array using a predicate function, executing **sequentially**.\n *\n * Useful for rate-limited or stateful async operations where execution order matters.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a `boolean` indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Sequentially filter even numbers with delay\n * const result = await filterSequential([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterSequential = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results: Item[] = [];\n\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n\n if (await predicate(item, i, array)) {\n results.push(item);\n }\n }\n\n return results;\n};\n\n/**\n * Asynchronously filters an array based on a provided async predicate function.\n *\n * Each item is passed to the `predicate` function in parallel, and only the items\n * for which the predicate resolves to `true` are included in the final result.\n *\n * Useful for filtering based on asynchronous conditions such as API calls,\n * file system access, or any other delayed operations.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a boolean indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Filter numbers that are even after a simulated delay\n * const result = await filterParallel([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterParallel = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results = await runParallel(array, async (item, index, array) =>\n (await predicate(item, index, array)) ? item : false,\n );\n\n return compact(results);\n};\n\n/**\n * Asynchronously checks if at least one element in the array satisfies the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if any item passes the condition.\n */\nexport const someAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Asynchronously checks if all elements in the array satisfy the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if all items pass the condition.\n */\nexport const everyAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (!(await predicate(array[i], i, array))) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Asynchronously reduces an array to a single accumulated value.\n *\n * @template Item - The type of items in the array.\n * @template Accumulator - The type of the accumulated result.\n *\n * @param array - The array to reduce.\n * @param fn - The async reducer function that processes each item and returns the updated accumulator.\n * @param initialValue - The initial accumulator value.\n *\n * @returns A promise that resolves to the final accumulated result.\n */\nexport const reduceAsync = async <Item, Accumulator>(\n array: Item[],\n fn: (accumulator: Accumulator, item: Item, index: number, array: Item[]) => Promise<Accumulator>,\n initialValue: Accumulator,\n): Promise<Accumulator> => {\n let accumulator = initialValue;\n\n for (let i = 0; i < array.length; i++) {\n accumulator = await fn(accumulator, array[i], i, array);\n }\n\n return accumulator;\n};\n\n/**\n * Asynchronously finds the first element that satisfies the async condition.\n *\n * @param array - The array of items to search.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to the found item or null if none match.\n */\nexport const findAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item | null> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return array[i];\n }\n }\n\n return null;\n};\n","/**\n * Converts a string to kebab-case format.\n *\n * This function transforms camelCase or PascalCase strings into kebab-case by inserting\n * hyphens between lowercase and uppercase letters, then converting everything to lowercase.\n *\n * @param input - The string to convert to kebab-case.\n *\n * @returns The kebab-case formatted string.\n *\n * @example\n * ```ts\n * toKebabCase('helloWorld'); // → 'hello-world'\n * toKebabCase('HelloWorld'); // → 'hello-world'\n * toKebabCase('hello123World'); // → 'hello123-world'\n * ```\n */\nexport const toKebabCase = (input: string): string =>\n input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Converts a camelCase string to dash-case format.\n *\n * This function transforms camelCase strings into dash-case by inserting\n * hyphens before uppercase letters and converting them to lowercase.\n * The function ensures that no hyphen is added at the start of the output string,\n * even if the input begins with an uppercase letter.\n *\n * @param input - The camelCase string to convert to dash-case.\n *\n * @returns The dash-case formatted string.\n *\n * @example\n * ```ts\n * camelToDashCase('helloWorld'); // → 'hello-world'\n * camelToDashCase('HelloWorld'); // → 'hello-world'\n * camelToDashCase('backgroundColor'); // → 'background-color'\n * ```\n */\nexport const camelToDashCase = (input: string): string => {\n // First handle the first character separately to avoid adding a hyphen at the start\n const firstChar = input.charAt(0);\n const restOfString = input.slice(1);\n \n // Convert the first character to lowercase without adding a hyphen\n const firstCharProcessed = firstChar.toLowerCase();\n \n // Process the rest of the string normally, adding hyphens before uppercase letters\n const restProcessed = restOfString.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);\n \n return firstCharProcessed + restProcessed;\n};\n\n/**\n * Splits a string into an array of filtered from redundant spaces words.\n *\n * @param input - The input string to be split.\n *\n * @returns An array of words from the input string.\n */\nexport const splitStringIntoWords = (input: string): string[] => input.split(' ').filter(Boolean);\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param input - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (input: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < input.length; i++) {\n hash = (hash * 33) ^ input.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends unknown[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n\n/**\n * Creates a promise that resolves after the specified delay.\n *\n * Useful for creating artificial delays, implementing timeouts, or spacing operations.\n *\n * @param delayMs - The delay in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n *\n * @example\n * ```ts\n * // Wait for 1 second\n * await delay(1000);\n * console.log('This logs after 1 second');\n *\n * // Use with other async operations\n * async function fetchWithTimeout() {\n * const timeoutPromise = delay(5000).then(() => {\n * throw new Error('Request timed out');\n * });\n *\n * return Promise.race([fetchData(), timeoutPromise]);\n * }\n * ```\n */\nexport const delay = (delayMs: number): Promise<void> =>\n new Promise(resolve => setTimeout(resolve, delayMs));\n\n/**\n * Wraps a promise with a timeout. If the promise does not settle within the specified time,\n * it will reject with a timeout error.\n *\n * @template T - The type of the promise result.\n *\n * @param promise - The promise to wrap.\n * @param timeoutMs - Timeout duration in milliseconds.\n * @param errorMessage - Optional custom error message.\n *\n * @returns A promise that resolves or rejects with the original promise,\n * or rejects with a timeout error if the duration is exceeded.\n *\n * @example\n * ```ts\n * // Rejects if fetch takes longer than 3 seconds\n * const response = await timeout(fetch('/api/data'), 3000);\n *\n * // With custom message\n * await timeout(fetchData(), 2000, 'Too long');\n * ```\n */\nexport const timeout = async <T>(\n promise: Promise<T>,\n timeoutMs: number,\n errorMessage = 'Operation timed out',\n): Promise<T> => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(errorMessage)), timeoutMs);\n });\n\n try {\n return await Promise.race([promise, timeoutPromise]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n};\n\ninterface RetryOptions {\n /**\n * Maximum number of retry attempts before failing.\n *\n * @default 3\n */\n maxAttempts?: number;\n /**\n * Delay in milliseconds between retry attempts.\n * If `backoff` is true, this is the base delay for exponential backoff.\n *\n * @default 300\n */\n delayMs?: number;\n /**\n * Whether to use exponential backoff for delays between attempts.\n * When enabled, the delay is multiplied by 2 ^ (`attempt` - 1).\n *\n * @default true\n */\n backoff?: boolean;\n /**\n * Optional callback triggered before each retry attempt.\n *\n * @param attempt - The current attempt number (starting from 1).\n * @param error - The error that caused the retry.\n */\n onRetry?: (attempt: number, error: unknown) => void;\n}\n\n/**\n * Wraps an asynchronous function with retry logic.\n *\n * The returned function will attempt to call the original function up to `maxAttempts` times,\n * with a delay between retries. If all attempts fail, the last encountered error is thrown.\n *\n * Useful for operations that may fail intermittently, such as network requests.\n *\n * @template Task - The type of the async function to wrap.\n * @template TaskResult - The result type of the async function.\n *\n * @param task - The async function to wrap with retry logic.\n * @param options - Configuration options for retry behavior.\n *\n * @returns A function that wraps the original function with retry support.\n *\n * @example\n * ```ts\n * async function fetchData() {\n * const response = await fetch('/api/data');\n *\n * if (!response.ok) {\n * throw new Error('Network error');\n * }\n *\n * return await response.json();\n * }\n *\n * const fetchWithRetry = retry(fetchData, {\n * maxAttempts: 5,\n * delayMs: 500,\n * onRetry: (attempt, error) => {\n * console.warn(`Attempt ${attempt} failed:`, error);\n * }\n * });\n *\n * fetchWithRetry()\n * .then(data => console.log('Success:', data))\n * .catch(error => console.error('Failed after retries:', error));\n * ```\n */\nexport const retry = <Task extends (...args: unknown[]) => Promise<TaskResult>, TaskResult>(\n task: Task,\n { maxAttempts = 3, delayMs = 300, backoff = true, onRetry }: RetryOptions = {},\n): ((...args: Parameters<Task>) => Promise<TaskResult>) => {\n return async (...args: Parameters<Task>): Promise<TaskResult> => {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await task(...args);\n } catch (e) {\n lastError = e;\n\n if (attempt < maxAttempts) {\n onRetry?.(attempt, e);\n\n const delayTime = backoff ? delayMs * 2 ** (attempt - 1) : delayMs;\n await delay(delayTime);\n }\n }\n }\n\n throw lastError;\n };\n};\n","/**\n * Calculates the Euclidean distance between two points in 2D space.\n *\n * @param startX - The X coordinate of the starting point.\n * @param startY - The Y coordinate of the starting point.\n * @param endX - The X coordinate of the ending point.\n * @param endY - The Y coordinate of the ending point.\n *\n * @returns The Euclidean distance between the two points.\n */\nexport const calculateEuclideanDistance = (\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n): number => {\n const deltaX = endX - startX;\n const deltaY = endY - startY;\n\n return Math.hypot(deltaX, deltaY);\n};\n\n/**\n * Calculates the moving speed.\n *\n * @param distance - The distance.\n * @param elapsedTime - The time taken to move the distance.\n *\n * @returns The calculated speed, which is the absolute value of delta divided by elapsed time.\n */\nexport const calculateMovingSpeed = (distance: number, elapsedTime: number): number =>\n Math.abs(distance / elapsedTime);\n\n/**\n * Calculates the specified percentage of a given value.\n *\n * @param value - The value to calculate the percentage of.\n * @param percentage - The percentage to calculate.\n *\n * @returns The calculated percentage of the value.\n */\nexport const calculatePercentage = (value: number, percentage: number): number => {\n return (value * percentage) / 100;\n};\n","interface HTMLElementTransformationValues {\n translateX: number;\n translateY: number;\n scaleX: number;\n scaleY: number;\n skewX: number;\n skewY: number;\n}\n\n/**\n * Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.\n *\n * Only works with 2D transforms (i.e., `matrix(a, b, c, d, e, f)`).\n *\n * @param element - The element with a CSS transform applied.\n * @returns An object with parsed transformation values.\n *\n * @example\n * ```ts\n * const values = parse2DMatrix(myElement);\n * console.log(values.translateX);\n * console.log(values.scaleX);\n * ```\n */\nexport const parse2DMatrix = (element: HTMLElement): HTMLElementTransformationValues => {\n const computedStyles = window.getComputedStyle(element);\n const transformValue = computedStyles.getPropertyValue('transform');\n\n const matrixMatch = transformValue.match(/^matrix\\((.+)\\)$/);\n if (!matrixMatch) {\n return {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n skewX: 0,\n skewY: 0,\n };\n }\n\n const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrixMatch[1]\n .split(', ')\n .map(parseFloat);\n\n return {\n translateX,\n translateY,\n scaleX,\n scaleY,\n skewX,\n skewY,\n };\n};\n\n/**\n * Creates a clone of a Blob object.\n *\n * @param blob - The Blob object to clone.\n *\n * @returns A new Blob with the same content and type as the original.\n */\nexport const cloneBlob = (blob: Blob): Blob => new Blob([blob], { type: blob.type });\n\n/**\n * Converts a `Blob` object into a `File` object with the specified name.\n *\n * This is useful when you receive a `Blob` (e.g., from canvas, fetch, or file manipulation)\n * and need to convert it into a `File` to upload via `FormData` or file inputs.\n *\n * @param blob - The `Blob` to convert.\n * @param fileName - The desired name for the resulting file (including extension).\n *\n * @returns A `File` instance with the same content and MIME type as the input `Blob`.\n *\n * @example\n * ```ts\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const file = convertBlobToFile(blob, 'hello.txt');\n *\n * console.log(file instanceof File); // true\n * ```\n */\nexport const convertBlobToFile = (blob: Blob, fileName: string): File =>\n new File([blob], fileName, {\n type: blob.type,\n });\n\n/**\n * Calculates the intersection ratio between two DOM rectangles.\n *\n * The ratio represents the proportion of the `targetRect` that is covered by `sourceRect`.\n * A value of `1` means `sourceRect` completely covers `targetRect`, and `0` means no overlap.\n *\n * @param sourceRect - The rectangle used to measure overlap against the target.\n * @param targetRect - The rectangle whose covered area is measured.\n *\n * @returns A number between `0` and `1` representing the intersection ratio.\n */\nexport const getDOMRectIntersectionRatio = (sourceRect: DOMRect, targetRect: DOMRect): number => {\n const xOverlap = Math.max(\n 0,\n Math.min(sourceRect.right, targetRect.right) - Math.max(sourceRect.left, targetRect.left),\n );\n\n const yOverlap = Math.max(\n 0,\n Math.min(sourceRect.bottom, targetRect.bottom) - Math.max(sourceRect.top, targetRect.top),\n );\n\n const intersectionArea = xOverlap * yOverlap;\n const targetArea = targetRect.width * targetRect.height;\n\n return intersectionArea / targetArea;\n};\n\n/**\n * Returns the bounding DOMRect of an element based on offset and client dimensions.\n *\n * This utility is useful when you need a stable, layout-based rect\n * without triggering a reflow via `getBoundingClientRect()`.\n *\n * @param element - The target HTML element.\n * @returns A `DOMRect` representing the element’s offset position and size.\n */\nexport const getElementOffsetRect = (element: HTMLElement): DOMRect =>\n new DOMRect(element.offsetLeft, element.offsetTop, element.clientWidth, element.clientHeight);\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","assert","condition","message","Error","isNull","isNil","isNilOrEmptyString","isDefined","isString","isNumber","isBool","isObject","isEmptyObject","keys","length","isArray","Array","isEmptyArray","isFunction","isPromise","then","isDate","Date","isValidDate","isNaN","getTime","isRegExp","RegExp","isMap","Map","isSet","Set","isSymbol","isUndefined","undefined","isFiniteNumber","isFinite","isInteger","Number","compact","array","filter","Boolean","unique","chunk","size","from","Math","ceil","_","index","slice","intersection","arrays","first","rest","item","every","includes","difference","exclude","pipe","fns","arg","reduce","prev","fn","compose","reduceRight","runSequential","async","results","i","push","runParallel","Promise","all","map","filterSequential","predicate","filterParallel","someAsync","everyAsync","reduceAsync","initialValue","accumulator","findAsync","toKebabCase","input","replace","toLowerCase","camelToDashCase","firstChar","charAt","restOfString","letter","splitStringIntoWords","split","hashString","hash","charCodeAt","toString","noop","invokeIfFunction","args","delay","delayMs","resolve","setTimeout","timeout","promise","timeoutMs","errorMessage","timeoutId","timeoutPromise","reject","race","clearTimeout","retry","task","maxAttempts","backoff","onRetry","lastError","attempt","e","delayTime","calculateEuclideanDistance","startX","startY","endX","endY","deltaX","deltaY","hypot","calculateMovingSpeed","distance","elapsedTime","abs","calculatePercentage","percentage","parse2DMatrix","element","matrixMatch","window","getComputedStyle","getPropertyValue","match","translateX","translateY","scaleX","scaleY","skewX","skewY","parseFloat","cloneBlob","blob","Blob","type","convertBlobToFile","fileName","File","getDOMRectIntersectionRatio","sourceRect","targetRect","max","min","right","left","bottom","top","width","height","getElementOffsetRect","DOMRect","offsetLeft","offsetTop","clientWidth","clientHeight"],"sourceRoot":""}
|
package/dist/index.dev.cjs
CHANGED
|
@@ -385,6 +385,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
385
385
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
386
386
|
/* harmony export */ cloneBlob: () => (/* binding */ cloneBlob),
|
|
387
387
|
/* harmony export */ convertBlobToFile: () => (/* binding */ convertBlobToFile),
|
|
388
|
+
/* harmony export */ getDOMRectIntersectionRatio: () => (/* binding */ getDOMRectIntersectionRatio),
|
|
389
|
+
/* harmony export */ getElementOffsetRect: () => (/* binding */ getElementOffsetRect),
|
|
388
390
|
/* harmony export */ parse2DMatrix: () => (/* binding */ parse2DMatrix)
|
|
389
391
|
/* harmony export */ });
|
|
390
392
|
/**
|
|
@@ -458,6 +460,34 @@ const cloneBlob = (blob) => new Blob([blob], { type: blob.type });
|
|
|
458
460
|
const convertBlobToFile = (blob, fileName) => new File([blob], fileName, {
|
|
459
461
|
type: blob.type,
|
|
460
462
|
});
|
|
463
|
+
/**
|
|
464
|
+
* Calculates the intersection ratio between two DOM rectangles.
|
|
465
|
+
*
|
|
466
|
+
* The ratio represents the proportion of the `targetRect` that is covered by `sourceRect`.
|
|
467
|
+
* A value of `1` means `sourceRect` completely covers `targetRect`, and `0` means no overlap.
|
|
468
|
+
*
|
|
469
|
+
* @param sourceRect - The rectangle used to measure overlap against the target.
|
|
470
|
+
* @param targetRect - The rectangle whose covered area is measured.
|
|
471
|
+
*
|
|
472
|
+
* @returns A number between `0` and `1` representing the intersection ratio.
|
|
473
|
+
*/
|
|
474
|
+
const getDOMRectIntersectionRatio = (sourceRect, targetRect) => {
|
|
475
|
+
const xOverlap = Math.max(0, Math.min(sourceRect.right, targetRect.right) - Math.max(sourceRect.left, targetRect.left));
|
|
476
|
+
const yOverlap = Math.max(0, Math.min(sourceRect.bottom, targetRect.bottom) - Math.max(sourceRect.top, targetRect.top));
|
|
477
|
+
const intersectionArea = xOverlap * yOverlap;
|
|
478
|
+
const targetArea = targetRect.width * targetRect.height;
|
|
479
|
+
return intersectionArea / targetArea;
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* Returns the bounding DOMRect of an element based on offset and client dimensions.
|
|
483
|
+
*
|
|
484
|
+
* This utility is useful when you need a stable, layout-based rect
|
|
485
|
+
* without triggering a reflow via `getBoundingClientRect()`.
|
|
486
|
+
*
|
|
487
|
+
* @param element - The target HTML element.
|
|
488
|
+
* @returns A `DOMRect` representing the element’s offset position and size.
|
|
489
|
+
*/
|
|
490
|
+
const getElementOffsetRect = (element) => new DOMRect(element.offsetLeft, element.offsetTop, element.clientWidth, element.clientHeight);
|
|
461
491
|
|
|
462
492
|
|
|
463
493
|
/***/ }),
|
|
@@ -473,7 +503,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
473
503
|
/* harmony export */ delay: () => (/* binding */ delay),
|
|
474
504
|
/* harmony export */ invokeIfFunction: () => (/* binding */ invokeIfFunction),
|
|
475
505
|
/* harmony export */ noop: () => (/* binding */ noop),
|
|
476
|
-
/* harmony export */ retry: () => (/* binding */ retry)
|
|
506
|
+
/* harmony export */ retry: () => (/* binding */ retry),
|
|
507
|
+
/* harmony export */ timeout: () => (/* binding */ timeout)
|
|
477
508
|
/* harmony export */ });
|
|
478
509
|
const noop = () => { };
|
|
479
510
|
/**
|
|
@@ -515,6 +546,42 @@ const invokeIfFunction = (input, ...args) => (typeof input === 'function' ? inpu
|
|
|
515
546
|
* ```
|
|
516
547
|
*/
|
|
517
548
|
const delay = (delayMs) => new Promise(resolve => setTimeout(resolve, delayMs));
|
|
549
|
+
/**
|
|
550
|
+
* Wraps a promise with a timeout. If the promise does not settle within the specified time,
|
|
551
|
+
* it will reject with a timeout error.
|
|
552
|
+
*
|
|
553
|
+
* @template T - The type of the promise result.
|
|
554
|
+
*
|
|
555
|
+
* @param promise - The promise to wrap.
|
|
556
|
+
* @param timeoutMs - Timeout duration in milliseconds.
|
|
557
|
+
* @param errorMessage - Optional custom error message.
|
|
558
|
+
*
|
|
559
|
+
* @returns A promise that resolves or rejects with the original promise,
|
|
560
|
+
* or rejects with a timeout error if the duration is exceeded.
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```ts
|
|
564
|
+
* // Rejects if fetch takes longer than 3 seconds
|
|
565
|
+
* const response = await timeout(fetch('/api/data'), 3000);
|
|
566
|
+
*
|
|
567
|
+
* // With custom message
|
|
568
|
+
* await timeout(fetchData(), 2000, 'Too long');
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
const timeout = async (promise, timeoutMs, errorMessage = 'Operation timed out') => {
|
|
572
|
+
let timeoutId = null;
|
|
573
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
574
|
+
timeoutId = setTimeout(() => reject(new Error(errorMessage)), timeoutMs);
|
|
575
|
+
});
|
|
576
|
+
try {
|
|
577
|
+
return await Promise.race([promise, timeoutPromise]);
|
|
578
|
+
}
|
|
579
|
+
finally {
|
|
580
|
+
if (timeoutId) {
|
|
581
|
+
clearTimeout(timeoutId);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
};
|
|
518
585
|
/**
|
|
519
586
|
* Wraps an asynchronous function with retry logic.
|
|
520
587
|
*
|
|
@@ -1037,6 +1104,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1037
1104
|
/* harmony export */ filterParallel: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.filterParallel),
|
|
1038
1105
|
/* harmony export */ filterSequential: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.filterSequential),
|
|
1039
1106
|
/* harmony export */ findAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.findAsync),
|
|
1107
|
+
/* harmony export */ getDOMRectIntersectionRatio: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.getDOMRectIntersectionRatio),
|
|
1108
|
+
/* harmony export */ getElementOffsetRect: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.getElementOffsetRect),
|
|
1040
1109
|
/* harmony export */ hashString: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.hashString),
|
|
1041
1110
|
/* harmony export */ intersection: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.intersection),
|
|
1042
1111
|
/* harmony export */ invokeIfFunction: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_3__.invokeIfFunction),
|
|
@@ -1071,6 +1140,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1071
1140
|
/* harmony export */ runSequential: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.runSequential),
|
|
1072
1141
|
/* harmony export */ someAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.someAsync),
|
|
1073
1142
|
/* harmony export */ splitStringIntoWords: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.splitStringIntoWords),
|
|
1143
|
+
/* harmony export */ timeout: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_3__.timeout),
|
|
1074
1144
|
/* harmony export */ toKebabCase: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.toKebabCase),
|
|
1075
1145
|
/* harmony export */ unique: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.unique)
|
|
1076
1146
|
/* harmony export */ });
|
package/dist/index.dev.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.dev.cjs","mappings":";;;;;;;;;;;;;;;;;;;;;AAAkC;AAOlC;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,OAAO,GAAG,CAAI,KAAoB,EAAO,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;AAEtF;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,M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jF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACNwB;AACC;AACD;AACG;AACF;AACF;AACD","sources":["webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/async.ts","webpack://@react-hive/honey-utils/./src/dom.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/math.ts","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/webpack/bootstrap","webpack://@react-hive/honey-utils/webpack/runtime/define property getters","webpack://@react-hive/honey-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-utils/webpack/runtime/make namespace object","webpack://@react-hive/honey-utils/./src/index.ts"],"sourcesContent":["import { assert } from './guards';\n\n/**\n * Represents all falsy values.\n */\ntype Falsy = false | null | undefined | 0 | '';\n\n/**\n * Removes all falsy values from an array.\n *\n * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.\n *\n * Useful for cleaning up arrays with optional, nullable, or conditionally included items.\n *\n * @template T - The type of the truthy items.\n *\n * @param array - An array possibly containing falsy values.\n *\n * @returns A new array containing only truthy values of type `T`.\n *\n * @example\n * ```ts\n * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]\n * ```\n */\nexport const compact = <T>(array: (T | Falsy)[]): T[] => array.filter(Boolean) as T[];\n\n/**\n * Returns a new array with duplicate values removed.\n *\n * Uses Set for efficient duplicate removal while preserving the original order.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array that may contain duplicate values.\n *\n * @returns A new array with only unique values, maintaining the original order.\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]\n * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']\n * ```\n */\nexport const unique = <T>(array: T[]): T[] => [...new Set(array)];\n\n/**\n * Splits an array into chunks of the specified size.\n *\n * Useful for pagination, batch processing, or creating grid layouts.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array to be chunked.\n * @param size - The size of each chunk. Must be greater than 0.\n *\n * @returns An array of chunks, where each chunk is an array of the specified size\n * (except possibly the last chunk, which may be smaller).\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]\n * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]\n * ```\n */\nexport const chunk = <T>(array: T[], size: number): T[][] => {\n assert(size > 0, 'Chunk size must be greater than 0');\n\n return Array.from({ length: Math.ceil(array.length / size) }, (_, index) =>\n array.slice(index * size, (index + 1) * size),\n );\n};\n\n/**\n * Returns an array containing elements that exist in all provided arrays.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param arrays - Two or more arrays to find common elements from.\n *\n * @returns A new array containing only the elements that exist in all input arrays.\n *\n * @example\n * ```ts\n * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]\n * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']\n * ```\n */\nexport const intersection = <T>(...arrays: T[][]): T[] => {\n if (arrays.length === 0) {\n return [];\n }\n\n if (arrays.length === 1) {\n return [...arrays[0]];\n }\n\n const [first, ...rest] = arrays;\n const uniqueFirst = unique(first);\n\n return uniqueFirst.filter(item => rest.every(array => array.includes(item)));\n};\n\n/**\n * Returns elements from the first array that don't exist in the second array.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param array - The source array.\n * @param exclude - The array containing elements to exclude.\n *\n * @returns A new array with elements from the first array that don't exist in the second array.\n *\n * @example\n * ```ts\n * difference([1, 2, 3, 4], [2, 4]); // [1, 3]\n * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']\n * ```\n */\nexport const difference = <T>(array: T[], exclude: T[]): T[] =>\n array.filter(item => !exclude.includes(item));\n\ntype PipeFn = (arg: unknown) => unknown;\n\ntype Pipe = {\n <A, B>(fn1: (a: A) => B): (a: A) => B;\n <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;\n <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;\n <A, B, C, D, E>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n ): (a: A) => E;\n <A, B, C, D, E, F>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n fn5: (e: E) => F,\n ): (a: A) => F;\n (...fns: PipeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from left to right.\n *\n * Useful for building a data processing pipeline where the output of one function becomes the input of the next.\n *\n * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from left to right.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = pipe(add, double, toStr)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const pipe: Pipe =\n (...fns: PipeFn[]) =>\n (arg: unknown) =>\n fns.reduce((prev, fn) => fn(prev), arg);\n\ntype ComposeFn = (arg: unknown) => unknown;\n\ntype Compose = {\n <A, R>(fn1: (a: A) => R): (a: A) => R;\n <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;\n <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;\n <A, B, C, D, R>(\n fn1: (d: D) => R,\n fn2: (c: C) => D,\n fn3: (b: B) => C,\n fn4: (a: A) => B,\n ): (a: A) => R;\n <A, B, C, D, E, R>(\n fn1: (e: E) => R,\n fn2: (d: D) => E,\n fn3: (c: C) => D,\n fn4: (b: B) => C,\n fn5: (a: A) => B,\n ): (a: A) => R;\n (...fns: ComposeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from **right to left**.\n *\n * Often used for building functional pipelines where the innermost function runs first.\n * Types are inferred up to 5 chained functions for full type safety.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from right to left.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = compose(toStr, double, add)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const compose: Compose =\n (...fns: ComposeFn[]) =>\n (arg: unknown) =>\n fns.reduceRight((prev, fn) => fn(prev), arg);\n","import { compact } from './array';\n\n/**\n * Asynchronously iterates over an array and executes an async function on each item sequentially,\n * collecting the results.\n *\n * Useful when order or timing matters (e.g., rate limits, UI updates, animations).\n *\n * @param array - The array of items to iterate over.\n * @param fn - An async function to execute for each item. Must return a value.\n *\n * @returns A promise that resolves with an array of results from each function call.\n *\n * @example\n * ```ts\n * const results = await runSequential([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runSequential = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => {\n const results: Result[] = [];\n\n for (let i = 0; i < array.length; i++) {\n results.push(await fn(array[i], i, array));\n }\n\n return results;\n};\n\n/**\n * Executes an asynchronous operation on each element of an array and waits for all promises to resolve.\n *\n * @param array - The array of items to operate on.\n * @param fn - The asynchronous operation to perform on each item.\n *\n * @returns A promise that resolves with an array of results after all operations are completed.\n *\n * @example\n * ```ts\n * const results = await runParallel([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runParallel = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => Promise.all(array.map(fn));\n\n/**\n * Asynchronously filters an array using a predicate function, executing **sequentially**.\n *\n * Useful for rate-limited or stateful async operations where execution order matters.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a `boolean` indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Sequentially filter even numbers with delay\n * const result = await filterSequential([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterSequential = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results: Item[] = [];\n\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n\n if (await predicate(item, i, array)) {\n results.push(item);\n }\n }\n\n return results;\n};\n\n/**\n * Asynchronously filters an array based on a provided async predicate function.\n *\n * Each item is passed to the `predicate` function in parallel, and only the items\n * for which the predicate resolves to `true` are included in the final result.\n *\n * Useful for filtering based on asynchronous conditions such as API calls,\n * file system access, or any other delayed operations.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a boolean indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Filter numbers that are even after a simulated delay\n * const result = await filterParallel([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterParallel = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results = await runParallel(array, async (item, index, array) =>\n (await predicate(item, index, array)) ? item : false,\n );\n\n return compact(results);\n};\n\n/**\n * Asynchronously checks if at least one element in the array satisfies the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if any item passes the condition.\n */\nexport const someAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Asynchronously checks if all elements in the array satisfy the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if all items pass the condition.\n */\nexport const everyAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (!(await predicate(array[i], i, array))) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Asynchronously reduces an array to a single accumulated value.\n *\n * @template Item - The type of items in the array.\n * @template Accumulator - The type of the accumulated result.\n *\n * @param array - The array to reduce.\n * @param fn - The async reducer function that processes each item and returns the updated accumulator.\n * @param initialValue - The initial accumulator value.\n *\n * @returns A promise that resolves to the final accumulated result.\n */\nexport const reduceAsync = async <Item, Accumulator>(\n array: Item[],\n fn: (accumulator: Accumulator, item: Item, index: number, array: Item[]) => Promise<Accumulator>,\n initialValue: Accumulator,\n): Promise<Accumulator> => {\n let accumulator = initialValue;\n\n for (let i = 0; i < array.length; i++) {\n accumulator = await fn(accumulator, array[i], i, array);\n }\n\n return accumulator;\n};\n\n/**\n * Asynchronously finds the first element that satisfies the async condition.\n *\n * @param array - The array of items to search.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to the found item or null if none match.\n */\nexport const findAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item | null> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return array[i];\n }\n }\n\n return null;\n};\n","interface HTMLElementTransformationValues {\n translateX: number;\n translateY: number;\n scaleX: number;\n scaleY: number;\n skewX: number;\n skewY: number;\n}\n\n/**\n * Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.\n *\n * Only works with 2D transforms (i.e., `matrix(a, b, c, d, e, f)`).\n *\n * @param element - The element with a CSS transform applied.\n * @returns An object with parsed transformation values.\n *\n * @example\n * ```ts\n * const values = parse2DMatrix(myElement);\n * console.log(values.translateX);\n * console.log(values.scaleX);\n * ```\n */\nexport const parse2DMatrix = (element: HTMLElement): HTMLElementTransformationValues => {\n const computedStyles = window.getComputedStyle(element);\n const transformValue = computedStyles.getPropertyValue('transform');\n\n const matrixMatch = transformValue.match(/^matrix\\((.+)\\)$/);\n if (!matrixMatch) {\n return {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n skewX: 0,\n skewY: 0,\n };\n }\n\n const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrixMatch[1]\n .split(', ')\n .map(parseFloat);\n\n return {\n translateX,\n translateY,\n scaleX,\n scaleY,\n skewX,\n skewY,\n };\n};\n\n/**\n * Creates a clone of a Blob object.\n *\n * @param blob - The Blob object to clone.\n *\n * @returns A new Blob with the same content and type as the original.\n */\nexport const cloneBlob = (blob: Blob): Blob => new Blob([blob], { type: blob.type });\n\n/**\n * Converts a `Blob` object into a `File` object with the specified name.\n *\n * This is useful when you receive a `Blob` (e.g., from canvas, fetch, or file manipulation)\n * and need to convert it into a `File` to upload via `FormData` or file inputs.\n *\n * @param blob - The `Blob` to convert.\n * @param fileName - The desired name for the resulting file (including extension).\n *\n * @returns A `File` instance with the same content and MIME type as the input `Blob`.\n *\n * @example\n * ```ts\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const file = convertBlobToFile(blob, 'hello.txt');\n *\n * console.log(file instanceof File); // true\n * ```\n */\nexport const convertBlobToFile = (blob: Blob, fileName: string): File =>\n new File([blob], fileName, {\n type: blob.type,\n });\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends unknown[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n\n/**\n * Creates a promise that resolves after the specified delay.\n *\n * Useful for creating artificial delays, implementing timeouts, or spacing operations.\n *\n * @param delayMs - The delay in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n *\n * @example\n * ```ts\n * // Wait for 1 second\n * await delay(1000);\n * console.log('This logs after 1 second');\n *\n * // Use with other async operations\n * async function fetchWithTimeout() {\n * const timeoutPromise = delay(5000).then(() => {\n * throw new Error('Request timed out');\n * });\n *\n * return Promise.race([fetchData(), timeoutPromise]);\n * }\n * ```\n */\nexport const delay = (delayMs: number): Promise<void> =>\n new Promise(resolve => setTimeout(resolve, delayMs));\n\ninterface RetryOptions {\n /**\n * Maximum number of retry attempts before failing.\n *\n * @default 3\n */\n maxAttempts?: number;\n /**\n * Delay in milliseconds between retry attempts.\n * If `backoff` is true, this is the base delay for exponential backoff.\n *\n * @default 300\n */\n delayMs?: number;\n /**\n * Whether to use exponential backoff for delays between attempts.\n * When enabled, the delay is multiplied by 2 ^ (`attempt` - 1).\n *\n * @default true\n */\n backoff?: boolean;\n /**\n * Optional callback triggered before each retry attempt.\n *\n * @param attempt - The current attempt number (starting from 1).\n * @param error - The error that caused the retry.\n */\n onRetry?: (attempt: number, error: unknown) => void;\n}\n\n/**\n * Wraps an asynchronous function with retry logic.\n *\n * The returned function will attempt to call the original function up to `maxAttempts` times,\n * with a delay between retries. If all attempts fail, the last encountered error is thrown.\n *\n * Useful for operations that may fail intermittently, such as network requests.\n *\n * @template Task - The type of the async function to wrap.\n * @template TaskResult - The result type of the async function.\n *\n * @param task - The async function to wrap with retry logic.\n * @param options - Configuration options for retry behavior.\n *\n * @returns A function that wraps the original function with retry support.\n *\n * @example\n * ```ts\n * async function fetchData() {\n * const response = await fetch('/api/data');\n *\n * if (!response.ok) {\n * throw new Error('Network error');\n * }\n *\n * return await response.json();\n * }\n *\n * const fetchWithRetry = retry(fetchData, {\n * maxAttempts: 5,\n * delayMs: 500,\n * onRetry: (attempt, error) => {\n * console.warn(`Attempt ${attempt} failed:`, error);\n * }\n * });\n *\n * fetchWithRetry()\n * .then(data => console.log('Success:', data))\n * .catch(error => console.error('Failed after retries:', error));\n * ```\n */\nexport const retry = <Task extends (...args: unknown[]) => Promise<TaskResult>, TaskResult>(\n task: Task,\n { maxAttempts = 3, delayMs = 300, backoff = true, onRetry }: RetryOptions = {},\n): ((...args: Parameters<Task>) => Promise<TaskResult>) => {\n return async (...args: Parameters<Task>): Promise<TaskResult> => {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await task(...args);\n } catch (e) {\n lastError = e;\n\n if (attempt < maxAttempts) {\n onRetry?.(attempt, e);\n\n const delayTime = backoff ? delayMs * 2 ** (attempt - 1) : delayMs;\n await delay(delayTime);\n }\n }\n }\n\n throw lastError;\n };\n};\n","export function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n\n/**\n * Checks if a value is null.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is null; otherwise, `false`.\n */\nexport const isNull = (value: unknown): value is null => value === null;\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n\n/**\n * Checks whether the provided value is considered \"empty\".\n *\n * A value is considered empty if it is:\n * - `null`\n * - `undefined`\n * - `''`\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is empty; otherwise, `false`.\n */\nexport const isNilOrEmptyString = (value: unknown): value is null | undefined =>\n value === '' || isNil(value);\n\n/**\n * Checks if a value is neither `null` nor `undefined`.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is defined (not `null` or `undefined`); otherwise, `false`.\n */\nexport const isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== null && value !== undefined;\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a string; otherwise, `false`.\n */\nexport const isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Checks if a value is a number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a number; otherwise, `false`.\n */\nexport const isNumber = (value: unknown): value is number => typeof value === 'number';\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a boolean; otherwise, `false`.\n */\nexport const isBool = (value: unknown): value is boolean => typeof value === 'boolean';\n\n/**\n * Checks if a value is an object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an object; otherwise, `false`.\n */\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\n/**\n * Checks if a value is an empty object (no own enumerable properties).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty object; otherwise, `false`.\n */\nexport const isEmptyObject = (value: unknown): value is Record<string, never> =>\n isObject(value) && !isNull(value) && Object.keys(value).length === 0;\n\n/**\n * Checks if a value is an array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an array; otherwise, `false`.\n */\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n\n/**\n * Checks if a value is an empty array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty array; otherwise, `false`.\n */\nexport const isEmptyArray = (value: unknown): value is [] => isArray(value) && value.length === 0;\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a function; otherwise, `false`.\n */\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is a Promise.\n *\n * @template T - The type of the value that the Promise resolves to.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Promise; otherwise, `false`.\n */\nexport const isPromise = <T = unknown>(value: unknown): value is Promise<T> =>\n isFunction((value as Promise<T>)?.then);\n\n/**\n * Checks if a value is a Date object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Date object; otherwise, `false`.\n */\nexport const isDate = (value: unknown): value is Date => value instanceof Date;\n\n/**\n * Checks if a value is a valid Date object (not Invalid Date).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a valid Date object; otherwise, `false`.\n */\nexport const isValidDate = (value: unknown): value is Date =>\n isDate(value) && !isNaN(value.getTime());\n\n/**\n * Checks if a value is a RegExp object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a RegExp object; otherwise, `false`.\n */\nexport const isRegExp = (value: unknown): value is RegExp => value instanceof RegExp;\n\n/**\n * Checks if a value is a Map.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Map; otherwise, `false`.\n */\nexport const isMap = (value: unknown): value is Map<unknown, unknown> => value instanceof Map;\n\n/**\n * Checks if a value is a Set.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Set; otherwise, `false`.\n */\nexport const isSet = (value: unknown): value is Set<unknown> => value instanceof Set;\n\n/**\n * Checks if a value is a Symbol.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Symbol; otherwise, `false`.\n */\nexport const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol';\n\n/**\n * Checks if a value is undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is undefined; otherwise, `false`.\n */\nexport const isUndefined = (value: unknown): value is undefined => value === undefined;\n\n/**\n * Checks if a value is a finite number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a finite number; otherwise, `false`.\n */\nexport const isFiniteNumber = (value: unknown): value is number =>\n isNumber(value) && isFinite(value);\n\n/**\n * Checks if a value is an integer.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an integer; otherwise, `false`.\n */\nexport const isInteger = (value: unknown): value is number =>\n isNumber(value) && Number.isInteger(value);\n","/**\n * Calculates the Euclidean distance between two points in 2D space.\n *\n * @param startX - The X coordinate of the starting point.\n * @param startY - The Y coordinate of the starting point.\n * @param endX - The X coordinate of the ending point.\n * @param endY - The Y coordinate of the ending point.\n *\n * @returns The Euclidean distance between the two points.\n */\nexport const calculateEuclideanDistance = (\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n): number => {\n const deltaX = endX - startX;\n const deltaY = endY - startY;\n\n return Math.hypot(deltaX, deltaY);\n};\n\n/**\n * Calculates the moving speed.\n *\n * @param distance - The distance.\n * @param elapsedTime - The time taken to move the distance.\n *\n * @returns The calculated speed, which is the absolute value of delta divided by elapsed time.\n */\nexport const calculateMovingSpeed = (distance: number, elapsedTime: number): number =>\n Math.abs(distance / elapsedTime);\n\n/**\n * Calculates the specified percentage of a given value.\n *\n * @param value - The value to calculate the percentage of.\n * @param percentage - The percentage to calculate.\n *\n * @returns The calculated percentage of the value.\n */\nexport const calculatePercentage = (value: number, percentage: number): number => {\n return (value * percentage) / 100;\n};\n","/**\n * Converts a string to kebab-case format.\n *\n * This function transforms camelCase or PascalCase strings into kebab-case by inserting\n * hyphens between lowercase and uppercase letters, then converting everything to lowercase.\n *\n * @param input - The string to convert to kebab-case.\n *\n * @returns The kebab-case formatted string.\n *\n * @example\n * ```ts\n * toKebabCase('helloWorld'); // → 'hello-world'\n * toKebabCase('HelloWorld'); // → 'hello-world'\n * toKebabCase('hello123World'); // → 'hello123-world'\n * ```\n */\nexport const toKebabCase = (input: string): string =>\n input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Converts a camelCase string to dash-case format.\n *\n * This function transforms camelCase strings into dash-case by inserting\n * hyphens before uppercase letters and converting them to lowercase.\n * The function ensures that no hyphen is added at the start of the output string,\n * even if the input begins with an uppercase letter.\n *\n * @param input - The camelCase string to convert to dash-case.\n *\n * @returns The dash-case formatted string.\n *\n * @example\n * ```ts\n * camelToDashCase('helloWorld'); // → 'hello-world'\n * camelToDashCase('HelloWorld'); // → 'hello-world'\n * camelToDashCase('backgroundColor'); // → 'background-color'\n * ```\n */\nexport const camelToDashCase = (input: string): string => {\n // First handle the first character separately to avoid adding a hyphen at the start\n const firstChar = input.charAt(0);\n const restOfString = input.slice(1);\n \n // Convert the first character to lowercase without adding a hyphen\n const firstCharProcessed = firstChar.toLowerCase();\n \n // Process the rest of the string normally, adding hyphens before uppercase letters\n const restProcessed = restOfString.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);\n \n return firstCharProcessed + restProcessed;\n};\n\n/**\n * Splits a string into an array of filtered from redundant spaces words.\n *\n * @param input - The input string to be split.\n *\n * @returns An array of words from the input string.\n */\nexport const splitStringIntoWords = (input: string): string[] => input.split(' ').filter(Boolean);\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param input - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (input: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < input.length; i++) {\n hash = (hash * 33) ^ input.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './async';\nexport * from './string';\nexport * from './array';\nexport * from './function';\nexport * from './guards';\nexport * from './math';\nexport * from './dom';\n"],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.dev.cjs","mappings":";;;;;;;;;;;;;;;;;;;;;AAAkC;AAOlC;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,OAAO,GAAG,CAAI,KAAoB,EAAO,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;AAEtF;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,MAAM,GAAG,CAAI,KAAU,EAAO,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,KAAK,GAAG,CAAI,KAAU,EAAE,IAAY,EAAS,EAAE;IAC1D,+CAAM,CAAC,IAAI,GAAG,CAAC,EAAE,mCAAmC,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UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACNwB;AACC;AACD;AACG;AACF;AACF;AACD","sources":["webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/async.ts","webpack://@react-hive/honey-utils/./src/dom.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/math.ts","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/webpack/bootstrap","webpack://@react-hive/honey-utils/webpack/runtime/define property getters","webpack://@react-hive/honey-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-utils/webpack/runtime/make namespace object","webpack://@react-hive/honey-utils/./src/index.ts"],"sourcesContent":["import { assert } from './guards';\n\n/**\n * Represents all falsy values.\n */\ntype Falsy = false | null | undefined | 0 | '';\n\n/**\n * Removes all falsy values from an array.\n *\n * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.\n *\n * Useful for cleaning up arrays with optional, nullable, or conditionally included items.\n *\n * @template T - The type of the truthy items.\n *\n * @param array - An array possibly containing falsy values.\n *\n * @returns A new array containing only truthy values of type `T`.\n *\n * @example\n * ```ts\n * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]\n * ```\n */\nexport const compact = <T>(array: (T | Falsy)[]): T[] => array.filter(Boolean) as T[];\n\n/**\n * Returns a new array with duplicate values removed.\n *\n * Uses Set for efficient duplicate removal while preserving the original order.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array that may contain duplicate values.\n *\n * @returns A new array with only unique values, maintaining the original order.\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]\n * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']\n * ```\n */\nexport const unique = <T>(array: T[]): T[] => [...new Set(array)];\n\n/**\n * Splits an array into chunks of the specified size.\n *\n * Useful for pagination, batch processing, or creating grid layouts.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array to be chunked.\n * @param size - The size of each chunk. Must be greater than 0.\n *\n * @returns An array of chunks, where each chunk is an array of the specified size\n * (except possibly the last chunk, which may be smaller).\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]\n * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]\n * ```\n */\nexport const chunk = <T>(array: T[], size: number): T[][] => {\n assert(size > 0, 'Chunk size must be greater than 0');\n\n return Array.from({ length: Math.ceil(array.length / size) }, (_, index) =>\n array.slice(index * size, (index + 1) * size),\n );\n};\n\n/**\n * Returns an array containing elements that exist in all provided arrays.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param arrays - Two or more arrays to find common elements from.\n *\n * @returns A new array containing only the elements that exist in all input arrays.\n *\n * @example\n * ```ts\n * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]\n * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']\n * ```\n */\nexport const intersection = <T>(...arrays: T[][]): T[] => {\n if (arrays.length === 0) {\n return [];\n }\n\n if (arrays.length === 1) {\n return [...arrays[0]];\n }\n\n const [first, ...rest] = arrays;\n const uniqueFirst = unique(first);\n\n return uniqueFirst.filter(item => rest.every(array => array.includes(item)));\n};\n\n/**\n * Returns elements from the first array that don't exist in the second array.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param array - The source array.\n * @param exclude - The array containing elements to exclude.\n *\n * @returns A new array with elements from the first array that don't exist in the second array.\n *\n * @example\n * ```ts\n * difference([1, 2, 3, 4], [2, 4]); // [1, 3]\n * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']\n * ```\n */\nexport const difference = <T>(array: T[], exclude: T[]): T[] =>\n array.filter(item => !exclude.includes(item));\n\ntype PipeFn = (arg: unknown) => unknown;\n\ntype Pipe = {\n <A, B>(fn1: (a: A) => B): (a: A) => B;\n <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;\n <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;\n <A, B, C, D, E>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n ): (a: A) => E;\n <A, B, C, D, E, F>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n fn5: (e: E) => F,\n ): (a: A) => F;\n (...fns: PipeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from left to right.\n *\n * Useful for building a data processing pipeline where the output of one function becomes the input of the next.\n *\n * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from left to right.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = pipe(add, double, toStr)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const pipe: Pipe =\n (...fns: PipeFn[]) =>\n (arg: unknown) =>\n fns.reduce((prev, fn) => fn(prev), arg);\n\ntype ComposeFn = (arg: unknown) => unknown;\n\ntype Compose = {\n <A, R>(fn1: (a: A) => R): (a: A) => R;\n <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;\n <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;\n <A, B, C, D, R>(\n fn1: (d: D) => R,\n fn2: (c: C) => D,\n fn3: (b: B) => C,\n fn4: (a: A) => B,\n ): (a: A) => R;\n <A, B, C, D, E, R>(\n fn1: (e: E) => R,\n fn2: (d: D) => E,\n fn3: (c: C) => D,\n fn4: (b: B) => C,\n fn5: (a: A) => B,\n ): (a: A) => R;\n (...fns: ComposeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from **right to left**.\n *\n * Often used for building functional pipelines where the innermost function runs first.\n * Types are inferred up to 5 chained functions for full type safety.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from right to left.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = compose(toStr, double, add)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const compose: Compose =\n (...fns: ComposeFn[]) =>\n (arg: unknown) =>\n fns.reduceRight((prev, fn) => fn(prev), arg);\n","import { compact } from './array';\n\n/**\n * Asynchronously iterates over an array and executes an async function on each item sequentially,\n * collecting the results.\n *\n * Useful when order or timing matters (e.g., rate limits, UI updates, animations).\n *\n * @param array - The array of items to iterate over.\n * @param fn - An async function to execute for each item. Must return a value.\n *\n * @returns A promise that resolves with an array of results from each function call.\n *\n * @example\n * ```ts\n * const results = await runSequential([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runSequential = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => {\n const results: Result[] = [];\n\n for (let i = 0; i < array.length; i++) {\n results.push(await fn(array[i], i, array));\n }\n\n return results;\n};\n\n/**\n * Executes an asynchronous operation on each element of an array and waits for all promises to resolve.\n *\n * @param array - The array of items to operate on.\n * @param fn - The asynchronous operation to perform on each item.\n *\n * @returns A promise that resolves with an array of results after all operations are completed.\n *\n * @example\n * ```ts\n * const results = await runParallel([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runParallel = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => Promise.all(array.map(fn));\n\n/**\n * Asynchronously filters an array using a predicate function, executing **sequentially**.\n *\n * Useful for rate-limited or stateful async operations where execution order matters.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a `boolean` indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Sequentially filter even numbers with delay\n * const result = await filterSequential([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterSequential = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results: Item[] = [];\n\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n\n if (await predicate(item, i, array)) {\n results.push(item);\n }\n }\n\n return results;\n};\n\n/**\n * Asynchronously filters an array based on a provided async predicate function.\n *\n * Each item is passed to the `predicate` function in parallel, and only the items\n * for which the predicate resolves to `true` are included in the final result.\n *\n * Useful for filtering based on asynchronous conditions such as API calls,\n * file system access, or any other delayed operations.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a boolean indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Filter numbers that are even after a simulated delay\n * const result = await filterParallel([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterParallel = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results = await runParallel(array, async (item, index, array) =>\n (await predicate(item, index, array)) ? item : false,\n );\n\n return compact(results);\n};\n\n/**\n * Asynchronously checks if at least one element in the array satisfies the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if any item passes the condition.\n */\nexport const someAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Asynchronously checks if all elements in the array satisfy the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if all items pass the condition.\n */\nexport const everyAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (!(await predicate(array[i], i, array))) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Asynchronously reduces an array to a single accumulated value.\n *\n * @template Item - The type of items in the array.\n * @template Accumulator - The type of the accumulated result.\n *\n * @param array - The array to reduce.\n * @param fn - The async reducer function that processes each item and returns the updated accumulator.\n * @param initialValue - The initial accumulator value.\n *\n * @returns A promise that resolves to the final accumulated result.\n */\nexport const reduceAsync = async <Item, Accumulator>(\n array: Item[],\n fn: (accumulator: Accumulator, item: Item, index: number, array: Item[]) => Promise<Accumulator>,\n initialValue: Accumulator,\n): Promise<Accumulator> => {\n let accumulator = initialValue;\n\n for (let i = 0; i < array.length; i++) {\n accumulator = await fn(accumulator, array[i], i, array);\n }\n\n return accumulator;\n};\n\n/**\n * Asynchronously finds the first element that satisfies the async condition.\n *\n * @param array - The array of items to search.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to the found item or null if none match.\n */\nexport const findAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item | null> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return array[i];\n }\n }\n\n return null;\n};\n","interface HTMLElementTransformationValues {\n translateX: number;\n translateY: number;\n scaleX: number;\n scaleY: number;\n skewX: number;\n skewY: number;\n}\n\n/**\n * Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.\n *\n * Only works with 2D transforms (i.e., `matrix(a, b, c, d, e, f)`).\n *\n * @param element - The element with a CSS transform applied.\n * @returns An object with parsed transformation values.\n *\n * @example\n * ```ts\n * const values = parse2DMatrix(myElement);\n * console.log(values.translateX);\n * console.log(values.scaleX);\n * ```\n */\nexport const parse2DMatrix = (element: HTMLElement): HTMLElementTransformationValues => {\n const computedStyles = window.getComputedStyle(element);\n const transformValue = computedStyles.getPropertyValue('transform');\n\n const matrixMatch = transformValue.match(/^matrix\\((.+)\\)$/);\n if (!matrixMatch) {\n return {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n skewX: 0,\n skewY: 0,\n };\n }\n\n const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrixMatch[1]\n .split(', ')\n .map(parseFloat);\n\n return {\n translateX,\n translateY,\n scaleX,\n scaleY,\n skewX,\n skewY,\n };\n};\n\n/**\n * Creates a clone of a Blob object.\n *\n * @param blob - The Blob object to clone.\n *\n * @returns A new Blob with the same content and type as the original.\n */\nexport const cloneBlob = (blob: Blob): Blob => new Blob([blob], { type: blob.type });\n\n/**\n * Converts a `Blob` object into a `File` object with the specified name.\n *\n * This is useful when you receive a `Blob` (e.g., from canvas, fetch, or file manipulation)\n * and need to convert it into a `File` to upload via `FormData` or file inputs.\n *\n * @param blob - The `Blob` to convert.\n * @param fileName - The desired name for the resulting file (including extension).\n *\n * @returns A `File` instance with the same content and MIME type as the input `Blob`.\n *\n * @example\n * ```ts\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const file = convertBlobToFile(blob, 'hello.txt');\n *\n * console.log(file instanceof File); // true\n * ```\n */\nexport const convertBlobToFile = (blob: Blob, fileName: string): File =>\n new File([blob], fileName, {\n type: blob.type,\n });\n\n/**\n * Calculates the intersection ratio between two DOM rectangles.\n *\n * The ratio represents the proportion of the `targetRect` that is covered by `sourceRect`.\n * A value of `1` means `sourceRect` completely covers `targetRect`, and `0` means no overlap.\n *\n * @param sourceRect - The rectangle used to measure overlap against the target.\n * @param targetRect - The rectangle whose covered area is measured.\n *\n * @returns A number between `0` and `1` representing the intersection ratio.\n */\nexport const getDOMRectIntersectionRatio = (sourceRect: DOMRect, targetRect: DOMRect): number => {\n const xOverlap = Math.max(\n 0,\n Math.min(sourceRect.right, targetRect.right) - Math.max(sourceRect.left, targetRect.left),\n );\n\n const yOverlap = Math.max(\n 0,\n Math.min(sourceRect.bottom, targetRect.bottom) - Math.max(sourceRect.top, targetRect.top),\n );\n\n const intersectionArea = xOverlap * yOverlap;\n const targetArea = targetRect.width * targetRect.height;\n\n return intersectionArea / targetArea;\n};\n\n/**\n * Returns the bounding DOMRect of an element based on offset and client dimensions.\n *\n * This utility is useful when you need a stable, layout-based rect\n * without triggering a reflow via `getBoundingClientRect()`.\n *\n * @param element - The target HTML element.\n * @returns A `DOMRect` representing the element’s offset position and size.\n */\nexport const getElementOffsetRect = (element: HTMLElement): DOMRect =>\n new DOMRect(element.offsetLeft, element.offsetTop, element.clientWidth, element.clientHeight);\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends unknown[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n\n/**\n * Creates a promise that resolves after the specified delay.\n *\n * Useful for creating artificial delays, implementing timeouts, or spacing operations.\n *\n * @param delayMs - The delay in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n *\n * @example\n * ```ts\n * // Wait for 1 second\n * await delay(1000);\n * console.log('This logs after 1 second');\n *\n * // Use with other async operations\n * async function fetchWithTimeout() {\n * const timeoutPromise = delay(5000).then(() => {\n * throw new Error('Request timed out');\n * });\n *\n * return Promise.race([fetchData(), timeoutPromise]);\n * }\n * ```\n */\nexport const delay = (delayMs: number): Promise<void> =>\n new Promise(resolve => setTimeout(resolve, delayMs));\n\n/**\n * Wraps a promise with a timeout. If the promise does not settle within the specified time,\n * it will reject with a timeout error.\n *\n * @template T - The type of the promise result.\n *\n * @param promise - The promise to wrap.\n * @param timeoutMs - Timeout duration in milliseconds.\n * @param errorMessage - Optional custom error message.\n *\n * @returns A promise that resolves or rejects with the original promise,\n * or rejects with a timeout error if the duration is exceeded.\n *\n * @example\n * ```ts\n * // Rejects if fetch takes longer than 3 seconds\n * const response = await timeout(fetch('/api/data'), 3000);\n *\n * // With custom message\n * await timeout(fetchData(), 2000, 'Too long');\n * ```\n */\nexport const timeout = async <T>(\n promise: Promise<T>,\n timeoutMs: number,\n errorMessage = 'Operation timed out',\n): Promise<T> => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(errorMessage)), timeoutMs);\n });\n\n try {\n return await Promise.race([promise, timeoutPromise]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n};\n\ninterface RetryOptions {\n /**\n * Maximum number of retry attempts before failing.\n *\n * @default 3\n */\n maxAttempts?: number;\n /**\n * Delay in milliseconds between retry attempts.\n * If `backoff` is true, this is the base delay for exponential backoff.\n *\n * @default 300\n */\n delayMs?: number;\n /**\n * Whether to use exponential backoff for delays between attempts.\n * When enabled, the delay is multiplied by 2 ^ (`attempt` - 1).\n *\n * @default true\n */\n backoff?: boolean;\n /**\n * Optional callback triggered before each retry attempt.\n *\n * @param attempt - The current attempt number (starting from 1).\n * @param error - The error that caused the retry.\n */\n onRetry?: (attempt: number, error: unknown) => void;\n}\n\n/**\n * Wraps an asynchronous function with retry logic.\n *\n * The returned function will attempt to call the original function up to `maxAttempts` times,\n * with a delay between retries. If all attempts fail, the last encountered error is thrown.\n *\n * Useful for operations that may fail intermittently, such as network requests.\n *\n * @template Task - The type of the async function to wrap.\n * @template TaskResult - The result type of the async function.\n *\n * @param task - The async function to wrap with retry logic.\n * @param options - Configuration options for retry behavior.\n *\n * @returns A function that wraps the original function with retry support.\n *\n * @example\n * ```ts\n * async function fetchData() {\n * const response = await fetch('/api/data');\n *\n * if (!response.ok) {\n * throw new Error('Network error');\n * }\n *\n * return await response.json();\n * }\n *\n * const fetchWithRetry = retry(fetchData, {\n * maxAttempts: 5,\n * delayMs: 500,\n * onRetry: (attempt, error) => {\n * console.warn(`Attempt ${attempt} failed:`, error);\n * }\n * });\n *\n * fetchWithRetry()\n * .then(data => console.log('Success:', data))\n * .catch(error => console.error('Failed after retries:', error));\n * ```\n */\nexport const retry = <Task extends (...args: unknown[]) => Promise<TaskResult>, TaskResult>(\n task: Task,\n { maxAttempts = 3, delayMs = 300, backoff = true, onRetry }: RetryOptions = {},\n): ((...args: Parameters<Task>) => Promise<TaskResult>) => {\n return async (...args: Parameters<Task>): Promise<TaskResult> => {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await task(...args);\n } catch (e) {\n lastError = e;\n\n if (attempt < maxAttempts) {\n onRetry?.(attempt, e);\n\n const delayTime = backoff ? delayMs * 2 ** (attempt - 1) : delayMs;\n await delay(delayTime);\n }\n }\n }\n\n throw lastError;\n };\n};\n","export function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n\n/**\n * Checks if a value is null.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is null; otherwise, `false`.\n */\nexport const isNull = (value: unknown): value is null => value === null;\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n\n/**\n * Checks whether the provided value is considered \"empty\".\n *\n * A value is considered empty if it is:\n * - `null`\n * - `undefined`\n * - `''`\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is empty; otherwise, `false`.\n */\nexport const isNilOrEmptyString = (value: unknown): value is null | undefined =>\n value === '' || isNil(value);\n\n/**\n * Checks if a value is neither `null` nor `undefined`.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is defined (not `null` or `undefined`); otherwise, `false`.\n */\nexport const isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== null && value !== undefined;\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a string; otherwise, `false`.\n */\nexport const isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Checks if a value is a number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a number; otherwise, `false`.\n */\nexport const isNumber = (value: unknown): value is number => typeof value === 'number';\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a boolean; otherwise, `false`.\n */\nexport const isBool = (value: unknown): value is boolean => typeof value === 'boolean';\n\n/**\n * Checks if a value is an object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an object; otherwise, `false`.\n */\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\n/**\n * Checks if a value is an empty object (no own enumerable properties).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty object; otherwise, `false`.\n */\nexport const isEmptyObject = (value: unknown): value is Record<string, never> =>\n isObject(value) && !isNull(value) && Object.keys(value).length === 0;\n\n/**\n * Checks if a value is an array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an array; otherwise, `false`.\n */\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n\n/**\n * Checks if a value is an empty array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty array; otherwise, `false`.\n */\nexport const isEmptyArray = (value: unknown): value is [] => isArray(value) && value.length === 0;\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a function; otherwise, `false`.\n */\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is a Promise.\n *\n * @template T - The type of the value that the Promise resolves to.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Promise; otherwise, `false`.\n */\nexport const isPromise = <T = unknown>(value: unknown): value is Promise<T> =>\n isFunction((value as Promise<T>)?.then);\n\n/**\n * Checks if a value is a Date object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Date object; otherwise, `false`.\n */\nexport const isDate = (value: unknown): value is Date => value instanceof Date;\n\n/**\n * Checks if a value is a valid Date object (not Invalid Date).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a valid Date object; otherwise, `false`.\n */\nexport const isValidDate = (value: unknown): value is Date =>\n isDate(value) && !isNaN(value.getTime());\n\n/**\n * Checks if a value is a RegExp object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a RegExp object; otherwise, `false`.\n */\nexport const isRegExp = (value: unknown): value is RegExp => value instanceof RegExp;\n\n/**\n * Checks if a value is a Map.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Map; otherwise, `false`.\n */\nexport const isMap = (value: unknown): value is Map<unknown, unknown> => value instanceof Map;\n\n/**\n * Checks if a value is a Set.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Set; otherwise, `false`.\n */\nexport const isSet = (value: unknown): value is Set<unknown> => value instanceof Set;\n\n/**\n * Checks if a value is a Symbol.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Symbol; otherwise, `false`.\n */\nexport const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol';\n\n/**\n * Checks if a value is undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is undefined; otherwise, `false`.\n */\nexport const isUndefined = (value: unknown): value is undefined => value === undefined;\n\n/**\n * Checks if a value is a finite number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a finite number; otherwise, `false`.\n */\nexport const isFiniteNumber = (value: unknown): value is number =>\n isNumber(value) && isFinite(value);\n\n/**\n * Checks if a value is an integer.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an integer; otherwise, `false`.\n */\nexport const isInteger = (value: unknown): value is number =>\n isNumber(value) && Number.isInteger(value);\n","/**\n * Calculates the Euclidean distance between two points in 2D space.\n *\n * @param startX - The X coordinate of the starting point.\n * @param startY - The Y coordinate of the starting point.\n * @param endX - The X coordinate of the ending point.\n * @param endY - The Y coordinate of the ending point.\n *\n * @returns The Euclidean distance between the two points.\n */\nexport const calculateEuclideanDistance = (\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n): number => {\n const deltaX = endX - startX;\n const deltaY = endY - startY;\n\n return Math.hypot(deltaX, deltaY);\n};\n\n/**\n * Calculates the moving speed.\n *\n * @param distance - The distance.\n * @param elapsedTime - The time taken to move the distance.\n *\n * @returns The calculated speed, which is the absolute value of delta divided by elapsed time.\n */\nexport const calculateMovingSpeed = (distance: number, elapsedTime: number): number =>\n Math.abs(distance / elapsedTime);\n\n/**\n * Calculates the specified percentage of a given value.\n *\n * @param value - The value to calculate the percentage of.\n * @param percentage - The percentage to calculate.\n *\n * @returns The calculated percentage of the value.\n */\nexport const calculatePercentage = (value: number, percentage: number): number => {\n return (value * percentage) / 100;\n};\n","/**\n * Converts a string to kebab-case format.\n *\n * This function transforms camelCase or PascalCase strings into kebab-case by inserting\n * hyphens between lowercase and uppercase letters, then converting everything to lowercase.\n *\n * @param input - The string to convert to kebab-case.\n *\n * @returns The kebab-case formatted string.\n *\n * @example\n * ```ts\n * toKebabCase('helloWorld'); // → 'hello-world'\n * toKebabCase('HelloWorld'); // → 'hello-world'\n * toKebabCase('hello123World'); // → 'hello123-world'\n * ```\n */\nexport const toKebabCase = (input: string): string =>\n input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Converts a camelCase string to dash-case format.\n *\n * This function transforms camelCase strings into dash-case by inserting\n * hyphens before uppercase letters and converting them to lowercase.\n * The function ensures that no hyphen is added at the start of the output string,\n * even if the input begins with an uppercase letter.\n *\n * @param input - The camelCase string to convert to dash-case.\n *\n * @returns The dash-case formatted string.\n *\n * @example\n * ```ts\n * camelToDashCase('helloWorld'); // → 'hello-world'\n * camelToDashCase('HelloWorld'); // → 'hello-world'\n * camelToDashCase('backgroundColor'); // → 'background-color'\n * ```\n */\nexport const camelToDashCase = (input: string): string => {\n // First handle the first character separately to avoid adding a hyphen at the start\n const firstChar = input.charAt(0);\n const restOfString = input.slice(1);\n \n // Convert the first character to lowercase without adding a hyphen\n const firstCharProcessed = firstChar.toLowerCase();\n \n // Process the rest of the string normally, adding hyphens before uppercase letters\n const restProcessed = restOfString.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);\n \n return firstCharProcessed + restProcessed;\n};\n\n/**\n * Splits a string into an array of filtered from redundant spaces words.\n *\n * @param input - The input string to be split.\n *\n * @returns An array of words from the input string.\n */\nexport const splitStringIntoWords = (input: string): string[] => input.split(' ').filter(Boolean);\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param input - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (input: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < input.length; i++) {\n hash = (hash * 33) ^ input.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './async';\nexport * from './string';\nexport * from './array';\nexport * from './function';\nexport * from './guards';\nexport * from './math';\nexport * from './dom';\n"],"names":[],"sourceRoot":""}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
var t={};function e(t,e){if(!t)throw new Error(e)}t.d=(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const r=t=>null===t,n=t=>null==t,a=t=>""===t||n(t),o=t=>null!=t,l=t=>"string"==typeof t,i=t=>"number"==typeof t,s=t=>"boolean"==typeof t,c=t=>"object"==typeof t,f=t=>c(t)&&!r(t)&&0===Object.keys(t).length,u=t=>Array.isArray(t),h=t=>u(t)&&0===t.length,y=t=>"function"==typeof t,p=t=>y(t?.then),w=t=>t instanceof Date,m=t=>w(t)&&!isNaN(t.getTime()),g=t=>t instanceof RegExp,b=t=>t instanceof Map,d=t=>t instanceof Set,M=t=>"symbol"==typeof t,x=t=>void 0===t,A=t=>i(t)&&isFinite(t),k=t=>i(t)&&Number.isInteger(t),P=t=>t.filter(Boolean),C=t=>[...new Set(t)],O=(t,r)=>(e(r>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(t.length/r)},(e,n)=>t.slice(n*r,(n+1)*r))),X=(...t)=>{if(0===t.length)return[];if(1===t.length)return[...t[0]];const[e,...r]=t;return C(e).filter(t=>r.every(e=>e.includes(t)))},Y=(t,e)=>t.filter(t=>!e.includes(t)),T=(...t)=>e=>t.reduce((t,e)=>e(t),e),j=(...t)=>e=>t.reduceRight((t,e)=>e(t),e),v=async(t,e)=>{const r=[];for(let n=0;n<t.length;n++)r.push(await e(t[n],n,t));return r},L=async(t,e)=>Promise.all(t.map(e)),R=async(t,e)=>{const r=[];for(let n=0;n<t.length;n++){const a=t[n];await e(a,n,t)&&r.push(a)}return r},S=async(t,e)=>{const r=await L(t,async(t,r,n)=>!!await e(t,r,n)&&t);return P(r)},$=async(t,e)=>{for(let r=0;r<t.length;r++)if(await e(t[r],r,t))return!0;return!1},B=async(t,e)=>{for(let r=0;r<t.length;r++)if(!await e(t[r],r,t))return!1;return!0},E=async(t,e,r)=>{let n=r;for(let r=0;r<t.length;r++)n=await e(n,t[r],r,t);return n},F=async(t,e)=>{for(let r=0;r<t.length;r++)if(await e(t[r],r,t))return t[r];return null},N=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),z=t=>{const e=t.charAt(0),r=t.slice(1);return e.toLowerCase()+r.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},D=t=>t.split(" ").filter(Boolean),Z=t=>{let e=5381;for(let r=0;r<t.length;r++)e=33*e^t.charCodeAt(r);return(e>>>0).toString(36)},H=()=>{},I=(t,...e)=>"function"==typeof t?t(...e):t,V=t=>new Promise(e=>setTimeout(e,t)),W=async(t,e,r="Operation timed out")=>{let n=null;const a=new Promise((t,a)=>{n=setTimeout(()=>a(new Error(r)),e)});try{return await Promise.race([t,a])}finally{n&&clearTimeout(n)}},q=(t,{maxAttempts:e=3,delayMs:r=300,backoff:n=!0,onRetry:a}={})=>async(...o)=>{let l;for(let i=1;i<=e;i++)try{return await t(...o)}catch(t){if(l=t,i<e){a?.(i,t);const e=n?r*2**(i-1):r;await V(e)}}throw l},G=(t,e,r,n)=>{const a=r-t,o=n-e;return Math.hypot(a,o)},J=(t,e)=>Math.abs(t/e),K=(t,e)=>t*e/100,Q=t=>{const e=window.getComputedStyle(t).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!e)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[r,n,a,o,l,i]=e[1].split(", ").map(parseFloat);return{translateX:l,translateY:i,scaleX:r,scaleY:o,skewX:a,skewY:n}},U=t=>new Blob([t],{type:t.type}),_=(t,e)=>new File([t],e,{type:t.type}),tt=(t,e)=>Math.max(0,Math.min(t.right,e.right)-Math.max(t.left,e.left))*Math.max(0,Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top))/(e.width*e.height),et=t=>new DOMRect(t.offsetLeft,t.offsetTop,t.clientWidth,t.clientHeight);export{e as assert,G as calculateEuclideanDistance,J as calculateMovingSpeed,K as calculatePercentage,z as camelToDashCase,O as chunk,U as cloneBlob,P as compact,j as compose,_ as convertBlobToFile,V as delay,Y as difference,B as everyAsync,S as filterParallel,R as filterSequential,F as findAsync,tt as getDOMRectIntersectionRatio,et as getElementOffsetRect,Z as hashString,X as intersection,I as invokeIfFunction,u as isArray,s as isBool,w as isDate,o as isDefined,h as isEmptyArray,f as isEmptyObject,A as isFiniteNumber,y as isFunction,k as isInteger,b as isMap,n as isNil,a as isNilOrEmptyString,r as isNull,i as isNumber,c as isObject,p as isPromise,g as isRegExp,d as isSet,l as isString,M as isSymbol,x as isUndefined,m as isValidDate,H as noop,Q as parse2DMatrix,T as pipe,E as reduceAsync,q as retry,L as runParallel,v as runSequential,$ as someAsync,D as splitStringIntoWords,W as timeout,N as toKebabCase,C as unique};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","mappings":"AAAO,SAASA,EAAOC,EAAgBC,GACrC,IAAKD,EACH,MAAM,IAAIE,MAAMD,EAEpB,CASO,MAAME,EAAUC,GAA4C,OAAVA,EAS5CC,EAASD,GACpBA,QAcWE,EAAsBF,GACvB,KAAVA,GAAgBC,EAAMD,GASXG,EAAgBH,GAC3BA,QASWI,EAAYJ,GAAqD,iBAAVA,EASvDK,EAAYL,GAAqD,iBAAVA,EASvDM,EAAUN,GAAsD,kBAAVA,EAStDO,EAAYP,GAAqD,iBAAVA,EASvDQ,EAAiBR,GAC5BO,EAASP,KAAWD,EAAOC,IAAwC,IAA9BS,OAAOC,KAAKV,GAAOW,OAS7CC,EAAWZ,GAAuCa,MAAMD,QAAQZ,GAShEc,EAAgBd,GAAgCY,EAAQZ,IAA2B,IAAjBA,EAAMW,OASxEI,EAAcf,GAAoC,mBAAVA,EAWxCgB,EAA0BhB,GACrCe,EAAYf,GAAsBiB,MASvBC,EAAUlB,GAAkCA,aAAiBmB,KAS7DC,EAAepB,GAC1BkB,EAAOlB,KAAWqB,MAAMrB,EAAMsB,WASnBC,EAAYvB,GAAoCA,aAAiBwB,OASjEC,EAASzB,GAAmDA,aAAiB0B,IAS7EC,EAAS3B,GAA0CA,aAAiB4B,IASpEC,EAAY7B,GAAqD,iBAAVA,EASvD8B,EAA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C,aACAC,SACAC,SACAC,QACAC,UAWSE,EAAaC,GAAqB,IAAIC,KAAK,CAACD,GAAO,CAAEE,KAAMF,EAAKE,OAqBhEC,EAAoB,CAACH,EAAYI,IAC5C,IAAIC,KAAK,CAACL,GAAOI,EAAU,CACzBF,KAAMF,EAAKE,c","sources":["webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/async.ts","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/math.ts","webpack://@react-hive/honey-utils/./src/dom.ts"],"sourcesContent":["export function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n\n/**\n * Checks if a value is null.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is null; otherwise, `false`.\n */\nexport const isNull = (value: unknown): value is null => value === null;\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n\n/**\n * Checks whether the provided value is considered \"empty\".\n *\n * A value is considered empty if it is:\n * - `null`\n * - `undefined`\n * - `''`\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is empty; otherwise, `false`.\n */\nexport const isNilOrEmptyString = (value: unknown): value is null | undefined =>\n value === '' || isNil(value);\n\n/**\n * Checks if a value is neither `null` nor `undefined`.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is defined (not `null` or `undefined`); otherwise, `false`.\n */\nexport const isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== null && value !== undefined;\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a string; otherwise, `false`.\n */\nexport const isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Checks if a value is a number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a number; otherwise, `false`.\n */\nexport const isNumber = (value: unknown): value is number => typeof value === 'number';\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a boolean; otherwise, `false`.\n */\nexport const isBool = (value: unknown): value is boolean => typeof value === 'boolean';\n\n/**\n * Checks if a value is an object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an object; otherwise, `false`.\n */\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\n/**\n * Checks if a value is an empty object (no own enumerable properties).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty object; otherwise, `false`.\n */\nexport const isEmptyObject = (value: unknown): value is Record<string, never> =>\n isObject(value) && !isNull(value) && Object.keys(value).length === 0;\n\n/**\n * Checks if a value is an array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an array; otherwise, `false`.\n */\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n\n/**\n * Checks if a value is an empty array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty array; otherwise, `false`.\n */\nexport const isEmptyArray = (value: unknown): value is [] => isArray(value) && value.length === 0;\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a function; otherwise, `false`.\n */\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is a Promise.\n *\n * @template T - The type of the value that the Promise resolves to.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Promise; otherwise, `false`.\n */\nexport const isPromise = <T = unknown>(value: unknown): value is Promise<T> =>\n isFunction((value as Promise<T>)?.then);\n\n/**\n * Checks if a value is a Date object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Date object; otherwise, `false`.\n */\nexport const isDate = (value: unknown): value is Date => value instanceof Date;\n\n/**\n * Checks if a value is a valid Date object (not Invalid Date).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a valid Date object; otherwise, `false`.\n */\nexport const isValidDate = (value: unknown): value is Date =>\n isDate(value) && !isNaN(value.getTime());\n\n/**\n * Checks if a value is a RegExp object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a RegExp object; otherwise, `false`.\n */\nexport const isRegExp = (value: unknown): value is RegExp => value instanceof RegExp;\n\n/**\n * Checks if a value is a Map.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Map; otherwise, `false`.\n */\nexport const isMap = (value: unknown): value is Map<unknown, unknown> => value instanceof Map;\n\n/**\n * Checks if a value is a Set.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Set; otherwise, `false`.\n */\nexport const isSet = (value: unknown): value is Set<unknown> => value instanceof Set;\n\n/**\n * Checks if a value is a Symbol.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Symbol; otherwise, `false`.\n */\nexport const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol';\n\n/**\n * Checks if a value is undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is undefined; otherwise, `false`.\n */\nexport const isUndefined = (value: unknown): value is undefined => value === undefined;\n\n/**\n * Checks if a value is a finite number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a finite number; otherwise, `false`.\n */\nexport const isFiniteNumber = (value: unknown): value is number =>\n isNumber(value) && isFinite(value);\n\n/**\n * Checks if a value is an integer.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an integer; otherwise, `false`.\n */\nexport const isInteger = (value: unknown): value is number =>\n isNumber(value) && Number.isInteger(value);\n","import { assert } from './guards';\n\n/**\n * Represents all falsy values.\n */\ntype Falsy = false | null | undefined | 0 | '';\n\n/**\n * Removes all falsy values from an array.\n *\n * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.\n *\n * Useful for cleaning up arrays with optional, nullable, or conditionally included items.\n *\n * @template T - The type of the truthy items.\n *\n * @param array - An array possibly containing falsy values.\n *\n * @returns A new array containing only truthy values of type `T`.\n *\n * @example\n * ```ts\n * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]\n * ```\n */\nexport const compact = <T>(array: (T | Falsy)[]): T[] => array.filter(Boolean) as T[];\n\n/**\n * Returns a new array with duplicate values removed.\n *\n * Uses Set for efficient duplicate removal while preserving the original order.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array that may contain duplicate values.\n *\n * @returns A new array with only unique values, maintaining the original order.\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]\n * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']\n * ```\n */\nexport const unique = <T>(array: T[]): T[] => [...new Set(array)];\n\n/**\n * Splits an array into chunks of the specified size.\n *\n * Useful for pagination, batch processing, or creating grid layouts.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array to be chunked.\n * @param size - The size of each chunk. Must be greater than 0.\n *\n * @returns An array of chunks, where each chunk is an array of the specified size\n * (except possibly the last chunk, which may be smaller).\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]\n * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]\n * ```\n */\nexport const chunk = <T>(array: T[], size: number): T[][] => {\n assert(size > 0, 'Chunk size must be greater than 0');\n\n return Array.from({ length: Math.ceil(array.length / size) }, (_, index) =>\n array.slice(index * size, (index + 1) * size),\n );\n};\n\n/**\n * Returns an array containing elements that exist in all provided arrays.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param arrays - Two or more arrays to find common elements from.\n *\n * @returns A new array containing only the elements that exist in all input arrays.\n *\n * @example\n * ```ts\n * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]\n * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']\n * ```\n */\nexport const intersection = <T>(...arrays: T[][]): T[] => {\n if (arrays.length === 0) {\n return [];\n }\n\n if (arrays.length === 1) {\n return [...arrays[0]];\n }\n\n const [first, ...rest] = arrays;\n const uniqueFirst = unique(first);\n\n return uniqueFirst.filter(item => rest.every(array => array.includes(item)));\n};\n\n/**\n * Returns elements from the first array that don't exist in the second array.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param array - The source array.\n * @param exclude - The array containing elements to exclude.\n *\n * @returns A new array with elements from the first array that don't exist in the second array.\n *\n * @example\n * ```ts\n * difference([1, 2, 3, 4], [2, 4]); // [1, 3]\n * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']\n * ```\n */\nexport const difference = <T>(array: T[], exclude: T[]): T[] =>\n array.filter(item => !exclude.includes(item));\n\ntype PipeFn = (arg: unknown) => unknown;\n\ntype Pipe = {\n <A, B>(fn1: (a: A) => B): (a: A) => B;\n <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;\n <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;\n <A, B, C, D, E>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n ): (a: A) => E;\n <A, B, C, D, E, F>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n fn5: (e: E) => F,\n ): (a: A) => F;\n (...fns: PipeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from left to right.\n *\n * Useful for building a data processing pipeline where the output of one function becomes the input of the next.\n *\n * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from left to right.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = pipe(add, double, toStr)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const pipe: Pipe =\n (...fns: PipeFn[]) =>\n (arg: unknown) =>\n fns.reduce((prev, fn) => fn(prev), arg);\n\ntype ComposeFn = (arg: unknown) => unknown;\n\ntype Compose = {\n <A, R>(fn1: (a: A) => R): (a: A) => R;\n <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;\n <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;\n <A, B, C, D, R>(\n fn1: (d: D) => R,\n fn2: (c: C) => D,\n fn3: (b: B) => C,\n fn4: (a: A) => B,\n ): (a: A) => R;\n <A, B, C, D, E, R>(\n fn1: (e: E) => R,\n fn2: (d: D) => E,\n fn3: (c: C) => D,\n fn4: (b: B) => C,\n fn5: (a: A) => B,\n ): (a: A) => R;\n (...fns: ComposeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from **right to left**.\n *\n * Often used for building functional pipelines where the innermost function runs first.\n * Types are inferred up to 5 chained functions for full type safety.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from right to left.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = compose(toStr, double, add)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const compose: Compose =\n (...fns: ComposeFn[]) =>\n (arg: unknown) =>\n fns.reduceRight((prev, fn) => fn(prev), arg);\n","import { compact } from './array';\n\n/**\n * Asynchronously iterates over an array and executes an async function on each item sequentially,\n * collecting the results.\n *\n * Useful when order or timing matters (e.g., rate limits, UI updates, animations).\n *\n * @param array - The array of items to iterate over.\n * @param fn - An async function to execute for each item. Must return a value.\n *\n * @returns A promise that resolves with an array of results from each function call.\n *\n * @example\n * ```ts\n * const results = await runSequential([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runSequential = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => {\n const results: Result[] = [];\n\n for (let i = 0; i < array.length; i++) {\n results.push(await fn(array[i], i, array));\n }\n\n return results;\n};\n\n/**\n * Executes an asynchronous operation on each element of an array and waits for all promises to resolve.\n *\n * @param array - The array of items to operate on.\n * @param fn - The asynchronous operation to perform on each item.\n *\n * @returns A promise that resolves with an array of results after all operations are completed.\n *\n * @example\n * ```ts\n * const results = await runParallel([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runParallel = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => Promise.all(array.map(fn));\n\n/**\n * Asynchronously filters an array using a predicate function, executing **sequentially**.\n *\n * Useful for rate-limited or stateful async operations where execution order matters.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a `boolean` indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Sequentially filter even numbers with delay\n * const result = await filterSequential([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterSequential = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results: Item[] = [];\n\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n\n if (await predicate(item, i, array)) {\n results.push(item);\n }\n }\n\n return results;\n};\n\n/**\n * Asynchronously filters an array based on a provided async predicate function.\n *\n * Each item is passed to the `predicate` function in parallel, and only the items\n * for which the predicate resolves to `true` are included in the final result.\n *\n * Useful for filtering based on asynchronous conditions such as API calls,\n * file system access, or any other delayed operations.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a boolean indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Filter numbers that are even after a simulated delay\n * const result = await filterParallel([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterParallel = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results = await runParallel(array, async (item, index, array) =>\n (await predicate(item, index, array)) ? item : false,\n );\n\n return compact(results);\n};\n\n/**\n * Asynchronously checks if at least one element in the array satisfies the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if any item passes the condition.\n */\nexport const someAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Asynchronously checks if all elements in the array satisfy the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if all items pass the condition.\n */\nexport const everyAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (!(await predicate(array[i], i, array))) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Asynchronously reduces an array to a single accumulated value.\n *\n * @template Item - The type of items in the array.\n * @template Accumulator - The type of the accumulated result.\n *\n * @param array - The array to reduce.\n * @param fn - The async reducer function that processes each item and returns the updated accumulator.\n * @param initialValue - The initial accumulator value.\n *\n * @returns A promise that resolves to the final accumulated result.\n */\nexport const reduceAsync = async <Item, Accumulator>(\n array: Item[],\n fn: (accumulator: Accumulator, item: Item, index: number, array: Item[]) => Promise<Accumulator>,\n initialValue: Accumulator,\n): Promise<Accumulator> => {\n let accumulator = initialValue;\n\n for (let i = 0; i < array.length; i++) {\n accumulator = await fn(accumulator, array[i], i, array);\n }\n\n return accumulator;\n};\n\n/**\n * Asynchronously finds the first element that satisfies the async condition.\n *\n * @param array - The array of items to search.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to the found item or null if none match.\n */\nexport const findAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item | null> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return array[i];\n }\n }\n\n return null;\n};\n","/**\n * Converts a string to kebab-case format.\n *\n * This function transforms camelCase or PascalCase strings into kebab-case by inserting\n * hyphens between lowercase and uppercase letters, then converting everything to lowercase.\n *\n * @param input - The string to convert to kebab-case.\n *\n * @returns The kebab-case formatted string.\n *\n * @example\n * ```ts\n * toKebabCase('helloWorld'); // → 'hello-world'\n * toKebabCase('HelloWorld'); // → 'hello-world'\n * toKebabCase('hello123World'); // → 'hello123-world'\n * ```\n */\nexport const toKebabCase = (input: string): string =>\n input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Converts a camelCase string to dash-case format.\n *\n * This function transforms camelCase strings into dash-case by inserting\n * hyphens before uppercase letters and converting them to lowercase.\n * The function ensures that no hyphen is added at the start of the output string,\n * even if the input begins with an uppercase letter.\n *\n * @param input - The camelCase string to convert to dash-case.\n *\n * @returns The dash-case formatted string.\n *\n * @example\n * ```ts\n * camelToDashCase('helloWorld'); // → 'hello-world'\n * camelToDashCase('HelloWorld'); // → 'hello-world'\n * camelToDashCase('backgroundColor'); // → 'background-color'\n * ```\n */\nexport const camelToDashCase = (input: string): string => {\n // First handle the first character separately to avoid adding a hyphen at the start\n const firstChar = input.charAt(0);\n const restOfString = input.slice(1);\n \n // Convert the first character to lowercase without adding a hyphen\n const firstCharProcessed = firstChar.toLowerCase();\n \n // Process the rest of the string normally, adding hyphens before uppercase letters\n const restProcessed = restOfString.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);\n \n return firstCharProcessed + restProcessed;\n};\n\n/**\n * Splits a string into an array of filtered from redundant spaces words.\n *\n * @param input - The input string to be split.\n *\n * @returns An array of words from the input string.\n */\nexport const splitStringIntoWords = (input: string): string[] => input.split(' ').filter(Boolean);\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param input - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (input: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < input.length; i++) {\n hash = (hash * 33) ^ input.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends unknown[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n\n/**\n * Creates a promise that resolves after the specified delay.\n *\n * Useful for creating artificial delays, implementing timeouts, or spacing operations.\n *\n * @param delayMs - The delay in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n *\n * @example\n * ```ts\n * // Wait for 1 second\n * await delay(1000);\n * console.log('This logs after 1 second');\n *\n * // Use with other async operations\n * async function fetchWithTimeout() {\n * const timeoutPromise = delay(5000).then(() => {\n * throw new Error('Request timed out');\n * });\n *\n * return Promise.race([fetchData(), timeoutPromise]);\n * }\n * ```\n */\nexport const delay = (delayMs: number): Promise<void> =>\n new Promise(resolve => setTimeout(resolve, delayMs));\n\ninterface RetryOptions {\n /**\n * Maximum number of retry attempts before failing.\n *\n * @default 3\n */\n maxAttempts?: number;\n /**\n * Delay in milliseconds between retry attempts.\n * If `backoff` is true, this is the base delay for exponential backoff.\n *\n * @default 300\n */\n delayMs?: number;\n /**\n * Whether to use exponential backoff for delays between attempts.\n * When enabled, the delay is multiplied by 2 ^ (`attempt` - 1).\n *\n * @default true\n */\n backoff?: boolean;\n /**\n * Optional callback triggered before each retry attempt.\n *\n * @param attempt - The current attempt number (starting from 1).\n * @param error - The error that caused the retry.\n */\n onRetry?: (attempt: number, error: unknown) => void;\n}\n\n/**\n * Wraps an asynchronous function with retry logic.\n *\n * The returned function will attempt to call the original function up to `maxAttempts` times,\n * with a delay between retries. If all attempts fail, the last encountered error is thrown.\n *\n * Useful for operations that may fail intermittently, such as network requests.\n *\n * @template Task - The type of the async function to wrap.\n * @template TaskResult - The result type of the async function.\n *\n * @param task - The async function to wrap with retry logic.\n * @param options - Configuration options for retry behavior.\n *\n * @returns A function that wraps the original function with retry support.\n *\n * @example\n * ```ts\n * async function fetchData() {\n * const response = await fetch('/api/data');\n *\n * if (!response.ok) {\n * throw new Error('Network error');\n * }\n *\n * return await response.json();\n * }\n *\n * const fetchWithRetry = retry(fetchData, {\n * maxAttempts: 5,\n * delayMs: 500,\n * onRetry: (attempt, error) => {\n * console.warn(`Attempt ${attempt} failed:`, error);\n * }\n * });\n *\n * fetchWithRetry()\n * .then(data => console.log('Success:', data))\n * .catch(error => console.error('Failed after retries:', error));\n * ```\n */\nexport const retry = <Task extends (...args: unknown[]) => Promise<TaskResult>, TaskResult>(\n task: Task,\n { maxAttempts = 3, delayMs = 300, backoff = true, onRetry }: RetryOptions = {},\n): ((...args: Parameters<Task>) => Promise<TaskResult>) => {\n return async (...args: Parameters<Task>): Promise<TaskResult> => {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await task(...args);\n } catch (e) {\n lastError = e;\n\n if (attempt < maxAttempts) {\n onRetry?.(attempt, e);\n\n const delayTime = backoff ? delayMs * 2 ** (attempt - 1) : delayMs;\n await delay(delayTime);\n }\n }\n }\n\n throw lastError;\n };\n};\n","/**\n * Calculates the Euclidean distance between two points in 2D space.\n *\n * @param startX - The X coordinate of the starting point.\n * @param startY - The Y coordinate of the starting point.\n * @param endX - The X coordinate of the ending point.\n * @param endY - The Y coordinate of the ending point.\n *\n * @returns The Euclidean distance between the two points.\n */\nexport const calculateEuclideanDistance = (\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n): number => {\n const deltaX = endX - startX;\n const deltaY = endY - startY;\n\n return Math.hypot(deltaX, deltaY);\n};\n\n/**\n * Calculates the moving speed.\n *\n * @param distance - The distance.\n * @param elapsedTime - The time taken to move the distance.\n *\n * @returns The calculated speed, which is the absolute value of delta divided by elapsed time.\n */\nexport const calculateMovingSpeed = (distance: number, elapsedTime: number): number =>\n Math.abs(distance / elapsedTime);\n\n/**\n * Calculates the specified percentage of a given value.\n *\n * @param value - The value to calculate the percentage of.\n * @param percentage - The percentage to calculate.\n *\n * @returns The calculated percentage of the value.\n */\nexport const calculatePercentage = (value: number, percentage: number): number => {\n return (value * percentage) / 100;\n};\n","interface HTMLElementTransformationValues {\n translateX: number;\n translateY: number;\n scaleX: number;\n scaleY: number;\n skewX: number;\n skewY: number;\n}\n\n/**\n * Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.\n *\n * Only works with 2D transforms (i.e., `matrix(a, b, c, d, e, f)`).\n *\n * @param element - The element with a CSS transform applied.\n * @returns An object with parsed transformation values.\n *\n * @example\n * ```ts\n * const values = parse2DMatrix(myElement);\n * console.log(values.translateX);\n * console.log(values.scaleX);\n * ```\n */\nexport const parse2DMatrix = (element: HTMLElement): HTMLElementTransformationValues => {\n const computedStyles = window.getComputedStyle(element);\n const transformValue = computedStyles.getPropertyValue('transform');\n\n const matrixMatch = transformValue.match(/^matrix\\((.+)\\)$/);\n if (!matrixMatch) {\n return {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n skewX: 0,\n skewY: 0,\n };\n }\n\n const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrixMatch[1]\n .split(', ')\n .map(parseFloat);\n\n return {\n translateX,\n translateY,\n scaleX,\n scaleY,\n skewX,\n skewY,\n };\n};\n\n/**\n * Creates a clone of a Blob object.\n *\n * @param blob - The Blob object to clone.\n *\n * @returns A new Blob with the same content and type as the original.\n */\nexport const cloneBlob = (blob: Blob): Blob => new Blob([blob], { type: blob.type });\n\n/**\n * Converts a `Blob` object into a `File` object with the specified name.\n *\n * This is useful when you receive a `Blob` (e.g., from canvas, fetch, or file manipulation)\n * and need to convert it into a `File` to upload via `FormData` or file inputs.\n *\n * @param blob - The `Blob` to convert.\n * @param fileName - The desired name for the resulting file (including extension).\n *\n * @returns A `File` instance with the same content and MIME type as the input `Blob`.\n *\n * @example\n * ```ts\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const file = convertBlobToFile(blob, 'hello.txt');\n *\n * console.log(file instanceof File); // true\n * ```\n */\nexport const convertBlobToFile = (blob: Blob, fileName: string): File =>\n new File([blob], fileName, {\n type: blob.type,\n });\n"],"names":["assert","condition","message","Error","isNull","value","isNil","isNilOrEmptyString","isDefined","isString","isNumber","isBool","isObject","isEmptyObject","Object","keys","length","isArray","Array","isEmptyArray","isFunction","isPromise","then","isDate","Date","isValidDate","isNaN","getTime","isRegExp","RegExp","isMap","Map","isSet","Set","isSymbol","isUndefined","undefined","isFiniteNumber","isFinite","isInteger","Number","compact","array","filter","Boolean","unique","chunk","size","from","Math","ceil","_","index","slice","intersection","arrays","first","rest","item","every","includes","difference","exclude","pipe","fns","arg","reduce","prev","fn","compose","reduceRight","runSequential","async","results","i","push","runParallel","Promise","all","map","filterSequential","predicate","filterParallel","someAsync","everyAsync","reduceAsync","initialValue","accumulator","findAsync","toKebabCase","input","replace","toLowerCase","camelToDashCase","firstChar","charAt","restOfString","letter","splitStringIntoWords","split","hashString","hash","charCodeAt","toString","noop","invokeIfFunction","args","delay","delayMs","resolve","setTimeout","retry","task","maxAttempts","backoff","onRetry","lastError","attempt","e","delayTime","calculateEuclideanDistance","startX","startY","endX","endY","deltaX","deltaY","hypot","calculateMovingSpeed","distance","elapsedTime","abs","calculatePercentage","percentage","parse2DMatrix","element","matrixMatch","window","getComputedStyle","getPropertyValue","match","translateX","translateY","scaleX","scaleY","skewX","skewY","parseFloat","cloneBlob","blob","Blob","type","convertBlobToFile","fileName","File"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.mjs","mappings":"AACA,IAAIA,EAAsB,CAAC,ECDpB,SAASC,EAAOC,EAAgBC,GACrC,IAAKD,EACH,MAAM,IAAIE,MAAMD,EAEpB,CCHAH,EAAoBK,EAAI,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAoBS,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GFa3E,MAAMI,EAAUC,GAA4C,OAAVA,EAS5CC,EAASD,GACpBA,QAcWE,EAAsBF,GACvB,KAAVA,GAAgBC,EAAMD,GASXG,EAAgBH,GAC3BA,QASWI,EAAYJ,GAAqD,iBAAVA,EASvDK,EAAYL,GAAqD,iBAAVA,EASvDM,EAAUN,GAAsD,kBAAVA,EAStDO,EAAYP,GAAqD,iBAAVA,EASvDQ,EAAiBR,GAC5BO,EAASP,KAAWD,EAAOC,IAAwC,IAA9BV,OAAOmB,KAAKT,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YAAanC,EAAQoC,qB","sources":["webpack://@react-hive/honey-utils/webpack/bootstrap","webpack://@react-hive/honey-utils/./src/guards.ts","webpack://@react-hive/honey-utils/webpack/runtime/define property getters","webpack://@react-hive/honey-utils/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-utils/./src/array.ts","webpack://@react-hive/honey-utils/./src/async.ts","webpack://@react-hive/honey-utils/./src/string.ts","webpack://@react-hive/honey-utils/./src/function.ts","webpack://@react-hive/honey-utils/./src/math.ts","webpack://@react-hive/honey-utils/./src/dom.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","export function assert(condition: any, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n\n/**\n * Checks if a value is null.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is null; otherwise, `false`.\n */\nexport const isNull = (value: unknown): value is null => value === null;\n\n/**\n * Checks if a value is null or undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is `null` or `undefined`, otherwise `false`.\n */\nexport const isNil = (value: unknown): value is null | undefined =>\n value === undefined || value === null;\n\n/**\n * Checks whether the provided value is considered \"empty\".\n *\n * A value is considered empty if it is:\n * - `null`\n * - `undefined`\n * - `''`\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is empty; otherwise, `false`.\n */\nexport const isNilOrEmptyString = (value: unknown): value is null | undefined =>\n value === '' || isNil(value);\n\n/**\n * Checks if a value is neither `null` nor `undefined`.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is defined (not `null` or `undefined`); otherwise, `false`.\n */\nexport const isDefined = <T>(value: T): value is NonNullable<T> =>\n value !== null && value !== undefined;\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a string; otherwise, `false`.\n */\nexport const isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Checks if a value is a number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a number; otherwise, `false`.\n */\nexport const isNumber = (value: unknown): value is number => typeof value === 'number';\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a boolean; otherwise, `false`.\n */\nexport const isBool = (value: unknown): value is boolean => typeof value === 'boolean';\n\n/**\n * Checks if a value is an object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an object; otherwise, `false`.\n */\nexport const isObject = (value: unknown): value is object => typeof value === 'object';\n\n/**\n * Checks if a value is an empty object (no own enumerable properties).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty object; otherwise, `false`.\n */\nexport const isEmptyObject = (value: unknown): value is Record<string, never> =>\n isObject(value) && !isNull(value) && Object.keys(value).length === 0;\n\n/**\n * Checks if a value is an array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an array; otherwise, `false`.\n */\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n\n/**\n * Checks if a value is an empty array.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an empty array; otherwise, `false`.\n */\nexport const isEmptyArray = (value: unknown): value is [] => isArray(value) && value.length === 0;\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a function; otherwise, `false`.\n */\nexport const isFunction = (value: unknown) => typeof value === 'function';\n\n/**\n * Checks if a value is a Promise.\n *\n * @template T - The type of the value that the Promise resolves to.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Promise; otherwise, `false`.\n */\nexport const isPromise = <T = unknown>(value: unknown): value is Promise<T> =>\n isFunction((value as Promise<T>)?.then);\n\n/**\n * Checks if a value is a Date object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Date object; otherwise, `false`.\n */\nexport const isDate = (value: unknown): value is Date => value instanceof Date;\n\n/**\n * Checks if a value is a valid Date object (not Invalid Date).\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a valid Date object; otherwise, `false`.\n */\nexport const isValidDate = (value: unknown): value is Date =>\n isDate(value) && !isNaN(value.getTime());\n\n/**\n * Checks if a value is a RegExp object.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a RegExp object; otherwise, `false`.\n */\nexport const isRegExp = (value: unknown): value is RegExp => value instanceof RegExp;\n\n/**\n * Checks if a value is a Map.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Map; otherwise, `false`.\n */\nexport const isMap = (value: unknown): value is Map<unknown, unknown> => value instanceof Map;\n\n/**\n * Checks if a value is a Set.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Set; otherwise, `false`.\n */\nexport const isSet = (value: unknown): value is Set<unknown> => value instanceof Set;\n\n/**\n * Checks if a value is a Symbol.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a Symbol; otherwise, `false`.\n */\nexport const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol';\n\n/**\n * Checks if a value is undefined.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is undefined; otherwise, `false`.\n */\nexport const isUndefined = (value: unknown): value is undefined => value === undefined;\n\n/**\n * Checks if a value is a finite number.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is a finite number; otherwise, `false`.\n */\nexport const isFiniteNumber = (value: unknown): value is number =>\n isNumber(value) && isFinite(value);\n\n/**\n * Checks if a value is an integer.\n *\n * @param value - The value to check.\n *\n * @returns `true` if the value is an integer; otherwise, `false`.\n */\nexport const isInteger = (value: unknown): value is number =>\n isNumber(value) && Number.isInteger(value);\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { assert } from './guards';\n\n/**\n * Represents all falsy values.\n */\ntype Falsy = false | null | undefined | 0 | '';\n\n/**\n * Removes all falsy values from an array.\n *\n * Falsy values include: `false`, `0`, `''` (empty string), `null`, `undefined`, and `NaN`.\n *\n * Useful for cleaning up arrays with optional, nullable, or conditionally included items.\n *\n * @template T - The type of the truthy items.\n *\n * @param array - An array possibly containing falsy values.\n *\n * @returns A new array containing only truthy values of type `T`.\n *\n * @example\n * ```ts\n * compact([0, 1, false, 2, '', 3, null, undefined, NaN]); // [1, 2, 3]\n * ```\n */\nexport const compact = <T>(array: (T | Falsy)[]): T[] => array.filter(Boolean) as T[];\n\n/**\n * Returns a new array with duplicate values removed.\n *\n * Uses Set for efficient duplicate removal while preserving the original order.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array that may contain duplicate values.\n *\n * @returns A new array with only unique values, maintaining the original order.\n *\n * @example\n * ```ts\n * unique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]\n * unique(['a', 'b', 'a', 'c']); // ['a', 'b', 'c']\n * ```\n */\nexport const unique = <T>(array: T[]): T[] => [...new Set(array)];\n\n/**\n * Splits an array into chunks of the specified size.\n *\n * Useful for pagination, batch processing, or creating grid layouts.\n *\n * @template T - The type of the items in the array.\n *\n * @param array - The input array to be chunked.\n * @param size - The size of each chunk. Must be greater than 0.\n *\n * @returns An array of chunks, where each chunk is an array of the specified size\n * (except possibly the last chunk, which may be smaller).\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]\n * chunk(['a', 'b', 'c', 'd'], 3); // [['a', 'b', 'c'], ['d']]\n * ```\n */\nexport const chunk = <T>(array: T[], size: number): T[][] => {\n assert(size > 0, 'Chunk size must be greater than 0');\n\n return Array.from({ length: Math.ceil(array.length / size) }, (_, index) =>\n array.slice(index * size, (index + 1) * size),\n );\n};\n\n/**\n * Returns an array containing elements that exist in all provided arrays.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param arrays - Two or more arrays to find common elements from.\n *\n * @returns A new array containing only the elements that exist in all input arrays.\n *\n * @example\n * ```ts\n * intersection([1, 2, 3], [2, 3, 4]); // [2, 3]\n * intersection(['a', 'b', 'c'], ['b', 'c', 'd'], ['b', 'e']); // ['b']\n * ```\n */\nexport const intersection = <T>(...arrays: T[][]): T[] => {\n if (arrays.length === 0) {\n return [];\n }\n\n if (arrays.length === 1) {\n return [...arrays[0]];\n }\n\n const [first, ...rest] = arrays;\n const uniqueFirst = unique(first);\n\n return uniqueFirst.filter(item => rest.every(array => array.includes(item)));\n};\n\n/**\n * Returns elements from the first array that don't exist in the second array.\n *\n * @template T - The type of the items in the arrays.\n *\n * @param array - The source array.\n * @param exclude - The array containing elements to exclude.\n *\n * @returns A new array with elements from the first array that don't exist in the second array.\n *\n * @example\n * ```ts\n * difference([1, 2, 3, 4], [2, 4]); // [1, 3]\n * difference(['a', 'b', 'c'], ['b']); // ['a', 'c']\n * ```\n */\nexport const difference = <T>(array: T[], exclude: T[]): T[] =>\n array.filter(item => !exclude.includes(item));\n\ntype PipeFn = (arg: unknown) => unknown;\n\ntype Pipe = {\n <A, B>(fn1: (a: A) => B): (a: A) => B;\n <A, B, C>(fn1: (a: A) => B, fn2: (b: B) => C): (a: A) => C;\n <A, B, C, D>(fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): (a: A) => D;\n <A, B, C, D, E>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n ): (a: A) => E;\n <A, B, C, D, E, F>(\n fn1: (a: A) => B,\n fn2: (b: B) => C,\n fn3: (c: C) => D,\n fn4: (d: D) => E,\n fn5: (e: E) => F,\n ): (a: A) => F;\n (...fns: PipeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from left to right.\n *\n * Useful for building a data processing pipeline where the output of one function becomes the input of the next.\n *\n * Types are inferred up to 5 chained functions for full type safety. Beyond that, it falls back to the unknown.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from left to right.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = pipe(add, double, toStr)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const pipe: Pipe =\n (...fns: PipeFn[]) =>\n (arg: unknown) =>\n fns.reduce((prev, fn) => fn(prev), arg);\n\ntype ComposeFn = (arg: unknown) => unknown;\n\ntype Compose = {\n <A, R>(fn1: (a: A) => R): (a: A) => R;\n <A, B, R>(fn1: (b: B) => R, fn2: (a: A) => B): (a: A) => R;\n <A, B, C, R>(fn1: (c: C) => R, fn2: (b: B) => C, fn3: (a: A) => B): (a: A) => R;\n <A, B, C, D, R>(\n fn1: (d: D) => R,\n fn2: (c: C) => D,\n fn3: (b: B) => C,\n fn4: (a: A) => B,\n ): (a: A) => R;\n <A, B, C, D, E, R>(\n fn1: (e: E) => R,\n fn2: (d: D) => E,\n fn3: (c: C) => D,\n fn4: (b: B) => C,\n fn5: (a: A) => B,\n ): (a: A) => R;\n (...fns: ComposeFn[]): (arg: unknown) => unknown;\n};\n\n/**\n * Composes multiple unary functions into a single function, applying them from **right to left**.\n *\n * Often used for building functional pipelines where the innermost function runs first.\n * Types are inferred up to 5 chained functions for full type safety.\n *\n * @param fns - A list of unary functions to compose.\n *\n * @returns A new function that applies all functions from right to left.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 1;\n * const double = (x: number) => x * 2;\n * const toStr = (x: number) => `Result: ${x}`;\n *\n * const result = compose(toStr, double, add)(2);\n * // => 'Result: 6'\n * ```\n */\nexport const compose: Compose =\n (...fns: ComposeFn[]) =>\n (arg: unknown) =>\n fns.reduceRight((prev, fn) => fn(prev), arg);\n","import { compact } from './array';\n\n/**\n * Asynchronously iterates over an array and executes an async function on each item sequentially,\n * collecting the results.\n *\n * Useful when order or timing matters (e.g., rate limits, UI updates, animations).\n *\n * @param array - The array of items to iterate over.\n * @param fn - An async function to execute for each item. Must return a value.\n *\n * @returns A promise that resolves with an array of results from each function call.\n *\n * @example\n * ```ts\n * const results = await runSequential([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runSequential = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => {\n const results: Result[] = [];\n\n for (let i = 0; i < array.length; i++) {\n results.push(await fn(array[i], i, array));\n }\n\n return results;\n};\n\n/**\n * Executes an asynchronous operation on each element of an array and waits for all promises to resolve.\n *\n * @param array - The array of items to operate on.\n * @param fn - The asynchronous operation to perform on each item.\n *\n * @returns A promise that resolves with an array of results after all operations are completed.\n *\n * @example\n * ```ts\n * const results = await runParallel([1, 2, 3], async (item) => {\n * await delay(100);\n *\n * return item * 2;\n * });\n *\n * console.log(results); // [2, 4, 6]\n * ```\n */\nexport const runParallel = async <Item, Result>(\n array: Item[],\n fn: (item: Item, index: number, array: Item[]) => Promise<Result>,\n): Promise<Result[]> => Promise.all(array.map(fn));\n\n/**\n * Asynchronously filters an array using a predicate function, executing **sequentially**.\n *\n * Useful for rate-limited or stateful async operations where execution order matters.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a `boolean` indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Sequentially filter even numbers with delay\n * const result = await filterSequential([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterSequential = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results: Item[] = [];\n\n for (let i = 0; i < array.length; i++) {\n const item = array[i];\n\n if (await predicate(item, i, array)) {\n results.push(item);\n }\n }\n\n return results;\n};\n\n/**\n * Asynchronously filters an array based on a provided async predicate function.\n *\n * Each item is passed to the `predicate` function in parallel, and only the items\n * for which the predicate resolves to `true` are included in the final result.\n *\n * Useful for filtering based on asynchronous conditions such as API calls,\n * file system access, or any other delayed operations.\n *\n * @template Item - The type of the items in the input array.\n *\n * @param array - The array of items to filter.\n * @param predicate - An async function that returns a boolean indicating whether to keep each item.\n *\n * @returns A promise that resolves to a new array containing only the items for which the predicate returned `true`.\n *\n * @example\n * ```ts\n * // Filter numbers that are even after a simulated delay\n * const result = await filterParallel([1, 2, 3, 4], async (num) => {\n * await delay(100);\n *\n * return num % 2 === 0;\n * });\n *\n * console.log(result); // [2, 4]\n * ```\n */\nexport const filterParallel = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item[]> => {\n const results = await runParallel(array, async (item, index, array) =>\n (await predicate(item, index, array)) ? item : false,\n );\n\n return compact(results);\n};\n\n/**\n * Asynchronously checks if at least one element in the array satisfies the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if any item passes the condition.\n */\nexport const someAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Asynchronously checks if all elements in the array satisfy the async condition.\n *\n * @param array - The array of items to check.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to true if all items pass the condition.\n */\nexport const everyAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<boolean> => {\n for (let i = 0; i < array.length; i++) {\n if (!(await predicate(array[i], i, array))) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Asynchronously reduces an array to a single accumulated value.\n *\n * @template Item - The type of items in the array.\n * @template Accumulator - The type of the accumulated result.\n *\n * @param array - The array to reduce.\n * @param fn - The async reducer function that processes each item and returns the updated accumulator.\n * @param initialValue - The initial accumulator value.\n *\n * @returns A promise that resolves to the final accumulated result.\n */\nexport const reduceAsync = async <Item, Accumulator>(\n array: Item[],\n fn: (accumulator: Accumulator, item: Item, index: number, array: Item[]) => Promise<Accumulator>,\n initialValue: Accumulator,\n): Promise<Accumulator> => {\n let accumulator = initialValue;\n\n for (let i = 0; i < array.length; i++) {\n accumulator = await fn(accumulator, array[i], i, array);\n }\n\n return accumulator;\n};\n\n/**\n * Asynchronously finds the first element that satisfies the async condition.\n *\n * @param array - The array of items to search.\n * @param predicate - An async function that returns a boolean.\n *\n * @returns A promise that resolves to the found item or null if none match.\n */\nexport const findAsync = async <Item>(\n array: Item[],\n predicate: (item: Item, index: number, array: Item[]) => Promise<boolean>,\n): Promise<Item | null> => {\n for (let i = 0; i < array.length; i++) {\n if (await predicate(array[i], i, array)) {\n return array[i];\n }\n }\n\n return null;\n};\n","/**\n * Converts a string to kebab-case format.\n *\n * This function transforms camelCase or PascalCase strings into kebab-case by inserting\n * hyphens between lowercase and uppercase letters, then converting everything to lowercase.\n *\n * @param input - The string to convert to kebab-case.\n *\n * @returns The kebab-case formatted string.\n *\n * @example\n * ```ts\n * toKebabCase('helloWorld'); // → 'hello-world'\n * toKebabCase('HelloWorld'); // → 'hello-world'\n * toKebabCase('hello123World'); // → 'hello123-world'\n * ```\n */\nexport const toKebabCase = (input: string): string =>\n input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Converts a camelCase string to dash-case format.\n *\n * This function transforms camelCase strings into dash-case by inserting\n * hyphens before uppercase letters and converting them to lowercase.\n * The function ensures that no hyphen is added at the start of the output string,\n * even if the input begins with an uppercase letter.\n *\n * @param input - The camelCase string to convert to dash-case.\n *\n * @returns The dash-case formatted string.\n *\n * @example\n * ```ts\n * camelToDashCase('helloWorld'); // → 'hello-world'\n * camelToDashCase('HelloWorld'); // → 'hello-world'\n * camelToDashCase('backgroundColor'); // → 'background-color'\n * ```\n */\nexport const camelToDashCase = (input: string): string => {\n // First handle the first character separately to avoid adding a hyphen at the start\n const firstChar = input.charAt(0);\n const restOfString = input.slice(1);\n \n // Convert the first character to lowercase without adding a hyphen\n const firstCharProcessed = firstChar.toLowerCase();\n \n // Process the rest of the string normally, adding hyphens before uppercase letters\n const restProcessed = restOfString.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);\n \n return firstCharProcessed + restProcessed;\n};\n\n/**\n * Splits a string into an array of filtered from redundant spaces words.\n *\n * @param input - The input string to be split.\n *\n * @returns An array of words from the input string.\n */\nexport const splitStringIntoWords = (input: string): string[] => input.split(' ').filter(Boolean);\n\n/**\n * Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.\n *\n * This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm\n * based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,\n * which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.\n *\n * Useful for:\n * - Generating stable class names in CSS-in-JS libraries.\n * - Producing consistent cache keys.\n * - Quick and lightweight hashing needs where cryptographic security is not required.\n *\n * ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.\n *\n * @param input - The input string to hash.\n *\n * @returns A short, base-36 encoded hash string.\n *\n * @example\n * ```ts\n * const className = hashString('background-color: red;');\n * // → 'e4k1z0x'\n * ```\n */\nexport const hashString = (input: string): string => {\n let hash = 5381;\n\n for (let i = 0; i < input.length; i++) {\n hash = (hash * 33) ^ input.charCodeAt(i);\n }\n\n return (hash >>> 0).toString(36);\n};\n","export const noop = () => {};\n\n/**\n * Invokes the given input if it is a function, passing the provided arguments.\n * Otherwise, returns the input as-is.\n *\n * @template Args - Tuple of argument types to pass to the function.\n * @template Result - Return type of the function or the value.\n *\n * @param input - A function to invoke with `args`, or a direct value of type `Result`.\n * @param args - Arguments to pass if `input` is a function.\n *\n * @returns The result of invoking the function, or the original value if it's not a function.\n */\nexport const invokeIfFunction = <Args extends unknown[], Result>(\n input: ((...args: Args) => Result) | Result,\n ...args: Args\n): Result => (typeof input === 'function' ? (input as (...args: Args) => Result)(...args) : input);\n\n/**\n * Creates a promise that resolves after the specified delay.\n *\n * Useful for creating artificial delays, implementing timeouts, or spacing operations.\n *\n * @param delayMs - The delay in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n *\n * @example\n * ```ts\n * // Wait for 1 second\n * await delay(1000);\n * console.log('This logs after 1 second');\n *\n * // Use with other async operations\n * async function fetchWithTimeout() {\n * const timeoutPromise = delay(5000).then(() => {\n * throw new Error('Request timed out');\n * });\n *\n * return Promise.race([fetchData(), timeoutPromise]);\n * }\n * ```\n */\nexport const delay = (delayMs: number): Promise<void> =>\n new Promise(resolve => setTimeout(resolve, delayMs));\n\n/**\n * Wraps a promise with a timeout. If the promise does not settle within the specified time,\n * it will reject with a timeout error.\n *\n * @template T - The type of the promise result.\n *\n * @param promise - The promise to wrap.\n * @param timeoutMs - Timeout duration in milliseconds.\n * @param errorMessage - Optional custom error message.\n *\n * @returns A promise that resolves or rejects with the original promise,\n * or rejects with a timeout error if the duration is exceeded.\n *\n * @example\n * ```ts\n * // Rejects if fetch takes longer than 3 seconds\n * const response = await timeout(fetch('/api/data'), 3000);\n *\n * // With custom message\n * await timeout(fetchData(), 2000, 'Too long');\n * ```\n */\nexport const timeout = async <T>(\n promise: Promise<T>,\n timeoutMs: number,\n errorMessage = 'Operation timed out',\n): Promise<T> => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => reject(new Error(errorMessage)), timeoutMs);\n });\n\n try {\n return await Promise.race([promise, timeoutPromise]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n};\n\ninterface RetryOptions {\n /**\n * Maximum number of retry attempts before failing.\n *\n * @default 3\n */\n maxAttempts?: number;\n /**\n * Delay in milliseconds between retry attempts.\n * If `backoff` is true, this is the base delay for exponential backoff.\n *\n * @default 300\n */\n delayMs?: number;\n /**\n * Whether to use exponential backoff for delays between attempts.\n * When enabled, the delay is multiplied by 2 ^ (`attempt` - 1).\n *\n * @default true\n */\n backoff?: boolean;\n /**\n * Optional callback triggered before each retry attempt.\n *\n * @param attempt - The current attempt number (starting from 1).\n * @param error - The error that caused the retry.\n */\n onRetry?: (attempt: number, error: unknown) => void;\n}\n\n/**\n * Wraps an asynchronous function with retry logic.\n *\n * The returned function will attempt to call the original function up to `maxAttempts` times,\n * with a delay between retries. If all attempts fail, the last encountered error is thrown.\n *\n * Useful for operations that may fail intermittently, such as network requests.\n *\n * @template Task - The type of the async function to wrap.\n * @template TaskResult - The result type of the async function.\n *\n * @param task - The async function to wrap with retry logic.\n * @param options - Configuration options for retry behavior.\n *\n * @returns A function that wraps the original function with retry support.\n *\n * @example\n * ```ts\n * async function fetchData() {\n * const response = await fetch('/api/data');\n *\n * if (!response.ok) {\n * throw new Error('Network error');\n * }\n *\n * return await response.json();\n * }\n *\n * const fetchWithRetry = retry(fetchData, {\n * maxAttempts: 5,\n * delayMs: 500,\n * onRetry: (attempt, error) => {\n * console.warn(`Attempt ${attempt} failed:`, error);\n * }\n * });\n *\n * fetchWithRetry()\n * .then(data => console.log('Success:', data))\n * .catch(error => console.error('Failed after retries:', error));\n * ```\n */\nexport const retry = <Task extends (...args: unknown[]) => Promise<TaskResult>, TaskResult>(\n task: Task,\n { maxAttempts = 3, delayMs = 300, backoff = true, onRetry }: RetryOptions = {},\n): ((...args: Parameters<Task>) => Promise<TaskResult>) => {\n return async (...args: Parameters<Task>): Promise<TaskResult> => {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await task(...args);\n } catch (e) {\n lastError = e;\n\n if (attempt < maxAttempts) {\n onRetry?.(attempt, e);\n\n const delayTime = backoff ? delayMs * 2 ** (attempt - 1) : delayMs;\n await delay(delayTime);\n }\n }\n }\n\n throw lastError;\n };\n};\n","/**\n * Calculates the Euclidean distance between two points in 2D space.\n *\n * @param startX - The X coordinate of the starting point.\n * @param startY - The Y coordinate of the starting point.\n * @param endX - The X coordinate of the ending point.\n * @param endY - The Y coordinate of the ending point.\n *\n * @returns The Euclidean distance between the two points.\n */\nexport const calculateEuclideanDistance = (\n startX: number,\n startY: number,\n endX: number,\n endY: number,\n): number => {\n const deltaX = endX - startX;\n const deltaY = endY - startY;\n\n return Math.hypot(deltaX, deltaY);\n};\n\n/**\n * Calculates the moving speed.\n *\n * @param distance - The distance.\n * @param elapsedTime - The time taken to move the distance.\n *\n * @returns The calculated speed, which is the absolute value of delta divided by elapsed time.\n */\nexport const calculateMovingSpeed = (distance: number, elapsedTime: number): number =>\n Math.abs(distance / elapsedTime);\n\n/**\n * Calculates the specified percentage of a given value.\n *\n * @param value - The value to calculate the percentage of.\n * @param percentage - The percentage to calculate.\n *\n * @returns The calculated percentage of the value.\n */\nexport const calculatePercentage = (value: number, percentage: number): number => {\n return (value * percentage) / 100;\n};\n","interface HTMLElementTransformationValues {\n translateX: number;\n translateY: number;\n scaleX: number;\n scaleY: number;\n skewX: number;\n skewY: number;\n}\n\n/**\n * Extracts transformation values (translate, scale, skew) from the 2D transformation matrix of a given HTML element.\n *\n * Only works with 2D transforms (i.e., `matrix(a, b, c, d, e, f)`).\n *\n * @param element - The element with a CSS transform applied.\n * @returns An object with parsed transformation values.\n *\n * @example\n * ```ts\n * const values = parse2DMatrix(myElement);\n * console.log(values.translateX);\n * console.log(values.scaleX);\n * ```\n */\nexport const parse2DMatrix = (element: HTMLElement): HTMLElementTransformationValues => {\n const computedStyles = window.getComputedStyle(element);\n const transformValue = computedStyles.getPropertyValue('transform');\n\n const matrixMatch = transformValue.match(/^matrix\\((.+)\\)$/);\n if (!matrixMatch) {\n return {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n skewX: 0,\n skewY: 0,\n };\n }\n\n const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrixMatch[1]\n .split(', ')\n .map(parseFloat);\n\n return {\n translateX,\n translateY,\n scaleX,\n scaleY,\n skewX,\n skewY,\n };\n};\n\n/**\n * Creates a clone of a Blob object.\n *\n * @param blob - The Blob object to clone.\n *\n * @returns A new Blob with the same content and type as the original.\n */\nexport const cloneBlob = (blob: Blob): Blob => new Blob([blob], { type: blob.type });\n\n/**\n * Converts a `Blob` object into a `File` object with the specified name.\n *\n * This is useful when you receive a `Blob` (e.g., from canvas, fetch, or file manipulation)\n * and need to convert it into a `File` to upload via `FormData` or file inputs.\n *\n * @param blob - The `Blob` to convert.\n * @param fileName - The desired name for the resulting file (including extension).\n *\n * @returns A `File` instance with the same content and MIME type as the input `Blob`.\n *\n * @example\n * ```ts\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const file = convertBlobToFile(blob, 'hello.txt');\n *\n * console.log(file instanceof File); // true\n * ```\n */\nexport const convertBlobToFile = (blob: Blob, fileName: string): File =>\n new File([blob], fileName, {\n type: blob.type,\n });\n\n/**\n * Calculates the intersection ratio between two DOM rectangles.\n *\n * The ratio represents the proportion of the `targetRect` that is covered by `sourceRect`.\n * A value of `1` means `sourceRect` completely covers `targetRect`, and `0` means no overlap.\n *\n * @param sourceRect - The rectangle used to measure overlap against the target.\n * @param targetRect - The rectangle whose covered area is measured.\n *\n * @returns A number between `0` and `1` representing the intersection ratio.\n */\nexport const getDOMRectIntersectionRatio = (sourceRect: DOMRect, targetRect: DOMRect): number => {\n const xOverlap = Math.max(\n 0,\n Math.min(sourceRect.right, targetRect.right) - Math.max(sourceRect.left, targetRect.left),\n );\n\n const yOverlap = Math.max(\n 0,\n Math.min(sourceRect.bottom, targetRect.bottom) - Math.max(sourceRect.top, targetRect.top),\n );\n\n const intersectionArea = xOverlap * yOverlap;\n const targetArea = targetRect.width * targetRect.height;\n\n return intersectionArea / targetArea;\n};\n\n/**\n * Returns the bounding DOMRect of an element based on offset and client dimensions.\n *\n * This utility is useful when you need a stable, layout-based rect\n * without triggering a reflow via `getBoundingClientRect()`.\n *\n * @param element - The target HTML element.\n * @returns A `DOMRect` representing the element’s offset position and size.\n */\nexport const getElementOffsetRect = (element: HTMLElement): DOMRect =>\n new DOMRect(element.offsetLeft, element.offsetTop, element.clientWidth, element.clientHeight);\n"],"names":["__webpack_require__","assert","condition","message","Error","d","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","isNull","value","isNil","isNilOrEmptyString","isDefined","isString","isNumber","isBool","isObject","isEmptyObject","keys","length","isArray","Array","isEmptyArray","isFunction","isPromise","then","isDate","Date","isValidDate","isNaN","getTime","isRegExp","RegExp","isMap","Map","isSet","Set","isSymbol","isUndefined","undefined","isFiniteNumber","isFinite","isInteger","Number","compact","array","filter","Boolean","unique","chunk","size","from","Math","ceil","_","index","slice","intersection","arrays","first","rest","item","every","includes","difference","exclude","pipe","fns","arg","reduce","prev","fn","compose","reduceRight","runSequential","async","results","i","push","runParallel","Promise","all","map","filterSequential","predicate","filterParallel","someAsync","everyAsync","reduceAsync","initialValue","accumulator","findAsync","toKebabCase","input","replace","toLowerCase","camelToDashCase","firstChar","charAt","restOfString","letter","splitStringIntoWords","split","hashString","hash","charCodeAt","toString","noop","invokeIfFunction","args","delay","delayMs","resolve","setTimeout","timeout","promise","timeoutMs","errorMessage","timeoutId","timeoutPromise","reject","race","clearTimeout","retry","task","maxAttempts","backoff","onRetry","lastError","attempt","e","delayTime","calculateEuclideanDistance","startX","startY","endX","endY","deltaX","deltaY","hypot","calculateMovingSpeed","distance","elapsedTime","abs","calculatePercentage","percentage","parse2DMatrix","element","matrixMatch","window","getComputedStyle","getPropertyValue","match","translateX","translateY","scaleX","scaleY","skewX","skewY","parseFloat","cloneBlob","blob","Blob","type","convertBlobToFile","fileName","File","getDOMRectIntersectionRatio","sourceRect","targetRect","max","min","right","left","bottom","top","width","height","getElementOffsetRect","DOMRect","offsetLeft","offsetTop","clientWidth","clientHeight"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-hive/honey-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A lightweight TypeScript utility library providing a collection of helper functions for common programming tasks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utils",
|
|
@@ -43,21 +43,21 @@
|
|
|
43
43
|
"!dist/**/jest*"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@eslint/js": "9.
|
|
47
|
-
"@mdx-js/loader": "3.1.
|
|
46
|
+
"@eslint/js": "9.36.0",
|
|
47
|
+
"@mdx-js/loader": "3.1.1",
|
|
48
48
|
"@types/jest": "29.5.14",
|
|
49
|
-
"@types/node": "22.
|
|
50
|
-
"copy-webpack-plugin": "13.0.
|
|
51
|
-
"eslint": "9.
|
|
49
|
+
"@types/node": "22.18.8",
|
|
50
|
+
"copy-webpack-plugin": "13.0.1",
|
|
51
|
+
"eslint": "9.36.0",
|
|
52
52
|
"eslint-plugin-react": "7.37.5",
|
|
53
|
-
"html-webpack-plugin": "5.6.
|
|
53
|
+
"html-webpack-plugin": "5.6.4",
|
|
54
54
|
"jest": "29.7.0",
|
|
55
55
|
"prettier": "3.6.2",
|
|
56
|
-
"ts-jest": "29.4.
|
|
57
|
-
"ts-loader": "9.5.
|
|
58
|
-
"typescript": "5.
|
|
59
|
-
"typescript-eslint": "8.
|
|
60
|
-
"webpack": "5.
|
|
56
|
+
"ts-jest": "29.4.4",
|
|
57
|
+
"ts-loader": "9.5.4",
|
|
58
|
+
"typescript": "5.9.3",
|
|
59
|
+
"typescript-eslint": "8.45.0",
|
|
60
|
+
"webpack": "5.102.0",
|
|
61
61
|
"webpack-cli": "6.0.1"
|
|
62
62
|
},
|
|
63
63
|
"jest": {
|