@ts-utilities/core 1.0.1 → 1.0.2

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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2025, Sohan Emon
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,46 +1,282 @@
1
1
  # @ts-utilities/core
2
2
 
3
- Core utilities for JavaScript/TypeScript projects, including React Native.
3
+ ![npm version](https://img.shields.io/npm/v/@ts-utilities/core)
4
+ ![npm downloads](https://img.shields.io/npm/dm/@ts-utilities/core)
5
+ ![License](https://img.shields.io/npm/l/@ts-utilities/core)
6
+ ![Tests](https://github.com/sohanemon/core/actions/workflows/test.yml/badge.svg)
7
+
8
+ ## Description
9
+
10
+ `@ts-utilities/core` is a collection of core utility functions and advanced TypeScript types designed for JavaScript/TypeScript projects. It provides essential utilities for object manipulation, async operations, data transformation, and type-level programming. The library is built with TypeScript and is fully typed, ensuring a smooth and error-free development experience.
11
+
12
+ ## Features
13
+
14
+ - **Object Utilities**: Functions to access and manipulate nested object properties
15
+ - **Data Transformation**: Deep merging, null-to-undefined conversion, and more
16
+ - **Async Operations**: Polling, scheduling, debouncing, throttling, and safe async execution
17
+ - **General Utilities**: Debounce, throttle, sleep, printf, and other common utilities
18
+ - **TypeScript Types**: Advanced utility types for deep partials, guards, and type-level logic gates
19
+ - **React Native Compatible**: All utilities are platform-agnostic and work in React Native environments
4
20
 
5
21
  ## Installation
6
22
 
23
+ You can install `@ts-utilities/core` using npm or yarn:
24
+
7
25
  ```bash
8
26
  npm install @ts-utilities/core
9
27
  ```
10
28
 
29
+ or
30
+
31
+ ```bash
32
+ yarn add @ts-utilities/core
33
+ ```
34
+
11
35
  ## Usage
12
36
 
13
- ```ts
14
- import { deepmerge, debounce, sleep } from '@ts-utilities/core';
37
+ ### Importing Utilities
38
+
39
+ You can import individual utilities or types as needed:
40
+
41
+ ```typescript
42
+ import { deepmerge, poll, shield, sleep, debounce, throttle } from '@ts-utilities/core';
43
+ import { getObjectValue, extendProps, hydrate } from '@ts-utilities/core/functions';
44
+ import type { DeepPartial, Primitive, KeysOfType } from '@ts-utilities/core/types';
45
+ ```
46
+
47
+ ### Examples
48
+
49
+ #### Object Utilities
50
+
51
+ ```typescript
52
+ import { getObjectValue, extendProps } from '@ts-utilities/core';
53
+
54
+ const obj = { a: { b: { c: 1 } } };
55
+ const value = getObjectValue(obj, 'a.b.c'); // 1
56
+
57
+ const extended = extendProps({ a: 1 }, { b: 'hello' }); // { a: 1, b: 'hello' }
58
+ ```
59
+
60
+ #### Data Transformation
61
+
62
+ ```typescript
63
+ import { hydrate, deepmerge } from '@ts-utilities/core';
64
+
65
+ const cleaned = hydrate({ a: null, b: { c: null } }); // { a: undefined, b: { c: undefined } }
66
+
67
+ // Deep merge objects
68
+ const merged = deepmerge({ user: { name: 'John' } }, { user: { age: 30 } });
69
+ // { user: { name: 'John', age: 30 } }
70
+
71
+ // Compose functions automatically
72
+ const composed = deepmerge(
73
+ { onFinish() { console.log('first') } },
74
+ { onFinish() { console.log('second') } },
75
+ { functionMerge: 'compose' }
76
+ );
77
+ // composed.onFinish() logs 'first' then 'second'
78
+
79
+ // Merge functions with custom logic
80
+ const combined = deepmerge(
81
+ { onFinish() { console.log('first') } },
82
+ { onFinish(v) { console.log('second', v) } },
83
+ {
84
+ customMerge: (key, target, source) => {
85
+ if (typeof target === 'function' && typeof source === 'function') {
86
+ return (...args) => { target(...args); source(...args); };
87
+ }
88
+ return source;
89
+ }
90
+ }
91
+ );
92
+ // combined.onFinish('done') logs 'first' then 'second done'
93
+ ```
94
+
95
+ #### Async Operations
96
+
97
+ ```typescript
98
+ import { poll, shield, sleep } from '@ts-utilities/core';
99
+
100
+ const result = await poll(async () => {
101
+ const status = await checkStatus();
102
+ return status === 'ready' ? status : null;
103
+ }, { interval: 2000, timeout: 30000 });
104
+
105
+ const [error, data] = await shield(fetchData());
106
+ ```
107
+
108
+ #### Debounce and Throttle
15
109
 
16
- // Example usage
17
- const merged = deepmerge({ a: 1 }, { b: 2 });
18
- const debouncedFn = debounce(() => console.log('called'), 300);
19
- await sleep(1000);
110
+ ```typescript
111
+ import { debounce, throttle } from '@ts-utilities/core';
112
+
113
+ const debouncedFunction = debounce(() => console.log('Debounced!'), 300);
114
+ const throttledFunction = throttle(() => console.log('Throttled!'), 300);
115
+ ```
116
+
117
+ #### TypeScript Types
118
+
119
+ ```typescript
120
+ import type { DeepPartial, Nullable, KeysOfType, Primitive } from '@ts-utilities/core/types';
121
+
122
+ type PartialUser = DeepPartial<User>;
123
+ type NullableUser = Nullable<User>;
124
+ type StringKeys = KeysOfType<User, string>;
20
125
  ```
21
126
 
22
- ## What's Included
127
+ ## API Documentation
23
128
 
24
129
  ### Functions
25
130
 
26
- - **deepmerge**: Advanced object merging with circular reference detection
27
- - **hydrate**: Convert null values to undefined in data structures
28
- - **object**: Utilities for working with nested objects (getObjectValue, extendProps)
29
- - **poll**: Async polling with timeout and abort signal support
30
- - **schedule**: Background task execution with retry logic
31
- - **shield**: Safe error handling for sync/async operations
32
- - **utils**: General utilities (debounce, throttle, sleep, printf, etc.)
131
+ #### Object Utilities
132
+ ```typescript
133
+ getObjectValue<T, K extends Array<string | number>, D>(
134
+ obj: T,
135
+ path: K,
136
+ defaultValue: D
137
+ ): Exclude<GetValue<T, K>, undefined> | D;
138
+
139
+ getObjectValue<T, K extends Array<string | number>>(
140
+ obj: T,
141
+ path: K
142
+ ): GetValue<T, K> | undefined;
143
+
144
+ getObjectValue<T, S extends string, D>(
145
+ obj: T,
146
+ path: S,
147
+ defaultValue: D
148
+ ): Exclude<GetValue<T, SplitPath<S>>, undefined> | D;
149
+
150
+ getObjectValue<T, S extends string>(
151
+ obj: T,
152
+ path: S
153
+ ): GetValue<T, SplitPath<S>> | undefined;
154
+
155
+ extendProps<T, P extends object>(
156
+ base: T,
157
+ props: P
158
+ ): T extends null | undefined ? T : T & P;
159
+ ```
160
+
161
+ #### Data Transformation
162
+ ```typescript
163
+ hydrate<T>(data: T): Hydrate<T>
164
+
165
+ deepmerge<T extends Record<string, any>, S extends Record<string, any>[]>(
166
+ target: T,
167
+ ...sources: S
168
+ ): TMerged<T | S[number]>
169
+
170
+ deepmerge<T extends Record<string, any>, S extends Record<string, any>[]>(
171
+ target: T,
172
+ sources: S,
173
+ options?: DeepMergeOptions
174
+ ): TMerged<T | S[number]>
175
+ ```
176
+
177
+ #### Async & Scheduling
178
+ ```typescript
179
+ poll<T>(
180
+ cond: () => Promise<T | null | false | undefined>,
181
+ options?: {
182
+ interval?: number;
183
+ timeout?: number;
184
+ signal?: AbortSignal;
185
+ jitter?: boolean;
186
+ }
187
+ ): Promise<T>
188
+
189
+ schedule(task: Task, options?: ScheduleOpts): void
190
+
191
+ shield<T, E = Error>(operation: Promise<T>): Promise<[E | null, T | null]>
192
+ shield<T, E = Error>(operation: () => T): [E | null, T | null]
193
+
194
+ sleep(time?: number, signal?: AbortSignal): Promise<void>
195
+
196
+ debounce<F extends (...args: any[]) => any>(
197
+ function_: F,
198
+ wait?: number,
199
+ options?: { immediate?: boolean }
200
+ ): DebouncedFunction<F>
201
+
202
+ throttle<F extends (...args: any[]) => any>(
203
+ function_: F,
204
+ wait?: number,
205
+ options?: { leading?: boolean; trailing?: boolean }
206
+ ): ThrottledFunction<F>
207
+ ```
33
208
 
34
209
  ### Types
35
210
 
36
- - **gates**: Type-level logic gates (AND, OR, XOR, etc.)
37
- - **guards**: Type guards and primitive checks
38
- - **utilities**: Advanced TypeScript utilities (DeepPartial, KeysOfType, etc.)
211
+ #### Utility Types
212
+ ```typescript
213
+ Keys<T extends object>: keyof T
214
+ Values<T extends object>: T[keyof T]
215
+ DeepPartial<T>: T with all properties optional recursively
216
+ SelectivePartial<T, K>: T with selected keys optional
217
+ DeepRequired<T>: T with all properties required recursively
218
+ SelectiveRequired<T, K>: T with selected keys required
219
+ Never<T>: Object with never values
220
+ Nullable<T>: T with null added to primitives
221
+ Optional<T>: T with undefined added to primitives
222
+ Nullish<T>: T with null|undefined added to primitives
223
+ Maybe<T>: T with all properties optional and nullish
224
+ DeepReadonly<T>: T with all properties readonly recursively
225
+ Mutable<T>: T with readonly removed
226
+ KeysOfType<T, U>: Keys of T where value is U
227
+ OmitByType<T, U>: T without properties of type U
228
+ RequiredKeys<T, K>: T with selected keys required
229
+ Diff<T, U>: Properties in T or U but not both
230
+ Intersection<T, U>: Common properties
231
+ Merge<T, U>: Merged object
232
+ Substract<T, U>: T without U properties
233
+ AllOrNone<T>: T or empty object
234
+ OneOf<T>: Union of single property objects
235
+ TwoOf<T>: Union of two property objects
236
+ Prettify<T>: Clean type representation
237
+ NestedKeyOf<T>: All nested keys as strings
238
+ Without<T, U>: T without U keys
239
+ ```
240
+
241
+ #### Type Guards & Primitives
242
+ ```typescript
243
+ Primitive: string | number | bigint | boolean | symbol | null | undefined
244
+ Falsy: false | '' | 0 | null | undefined
245
+
246
+ isFalsy(val: unknown): val is Falsy
247
+ isNullish(val: unknown): val is nullish
248
+ isPrimitive(val: unknown): val is Primitive
249
+ isPlainObject(value: unknown): value is Record<string, any>
250
+ ```
251
+
252
+ #### Logic Gates
253
+ ```typescript
254
+ BUFFER<T>: T
255
+ IMPLIES<T, U>: true if T extends U
256
+ XOR_Binary<T, U>: T | U with exclusions
257
+ XNOR_Binary<T, U>: T & U | neither
258
+ AND<T extends any[]>: All true
259
+ OR<T extends any[]>: At least one true
260
+ XOR<T extends any[]>: Odd number true
261
+ XNOR<T extends any[]>: Even number true
262
+ NOT<T>: Never properties
263
+ NAND<T extends any[]>: NOT AND
264
+ NOR<T extends any[]>: NOT OR
265
+ ```
39
266
 
40
267
  ## React Native Compatibility
41
268
 
42
269
  This package is designed to work in React Native environments. All included utilities are platform-agnostic and don't depend on DOM APIs.
43
270
 
271
+ ## Contributing
272
+
273
+ Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines on how to contribute to the project.
274
+
44
275
  ## License
45
276
 
46
- ISC
277
+ This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
278
+
279
+ ## Contact
280
+
281
+ - **Sohan Emon**: [sohanemon@outlook.com](mailto:sohanemon@outlook.com)
282
+ - **GitHub**: [sohanemon](https://github.com/sohanemon)
@@ -0,0 +1 @@
1
+ require(`../types-Cr826iDM.cjs`);const e=require(`../functions-Bj4KwuS7.cjs`);exports.convertToNormalCase=e.i,exports.convertToSlug=e.a,exports.debounce=e.o,exports.deepmerge=e.h,exports.escapeRegExp=e.s,exports.extendProps=e.f,exports.getObjectValue=e.p,exports.hydrate=e.m,exports.normalizeText=e.c,exports.poll=e.r,exports.printf=e.l,exports.schedule=e.n,exports.shield=e.t,exports.sleep=e.u,exports.throttle=e.d;
@@ -0,0 +1,2 @@
1
+ import { _ as DeepMergeOptions, a as normalizeText, c as throttle, d as Task, f as schedule, g as hydrate, h as getObjectValue, i as escapeRegExp, l as shield, m as extendProps, n as convertToSlug, o as printf, p as poll, r as debounce, s as sleep, t as convertToNormalCase, u as ScheduleOpts, v as deepmerge } from "../index-CODZbfqn.cjs";
2
+ export { DeepMergeOptions, ScheduleOpts, Task, convertToNormalCase, convertToSlug, debounce, deepmerge, escapeRegExp, extendProps, getObjectValue, hydrate, normalizeText, poll, printf, schedule, shield, sleep, throttle };
@@ -0,0 +1,2 @@
1
+ import { _ as DeepMergeOptions, a as normalizeText, c as throttle, d as Task, f as schedule, g as hydrate, h as getObjectValue, i as escapeRegExp, l as shield, m as extendProps, n as convertToSlug, o as printf, p as poll, r as debounce, s as sleep, t as convertToNormalCase, u as ScheduleOpts, v as deepmerge } from "../index-BlbkY6UJ.js";
2
+ export { DeepMergeOptions, ScheduleOpts, Task, convertToNormalCase, convertToSlug, debounce, deepmerge, escapeRegExp, extendProps, getObjectValue, hydrate, normalizeText, poll, printf, schedule, shield, sleep, throttle };
@@ -0,0 +1 @@
1
+ import"../types-CExAEo2W.js";import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"../functions-DOWFQTb6.js";export{a as convertToNormalCase,e as convertToSlug,l as debounce,i as deepmerge,f as escapeRegExp,r as extendProps,u as getObjectValue,s as hydrate,t as normalizeText,d as poll,o as printf,c as schedule,p as shield,m as sleep,n as throttle};
@@ -0,0 +1 @@
1
+ const e=require(`./types-Cr826iDM.cjs`);function t(t,...n){let r,i={},a=n[n.length-1];a&&typeof a==`object`&&!Array.isArray(a)&&(a.arrayMerge!==void 0||a.clone!==void 0||a.customMerge!==void 0||a.functionMerge!==void 0||a.maxDepth!==void 0)?(i={...i,...a},r=n.slice(0,-1)):r=n;let{arrayMerge:o=`replace`,clone:s=!0,functionMerge:c=`replace`,maxDepth:l=100,customMerge:u}=i,d=new WeakMap;return f(t,r,0);function f(t,n,r){if(r>=l)return console.warn(`[deepmerge] Maximum depth ${l} exceeded. Returning target as-is.`),t;if(!e.r(t)&&!Array.isArray(t)){for(let e of n)if(e!==void 0){if(u){let n=u(``,t,e);if(n!==void 0)return n}return typeof t==`function`&&typeof e==`function`&&c===`compose`?(...n)=>{t(...n),e(...n)}:e}return t}let i=s?Array.isArray(t)?[...t]:{...t}:t;for(let t of n)if(t!=null&&!d.has(t))if(d.set(t,i),Array.isArray(i)&&Array.isArray(t))i=p(i,t,o);else if(e.r(i)&&e.r(t)){let n=new Set([...Object.keys(i),...Object.keys(t),...Object.getOwnPropertySymbols(i),...Object.getOwnPropertySymbols(t)]);for(let a of n){let n=i[a],s=t[a];u&&u(a,n,s)!==void 0?i[a]=u(a,n,s):typeof n==`function`&&typeof s==`function`?c===`compose`?i[a]=(...e)=>{n(...e),s(...e)}:i[a]=s:e.r(n)&&e.r(s)?i[a]=f(n,[s],r+1):Array.isArray(n)&&Array.isArray(s)?i[a]=p(n,s,o):s!==void 0&&(i[a]=s)}}else i=t;return i}function p(t,n,r){if(typeof r==`function`)return r(t,n);switch(r){case`concat`:return[...t,...n];case`merge`:let r=Math.max(t.length,n.length),i=[];for(let a=0;a<r;a++)a<t.length&&a<n.length?e.r(t[a])&&e.r(n[a])?i[a]=f(t[a],[n[a]],0):i[a]=n[a]:a<t.length?i[a]=t[a]:i[a]=n[a];return i;case`replace`:default:return[...n]}}}function n(e){return r(e)}function r(t){if(t!==null){if(typeof t!=`object`||!t)return t;if(Array.isArray(t))return t.map(r);if(e.r(t)){let e={};for(let n in t)e[n]=r(t[n]);return e}return t}}function i(e,t,n){if(typeof t!=`string`&&!Array.isArray(t))return n;let r=(()=>Array.isArray(t)?t:t===``?[]:String(t).split(`.`).filter(e=>e!==``))();if(!Array.isArray(r))return n;let i=e;for(let e of r){if(i==null)return n;let t=typeof e==`string`&&Array.isArray(i)&&/^\d+$/.test(e)?Number.parseInt(e,10):e;i=i[t]}return i===void 0?n:i}function a(e,t){return e==null?e:Object.assign(e,t)}function o(e){return(e.split(`.`).pop()||e).replace(/([a-z])([A-Z])/g,`$1 $2`).split(/[-_|�\s]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}const s=`àáãäâèéëêìíïîòóöôùúüûñç·/_,:;`,c=`aaaaaeeeeiiiioooouuuunc------`,l=e=>{if(typeof e!=`string`)throw TypeError(`Input must be a string`);let t=e.trim().toLowerCase(),n={};for(let e=0;e<29;e++)n[s.charAt(e)]=`aaaaaeeeeiiiioooouuuunc------`.charAt(e);return t=t.replace(RegExp(`[${s}]`,`g`),e=>n[e]||e),t.replace(/[^a-z0-9 -]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-+/,``).replace(/-+$/,``)||``},u=(e=1e3,t)=>new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(()=>{a(),n()},e);function i(){clearTimeout(r),a(),n()}function a(){t?.removeEventListener(`abort`,i)}t&&t.addEventListener(`abort`,i,{once:!0})});function d(e,t=100,n){if(typeof e!=`function`)throw TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw RangeError("`wait` must not be negative.");let r=n?.immediate??!1,i,a,o,s;function c(){return s=e.apply(o,a),a=void 0,o=void 0,s}let l=function(...e){return a=e,o=this,i===void 0&&r&&(s=c.call(this)),i!==void 0&&clearTimeout(i),i=setTimeout(c.bind(this),t),s};return Object.defineProperty(l,`isPending`,{get(){return i!==void 0}}),l}function f(e,t=100,n){if(typeof e!=`function`)throw TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw RangeError("`wait` must not be negative.");let r=n?.leading??!0,i=n?.trailing??!0,a,o,s,c,l;function u(){c=Date.now(),l=e.apply(s,o),o=void 0,s=void 0}function d(){a=void 0,i&&o&&u()}let f=function(...e){let n=c?Date.now()-c:1/0;return o=e,s=this,n>=t?r?u():a=setTimeout(d,t):!a&&i&&(a=setTimeout(d,t-n)),l};return Object.defineProperty(f,`isPending`,{get(){return a!==void 0}}),f}function p(e,...t){let n=t.length===1&&Array.isArray(t[0])?t[0]:t,r=0;return e.replace(/%s/g,()=>{let e=n[r++];return e===void 0?``:String(e)})}function m(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function h(e,t={}){if(!e)return``;let{lowercase:n=!0,removeAccents:r=!0,removeNonAlphanumeric:i=!0}=t,a=e.normalize(`NFC`);return r&&(a=a.normalize(`NFD`).replace(/\p{M}/gu,``)),i&&(a=a.replace(/^[^\p{L}\p{N}]*|[^\p{L}\p{N}]*$/gu,``)),n&&(a=a.toLocaleLowerCase()),a}async function g(e,{interval:t=5e3,timeout:n=300*1e3,jitter:r=!0,signal:i}={}){let a=Date.now(),o=i?.aborted??!1,s=()=>{o=!0};i?.addEventListener(`abort`,s,{once:!0});try{for(let s=0;;s++){if(o)throw Error(`Polling aborted`);let s=await e();if(s)return s;if(Date.now()-a>=n)throw Error(`Polling timed out`,{cause:`Polling timed out after ${n}ms`});await u(r?t+(Math.random()-.5)*t*.2:t,i)}}catch(e){throw e}finally{i?.removeEventListener(`abort`,s)}}function _(e,t={}){let{retry:n=0,delay:r=0}=t,i=Date.now(),a=async t=>{try{await e();let t=Date.now()-i;console.log(`⚡[schedule.ts] Completed in ${t}ms`)}catch(e){if(console.log(`⚡[schedule.ts] err:`,e),t>0)console.log(`⚡[schedule.ts] Retrying in ${r}ms...`),setTimeout(()=>a(t-1),r);else{let e=Date.now()-i;console.log(`⚡[schedule.ts] Failed after ${e}ms`)}}};setTimeout(()=>a(n),0)}function v(e){if(e instanceof Promise)return e.then(e=>[null,e]).catch(e=>[e,null]);try{return[null,e()]}catch(t){return console.log(`\x1b[31m🛡 [shield]\x1b[0m ${e.name} failed →`,t),[t,null]}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return u}});
@@ -0,0 +1 @@
1
+ import{r as e}from"./types-CExAEo2W.js";function t(t,...n){let r,i={},a=n[n.length-1];a&&typeof a==`object`&&!Array.isArray(a)&&(a.arrayMerge!==void 0||a.clone!==void 0||a.customMerge!==void 0||a.functionMerge!==void 0||a.maxDepth!==void 0)?(i={...i,...a},r=n.slice(0,-1)):r=n;let{arrayMerge:o=`replace`,clone:s=!0,functionMerge:c=`replace`,maxDepth:l=100,customMerge:u}=i,d=new WeakMap;return f(t,r,0);function f(t,n,r){if(r>=l)return console.warn(`[deepmerge] Maximum depth ${l} exceeded. Returning target as-is.`),t;if(!e(t)&&!Array.isArray(t)){for(let e of n)if(e!==void 0){if(u){let n=u(``,t,e);if(n!==void 0)return n}return typeof t==`function`&&typeof e==`function`&&c===`compose`?(...n)=>{t(...n),e(...n)}:e}return t}let i=s?Array.isArray(t)?[...t]:{...t}:t;for(let t of n)if(t!=null&&!d.has(t))if(d.set(t,i),Array.isArray(i)&&Array.isArray(t))i=p(i,t,o);else if(e(i)&&e(t)){let n=new Set([...Object.keys(i),...Object.keys(t),...Object.getOwnPropertySymbols(i),...Object.getOwnPropertySymbols(t)]);for(let a of n){let n=i[a],s=t[a];u&&u(a,n,s)!==void 0?i[a]=u(a,n,s):typeof n==`function`&&typeof s==`function`?c===`compose`?i[a]=(...e)=>{n(...e),s(...e)}:i[a]=s:e(n)&&e(s)?i[a]=f(n,[s],r+1):Array.isArray(n)&&Array.isArray(s)?i[a]=p(n,s,o):s!==void 0&&(i[a]=s)}}else i=t;return i}function p(t,n,r){if(typeof r==`function`)return r(t,n);switch(r){case`concat`:return[...t,...n];case`merge`:let r=Math.max(t.length,n.length),i=[];for(let a=0;a<r;a++)a<t.length&&a<n.length?e(t[a])&&e(n[a])?i[a]=f(t[a],[n[a]],0):i[a]=n[a]:a<t.length?i[a]=t[a]:i[a]=n[a];return i;case`replace`:default:return[...n]}}}function n(e){return r(e)}function r(t){if(t!==null){if(typeof t!=`object`||!t)return t;if(Array.isArray(t))return t.map(r);if(e(t)){let e={};for(let n in t)e[n]=r(t[n]);return e}return t}}function i(e,t,n){if(typeof t!=`string`&&!Array.isArray(t))return n;let r=(()=>Array.isArray(t)?t:t===``?[]:String(t).split(`.`).filter(e=>e!==``))();if(!Array.isArray(r))return n;let i=e;for(let e of r){if(i==null)return n;let t=typeof e==`string`&&Array.isArray(i)&&/^\d+$/.test(e)?Number.parseInt(e,10):e;i=i[t]}return i===void 0?n:i}function a(e,t){return e==null?e:Object.assign(e,t)}function o(e){return(e.split(`.`).pop()||e).replace(/([a-z])([A-Z])/g,`$1 $2`).split(/[-_|�\s]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}const s=`àáãäâèéëêìíïîòóöôùúüûñç·/_,:;`,c=e=>{if(typeof e!=`string`)throw TypeError(`Input must be a string`);let t=e.trim().toLowerCase(),n={};for(let e=0;e<29;e++)n[s.charAt(e)]=`aaaaaeeeeiiiioooouuuunc------`.charAt(e);return t=t.replace(RegExp(`[${s}]`,`g`),e=>n[e]||e),t.replace(/[^a-z0-9 -]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-+/,``).replace(/-+$/,``)||``},l=(e=1e3,t)=>new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(()=>{a(),n()},e);function i(){clearTimeout(r),a(),n()}function a(){t?.removeEventListener(`abort`,i)}t&&t.addEventListener(`abort`,i,{once:!0})});function u(e,t=100,n){if(typeof e!=`function`)throw TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw RangeError("`wait` must not be negative.");let r=n?.immediate??!1,i,a,o,s;function c(){return s=e.apply(o,a),a=void 0,o=void 0,s}let l=function(...e){return a=e,o=this,i===void 0&&r&&(s=c.call(this)),i!==void 0&&clearTimeout(i),i=setTimeout(c.bind(this),t),s};return Object.defineProperty(l,`isPending`,{get(){return i!==void 0}}),l}function d(e,t=100,n){if(typeof e!=`function`)throw TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw RangeError("`wait` must not be negative.");let r=n?.leading??!0,i=n?.trailing??!0,a,o,s,c,l;function u(){c=Date.now(),l=e.apply(s,o),o=void 0,s=void 0}function d(){a=void 0,i&&o&&u()}let f=function(...e){let n=c?Date.now()-c:1/0;return o=e,s=this,n>=t?r?u():a=setTimeout(d,t):!a&&i&&(a=setTimeout(d,t-n)),l};return Object.defineProperty(f,`isPending`,{get(){return a!==void 0}}),f}function f(e,...t){let n=t.length===1&&Array.isArray(t[0])?t[0]:t,r=0;return e.replace(/%s/g,()=>{let e=n[r++];return e===void 0?``:String(e)})}function p(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function m(e,t={}){if(!e)return``;let{lowercase:n=!0,removeAccents:r=!0,removeNonAlphanumeric:i=!0}=t,a=e.normalize(`NFC`);return r&&(a=a.normalize(`NFD`).replace(/\p{M}/gu,``)),i&&(a=a.replace(/^[^\p{L}\p{N}]*|[^\p{L}\p{N}]*$/gu,``)),n&&(a=a.toLocaleLowerCase()),a}async function h(e,{interval:t=5e3,timeout:n=300*1e3,jitter:r=!0,signal:i}={}){let a=Date.now(),o=i?.aborted??!1,s=()=>{o=!0};i?.addEventListener(`abort`,s,{once:!0});try{for(let s=0;;s++){if(o)throw Error(`Polling aborted`);let s=await e();if(s)return s;if(Date.now()-a>=n)throw Error(`Polling timed out`,{cause:`Polling timed out after ${n}ms`});await l(r?t+(Math.random()-.5)*t*.2:t,i)}}catch(e){throw e}finally{i?.removeEventListener(`abort`,s)}}function g(e,t={}){let{retry:n=0,delay:r=0}=t,i=Date.now(),a=async t=>{try{await e();let t=Date.now()-i;console.log(`⚡[schedule.ts] Completed in ${t}ms`)}catch(e){if(console.log(`⚡[schedule.ts] err:`,e),t>0)console.log(`⚡[schedule.ts] Retrying in ${r}ms...`),setTimeout(()=>a(t-1),r);else{let e=Date.now()-i;console.log(`⚡[schedule.ts] Failed after ${e}ms`)}}};setTimeout(()=>a(n),0)}function _(e){if(e instanceof Promise)return e.then(e=>[null,e]).catch(e=>[e,null]);try{return[null,e()]}catch(t){return console.log(`\x1b[31m🛡 [shield]\x1b[0m ${e.name} failed →`,t),[t,null]}}export{c as a,m as c,d,a as f,t as h,o as i,f as l,n as m,g as n,u as o,i as p,h as r,p as s,_ as t,l as u};