@homedev/framework 0.0.2 → 0.0.3
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/dist/index.d.ts +313 -0
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructor for creating async functions dynamically from source code strings.
|
|
3
|
+
* Equivalent to the built-in async function constructor.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const fn = new AsyncFunction('x', 'y', 'return x + y')
|
|
8
|
+
* await fn(2, 3) // 5
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
declare const AsyncFunction_2: any;
|
|
12
|
+
export { AsyncFunction_2 as AsyncFunction }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Guards against undefined and null values.
|
|
16
|
+
* Throws an error if the value is nullish, otherwise returns the value.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The value to check
|
|
19
|
+
* @param message - Custom error message (default: 'Value is undefined')
|
|
20
|
+
* @returns The value if it is not nullish
|
|
21
|
+
* @throws {Error} When value is undefined or null
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const value = defined(maybeUndefined, 'Required value missing')
|
|
26
|
+
* // value is guaranteed to be non-nullish here
|
|
27
|
+
*
|
|
28
|
+
* defined(0) // 0 (falsy but not nullish)
|
|
29
|
+
* defined(false) // false (falsy but not nullish)
|
|
30
|
+
* defined(null) // throws Error: Value is undefined
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare function defined_2<T>(value: T | undefined | null, message?: string): T;
|
|
34
|
+
export { defined_2 as defined }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare type MergeMode = 'merge' | 'source' | 'target' | 'skip';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare interface MergeOptions {
|
|
45
|
+
conflict?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
46
|
+
mismatch?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
47
|
+
navigate?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => boolean | undefined;
|
|
48
|
+
mode?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => MergeMode | void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare enum NavigateAction {
|
|
55
|
+
Explore = 0,
|
|
56
|
+
SkipSiblings = 1,
|
|
57
|
+
NoExplore = 2,
|
|
58
|
+
ReplaceParent = 3,
|
|
59
|
+
DeleteParent = 4,
|
|
60
|
+
MergeParent = 5,
|
|
61
|
+
ReplaceItem = 6,
|
|
62
|
+
DeleteItem = 7
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare type NavigateCallback = (context: NavigateContext) => Promise<NavigateResult> | NavigateResult;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export declare interface NavigateContext {
|
|
74
|
+
key: string;
|
|
75
|
+
value: any;
|
|
76
|
+
path: string[];
|
|
77
|
+
parent: any;
|
|
78
|
+
parents: any[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export declare class NavigateResult {
|
|
85
|
+
readonly action: NavigateAction;
|
|
86
|
+
by?: any | undefined;
|
|
87
|
+
skipSiblings?: boolean | undefined;
|
|
88
|
+
reexplore?: boolean | undefined;
|
|
89
|
+
constructor(action: NavigateAction, by?: any | undefined, skipSiblings?: boolean | undefined, reexplore?: boolean | undefined);
|
|
90
|
+
private static readonly _explore;
|
|
91
|
+
private static readonly _noExplore;
|
|
92
|
+
private static readonly _skipSiblings;
|
|
93
|
+
private static readonly _deleteParent;
|
|
94
|
+
static ReplaceParent(by: any, reexplore?: boolean): NavigateResult;
|
|
95
|
+
static SkipSiblings(): NavigateResult;
|
|
96
|
+
static Explore(): NavigateResult;
|
|
97
|
+
static NoExplore(): NavigateResult;
|
|
98
|
+
static DeleteParent(): NavigateResult;
|
|
99
|
+
static MergeParent(by: any): NavigateResult;
|
|
100
|
+
static ReplaceItem(by: any, skipSiblings?: boolean): NavigateResult;
|
|
101
|
+
static DeleteItem(skipSiblings?: boolean): NavigateResult;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Options for configuring the select function behavior
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
export declare interface SelectOptions {
|
|
109
|
+
/** Value to set at the selected path */
|
|
110
|
+
set?: any;
|
|
111
|
+
/** Alternative key to use (currently unused) */
|
|
112
|
+
key?: string;
|
|
113
|
+
/** Path separator character (default: '.') */
|
|
114
|
+
separator?: string;
|
|
115
|
+
/** Default value to return when path is not found */
|
|
116
|
+
defaultValue?: any;
|
|
117
|
+
/** If true, returns undefined instead of throwing on missing paths */
|
|
118
|
+
optional?: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { }
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
/* Global declarations */
|
|
125
|
+
|
|
126
|
+
declare global {
|
|
127
|
+
type Constructor<T = any> = new (...args: any[]) => T;
|
|
128
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
129
|
+
type AsyncFunction<T = any> = (...args: any[]) => Promise<T>;
|
|
130
|
+
var AsyncFunction: typeof Function;
|
|
131
|
+
var defined: <T>(value: T | undefined | null, msg?: string) => T;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
declare global {
|
|
137
|
+
interface Array<T> {
|
|
138
|
+
mapAsync<U>(callback: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]>;
|
|
139
|
+
forEachAsync(callback: (value: T, index: number, array: T[]) => Promise<void>): Promise<void>;
|
|
140
|
+
sortBy<K extends keyof T>(selector: (item: T) => T[K], ascending?: boolean): T[];
|
|
141
|
+
unique(): T[];
|
|
142
|
+
uniqueBy<K extends keyof T>(selector: (item: T) => T[K]): T[];
|
|
143
|
+
groupBy<K extends keyof T>(selector: (item: T) => T[K]): Record<T[K] & (string | number | symbol), T[]>;
|
|
144
|
+
toObject<K extends keyof T, V>(keySelector: (item: T) => T[K], valueSelector?: (item: T) => V): Record<T[K] & (string | number | symbol), V>;
|
|
145
|
+
toObjectWithKey<K extends keyof T>(key: K): Record<string, T>;
|
|
146
|
+
nonNullMap<U>(callback: (value: T, index: number, array: T[]) => U | null | undefined): U[];
|
|
147
|
+
nonNullMapAsync<U>(callback: (value: T, index: number, array: T[]) => Promise<U | null | undefined>): Promise<U[]>;
|
|
148
|
+
findOrFail(predicate: (value: T, index: number, array: T[]) => boolean, message?: string, thisArg?: any): T;
|
|
149
|
+
selectFor<K>(predicate: (value: T, index: number, array: T[]) => boolean, selector: (value: T) => K, message?: string, thisArg?: any): K;
|
|
150
|
+
createInstances<TTarget>(targetConstructor: new (...args: any[]) => TTarget, ...args: any[]): TTarget[];
|
|
151
|
+
mergeAll(options?: MergeOptions): any;
|
|
152
|
+
}
|
|
153
|
+
interface ArrayConstructor {
|
|
154
|
+
flat<T>(v: T | T[] | T[][]): T[];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
declare global {
|
|
162
|
+
interface ObjectConstructor {
|
|
163
|
+
mapEntries<T extends object, U>(obj: T, callback: (key: keyof T, value: T[keyof T]) => [string | number | symbol, U]): Record<string | number | symbol, U>;
|
|
164
|
+
toList<T extends object, U extends object, X extends string>(obj: T, key: X): (Record<X, string> & U)[];
|
|
165
|
+
deepClone<T extends object>(obj: T): T;
|
|
166
|
+
merge(source: any, target: any, options?: MergeOptions): void;
|
|
167
|
+
navigate(o: any, cb: NavigateCallback): Promise<void>;
|
|
168
|
+
find(from: any, cb: (path: string, value: any) => boolean): Promise<any[]>;
|
|
169
|
+
select(from: any, path: string, options?: SelectOptions): any;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Guards against undefined and null values.
|
|
175
|
+
* Throws an error if the value is nullish, otherwise returns the value.
|
|
176
|
+
*
|
|
177
|
+
* @param value - The value to check
|
|
178
|
+
* @param message - Custom error message (default: 'Value is undefined')
|
|
179
|
+
* @returns The value if it is not nullish
|
|
180
|
+
* @throws {Error} When value is undefined or null
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const value = defined(maybeUndefined, 'Required value missing')
|
|
185
|
+
* // value is guaranteed to be non-nullish here
|
|
186
|
+
*
|
|
187
|
+
* defined(0) // 0 (falsy but not nullish)
|
|
188
|
+
* defined(false) // false (falsy but not nullish)
|
|
189
|
+
* defined(null) // throws Error: Value is undefined
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Re-export AsyncFunction constructor from async module.
|
|
194
|
+
* Useful for dynamically creating async functions from source code strings.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const fn = new AsyncFunction('x', 'return x * 2')
|
|
199
|
+
* await fn(5) // 10
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
declare global {
|
|
204
|
+
interface String {
|
|
205
|
+
capitalize(): string;
|
|
206
|
+
toPascal(): string;
|
|
207
|
+
toCamel(): string;
|
|
208
|
+
toSnake(): string;
|
|
209
|
+
toKebab(): string;
|
|
210
|
+
changeCase(to: 'upper' | 'lower' | 'pascal' | 'camel' | 'snake' | 'kebab'): string;
|
|
211
|
+
splitWithQuotes(separator?: string): {
|
|
212
|
+
value: string;
|
|
213
|
+
quoted: boolean;
|
|
214
|
+
}[];
|
|
215
|
+
splitNested(separator: string, open: string, close: string): string[];
|
|
216
|
+
padBlock(indent: number, separator?: string, padder?: string): string;
|
|
217
|
+
tokenize(from: Record<string, unknown>, tokenizer?: RegExp): string;
|
|
218
|
+
stripIndent(): string;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
key: string;
|
|
228
|
+
value: any;
|
|
229
|
+
path: string[];
|
|
230
|
+
parent: any;
|
|
231
|
+
parents: any[];
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
Explore = 0,
|
|
237
|
+
SkipSiblings = 1,
|
|
238
|
+
NoExplore = 2,
|
|
239
|
+
ReplaceParent = 3,
|
|
240
|
+
DeleteParent = 4,
|
|
241
|
+
MergeParent = 5,
|
|
242
|
+
ReplaceItem = 6,
|
|
243
|
+
DeleteItem = 7
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
/**
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
readonly action: NavigateAction;
|
|
252
|
+
by?: any | undefined;
|
|
253
|
+
skipSiblings?: boolean | undefined;
|
|
254
|
+
reexplore?: boolean | undefined;
|
|
255
|
+
constructor(action: NavigateAction, by?: any | undefined, skipSiblings?: boolean | undefined, reexplore?: boolean | undefined);
|
|
256
|
+
private static readonly _explore;
|
|
257
|
+
private static readonly _noExplore;
|
|
258
|
+
private static readonly _skipSiblings;
|
|
259
|
+
private static readonly _deleteParent;
|
|
260
|
+
static ReplaceParent(by: any, reexplore?: boolean): NavigateResult;
|
|
261
|
+
static SkipSiblings(): NavigateResult;
|
|
262
|
+
static Explore(): NavigateResult;
|
|
263
|
+
static NoExplore(): NavigateResult;
|
|
264
|
+
static DeleteParent(): NavigateResult;
|
|
265
|
+
static MergeParent(by: any): NavigateResult;
|
|
266
|
+
static ReplaceItem(by: any, skipSiblings?: boolean): NavigateResult;
|
|
267
|
+
static DeleteItem(skipSiblings?: boolean): NavigateResult;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @public
|
|
273
|
+
*/
|
|
274
|
+
/**
|
|
275
|
+
* @public
|
|
276
|
+
*/
|
|
277
|
+
conflict?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
278
|
+
mismatch?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
279
|
+
navigate?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => boolean | undefined;
|
|
280
|
+
mode?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => MergeMode | void;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Options for configuring the select function behavior
|
|
286
|
+
* @public
|
|
287
|
+
*/
|
|
288
|
+
/** Value to set at the selected path */
|
|
289
|
+
set?: any;
|
|
290
|
+
/** Alternative key to use (currently unused) */
|
|
291
|
+
key?: string;
|
|
292
|
+
/** Path separator character (default: '.') */
|
|
293
|
+
separator?: string;
|
|
294
|
+
/** Default value to return when path is not found */
|
|
295
|
+
defaultValue?: any;
|
|
296
|
+
/** If true, returns undefined instead of throwing on missing paths */
|
|
297
|
+
optional?: boolean;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Array.prototype.findOrFail=function(n,
|
|
2
|
-
`,
|
|
3
|
-
`)};var
|
|
1
|
+
Array.prototype.findOrFail=function(T,n,m){let r=this.find(T,m);if(r===void 0)throw Error(n??"Element not found");return r};Array.flat=function(T){if(Array.isArray(T))return T.flat(2);else return[T]};Array.prototype.forEachAsync=async function(T){for(let n=0;n<this.length;n++)await T(this[n],n,this)};Array.prototype.groupBy=function(T){return this.reduce((n,m)=>{let r=T(m);if(!n[r])n[r]=[];return n[r].push(m),n},{})};Array.prototype.createInstances=function(T,...n){return this.map((m,r)=>new T(...n,m,r))};Array.prototype.mapAsync=async function(T){return Promise.all(this.map(T))};Array.prototype.nonNullMap=function(T){let n=[];for(let m=0;m<this.length;m++){let r=T(this[m],m,this);if(r!=null)n.push(r)}return n};Array.prototype.nonNullMapAsync=async function(T){let n=[];for(let m=0;m<this.length;m++){let r=await T(this[m],m,this);if(r!=null)n.push(r)}return n};Array.prototype.mergeAll=function(T){let n={};for(let m of this.toReversed())Object.merge(m,n,T);return n};Array.prototype.toObject=function(T,n){return Object.fromEntries(this.map((m)=>{let r=T(m),f=n?n(m):m;return[r,f]}))};Array.prototype.toObjectWithKey=function(T){return Object.fromEntries(this.map((n)=>[String(n[T]),n]))};Array.prototype.selectFor=function(T,n,m,r){let f=this.find(T,r);if(f===void 0)throw Error(m??"Element not found");return n(f)};Array.prototype.sortBy=function(T,n=!0){return this.slice().sort((m,r)=>{let f=T(m),b=T(r);if(f<b)return n?-1:1;if(f>b)return n?1:-1;return 0})};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(T){let n=new Set;return this.filter((m)=>{let r=T(m);if(n.has(r))return!1;else return n.add(r),!0})};var y;((x)=>{x[x.Explore=0]="Explore";x[x.SkipSiblings=1]="SkipSiblings";x[x.NoExplore=2]="NoExplore";x[x.ReplaceParent=3]="ReplaceParent";x[x.DeleteParent=4]="DeleteParent";x[x.MergeParent=5]="MergeParent";x[x.ReplaceItem=6]="ReplaceItem";x[x.DeleteItem=7]="DeleteItem"})(y||={});class F{action;by;skipSiblings;reexplore;constructor(T,n,m,r){this.action=T;this.by=n;this.skipSiblings=m;this.reexplore=r}static _explore=new F(0);static _noExplore=new F(2);static _skipSiblings=new F(1);static _deleteParent=new F(4);static ReplaceParent(T,n){return new F(3,T,void 0,n)}static SkipSiblings(){return F._skipSiblings}static Explore(){return F._explore}static NoExplore(){return F._noExplore}static DeleteParent(){return F._deleteParent}static MergeParent(T){return new F(5,T)}static ReplaceItem(T,n){return new F(6,T,n)}static DeleteItem(T){return new F(7,void 0,T)}}Object.navigate=async(T,n)=>{let m=new WeakSet,r=[],f=[],b=async(o,x,E)=>{let O=o===null,A=O?F.Explore():await n({key:o,value:x,path:r,parent:E,parents:f});if(x&&typeof x==="object"&&A.action===0){if(m.has(x))return A;if(m.add(x),!O)r.push(o),f.push(E);let w=x;while(await d(w,o,E))w=E[o];if(!O)f.pop(),r.pop()}return A},d=async(o,x,E)=>{let O=Object.keys(o),U=O.length;for(let A=0;A<U;A++){let B=O[A],C=o[B],w=await b(B,C,o),K=w.action;if(K===0||K===2)continue;if(K===6){if(o[B]=w.by,w.skipSiblings)return;continue}if(K===7){if(delete o[B],w.skipSiblings)return;continue}if(K===1)return;if(K===3){if(x===null)throw Error("Cannot replace root object");if(E[x]=w.by,w.reexplore)return!0;return}if(K===4){if(x===null)throw Error("Cannot delete root object");delete E[x];return}if(K===5)delete o[B],Object.assign(o,w.by)}};await b(null,T,null)};Object.find=async function(T,n){let m=[];return await Object.navigate(T,(r)=>{if(n([...r.path,r.key].join("."),r.value))m.push(r.value);return F.Explore()}),m};Object.merge=(T,n,m)=>{for(let r of Object.keys(n)){if(T[r]===void 0)continue;let f=n[r],b=T[r];if(typeof b!==typeof f||Array.isArray(b)!==Array.isArray(f)){let o=m?.mismatch?.(r,b,f,T,n);if(o!==void 0){n[r]=o;continue}throw Error(`Type mismatch: ${r}`)}let d=m?.mode?.(r,b,f,T,n)??n[".merge"]??"merge";switch(d){case"source":n[r]=b;continue;case"target":continue;case"skip":delete n[r],delete T[r];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${d}`)}if(typeof b==="object")if(Array.isArray(b))f.push(...b);else{if(m?.navigate?.(r,b,f,T,n)===!1)continue;Object.merge(b,f,m)}else{if(b===f)continue;let o=m?.conflict?.(r,b,f,T,n);n[r]=o===void 0?f:o}}for(let r of Object.keys(T))if(n[r]===void 0)n[r]=T[r]};var I=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,X=/^([^[\]]*)\[([^\]]*)]$/,P=(T,n,m,r)=>{if(T.startsWith("{")&&T.endsWith("}")){let f=T.substring(1,T.length-1);return Object.select(n,f,m)?.toString()}return r?T:void 0},j=(T,n,m,r)=>{let f=P(n,m,r);if(f)return Object.select(T,f,r);let b=I.exec(n);if(b){let[,o,x,E]=b,O=P(o.trim(),m,r,!0),U=P(E.trim(),m,r,!0);if(Array.isArray(T)&&(x==="="||x==="==")&&O)return T.find((A)=>A?.[O]==U)}let d=X.exec(n);if(d){let[,o,x]=d;return T?.[o]?.[x]}return T?.[n]};Object.select=(T,n,m)=>{let r=void 0,f=void 0,b=n??"",d=(U)=>{if(!U)return[U,!1];return U.endsWith("?")?[U.substring(0,U.length-1),!0]:[U,!1]},o=(U,A)=>{let[B,C]=d(A.pop());if(!B){if(m?.set!==void 0&&f!==void 0&&r!==void 0)r[f]=m.set;return U}let w=j(U,B,T,m);if(w===void 0){if(C||m?.optional||m?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${B}" in "${b}"`)}return r=U,f=B,o(w,A)},x=b.splitNested(m?.separator??".","{","}"),E=void 0;if(x.length>0&&x[x.length-1].startsWith("?="))E=x.pop()?.substring(2);x.reverse();let O=o(T,x);if(O===void 0)return E??m?.defaultValue;return O};Object.deepClone=function(T){if(typeof structuredClone<"u")try{return structuredClone(T)}catch{}return JSON.parse(JSON.stringify(T))};Object.toList=function(T,n){return Object.entries(T).map(([m,r])=>({[n]:m,...r}))};Object.mapEntries=function(T,n){let r=Object.entries(T).map(([f,b])=>n(f,b));return Object.fromEntries(r)};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;global.defined=(T,n="Value is undefined")=>{if(T===void 0||T===null)throw Error(n);return T};String.prototype.tokenize=function(T,n=/\${([^}]+)}/g){return this.replace(n,(m,r)=>{let f=T[r];if(f===null||f===void 0)return"";if(typeof f==="string")return f;if(typeof f==="number"||typeof f==="boolean")return String(f);return String(f)})};String.prototype.toPascal=function(){return this.replace(/((?:[_ ]+)\w|^\w)/g,(T,n)=>n.toUpperCase()).replace(/[_ ]/g,"")};String.prototype.capitalize=function(){return this.replace(/((?:[ ]+)\w|^\w)/g,(T,n)=>n.toUpperCase())};String.prototype.toCamel=function(){return this.toPascal().replace(/((?:[ ]+\w)|^\w)/g,(T,n)=>n.toLowerCase())};String.prototype.toSnake=function(){return this.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/\s+/g,"_")};String.prototype.toKebab=function(){return this.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-")};String.prototype.changeCase=function(T){switch(T){case"upper":return this.toUpperCase();case"lower":return this.toLowerCase();case"pascal":return this.toPascal();case"camel":return this.toCamel();case"snake":return this.toSnake();case"kebab":return this.toKebab();default:throw Error(`Unsupported case type: ${T}`)}};String.prototype.splitWithQuotes=function(T=","){let n=[],m=this.length,r=T.length,f=0,b=(d)=>{if(d+r>m)return!1;for(let o=0;o<r;o++)if(this[d+o]!==T[o])return!1;return!0};while(f<m){while(f<m&&this[f]===" ")f++;if(f>=m)break;let d="",o=this[f]==='"'||this[f]==="'";if(o){let x=this[f++];while(f<m&&this[f]!==x)d+=this[f++];if(f<m)f++}else{while(f<m&&!b(f)){let x=this[f];if(x==='"'||x==="'"){d+=x,f++;while(f<m&&this[f]!==x)d+=this[f++];if(f<m)d+=this[f++]}else d+=this[f++]}d=d.trim()}if(d)n.push({value:d,quoted:o});if(b(f))f+=r}return n};String.prototype.splitNested=function(T,n,m){let r=0,f="",b=[];for(let d of this){if(f+=d,d===n)r++;if(d===m)r--;if(r===0&&d===T)b.push(f.slice(0,-1)),f=""}if(f)b.push(f);return b};String.prototype.padBlock=function(T,n=`
|
|
2
|
+
`,m=" "){let r=m.repeat(T);return this.split(n).map((f)=>r+f).join(n)};String.prototype.stripIndent=function(){let T=this.split(/\r?\n/),n=T.filter((r)=>r.trim().length>0).map((r)=>/^[ \t]*/.exec(r)?.[0].length??0),m=n.length>0?Math.min(...n):0;if(m===0)return this;return T.map((r)=>r.slice(m)).join(`
|
|
3
|
+
`)};var W=Object.getPrototypeOf(async function(){}).constructor;function i(T,n="Value is undefined"){if(T===void 0||T===null)throw Error(n);return T}export{i as defined,F as NavigateResult,y as NavigateAction,W as AsyncFunction};
|