@avstantso/core 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +124 -1
- package/dist/_global/_register.d.ts +2 -1
- package/dist/_global/deep-ops.d.ts +505 -0
- package/dist/_global/func.d.ts +15 -2
- package/dist/_global/index.d.ts +2 -0
- package/dist/_global/low-level.d.ts +116 -0
- package/dist/export.d.ts +2 -1
- package/dist/index.js +575 -53
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
declare namespace AVStantso {
|
|
2
|
+
type TypeMap = DeepOps.TypeMap;
|
|
3
|
+
namespace TypeMap {
|
|
4
|
+
type Wildcard = DeepOps.TypeMap.Wildcard;
|
|
5
|
+
type Derive<TOverrides extends Partial<TypeMap>, TTypeMap extends TypeMap = TypeMap> = DeepOps.TypeMap.Derive<TOverrides, TTypeMap>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @summary Deep operations
|
|
9
|
+
*/
|
|
10
|
+
export namespace DeepOps {
|
|
11
|
+
/**
|
|
12
|
+
* @summary Deep operation node type to walk
|
|
13
|
+
*/
|
|
14
|
+
type NodeType = keyof typeof AVStantso.LowLevel.TypeGroup;
|
|
15
|
+
namespace NodeType {
|
|
16
|
+
/**
|
|
17
|
+
* @summary Deep operation node type to walk: supports recursion next
|
|
18
|
+
*/
|
|
19
|
+
type Nextable = Exclude<NodeType, 'scalar' | 'atomic'>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @summary Deep operation node type tuple type
|
|
23
|
+
*/
|
|
24
|
+
type NodeTypes = AVStantso.LowLevel.TypeGroups;
|
|
25
|
+
/**
|
|
26
|
+
* @summary Deep operation recursion generics types map
|
|
27
|
+
*/
|
|
28
|
+
type TypeMap = {
|
|
29
|
+
walker?: Function;
|
|
30
|
+
nodes?: NodeType;
|
|
31
|
+
};
|
|
32
|
+
namespace TypeMap {
|
|
33
|
+
/**
|
|
34
|
+
* @summary Types map wildcard
|
|
35
|
+
*/
|
|
36
|
+
type Wildcard = {
|
|
37
|
+
[K in keyof TypeMap]-?: any;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @summary Derive types map from previous
|
|
41
|
+
*/
|
|
42
|
+
type Derive<TOverrides extends Partial<TypeMap>, TTypeMap extends TypeMap = TypeMap> = Omit<TTypeMap, keyof TOverrides> & TOverrides extends infer R extends Omit<TTypeMap, keyof TOverrides> & TOverrides ? {
|
|
43
|
+
[K in keyof R]-?: R[K];
|
|
44
|
+
} : never;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @summary Walk rules types.\
|
|
48
|
+
* Walk rules by node types
|
|
49
|
+
*/
|
|
50
|
+
namespace Walk {
|
|
51
|
+
/**
|
|
52
|
+
* @summary Class map for walk rules.
|
|
53
|
+
*/
|
|
54
|
+
export type ClassMap<TTypeMap extends TypeMap = TypeMap> = ReadonlyMap<AVStantso.TS.Class, boolean | TTypeMap['walker']>;
|
|
55
|
+
/**
|
|
56
|
+
* @summary Walk scalar (not objects and functions) types rule.\
|
|
57
|
+
* Process falsy values too (`undefined`, `null`).\
|
|
58
|
+
* If `null`, translated to `true` for inclusive / to `false` for exclusive behaviour.\
|
|
59
|
+
* If truthy, recursion will walk `string`, `number` etc.\
|
|
60
|
+
* If value is general `CustomWalker`:
|
|
61
|
+
* - All will be walked custom
|
|
62
|
+
* If value is record object:
|
|
63
|
+
* - Unexists / `null` — see `null` above
|
|
64
|
+
* - Exists as `CustomWalker` will be walked custom
|
|
65
|
+
* - Exists as thruthy will be walked
|
|
66
|
+
* - Exists as falsy will be NOT walked
|
|
67
|
+
*/
|
|
68
|
+
export type Scalar<TTypeMap extends TypeMap = TypeMap> = null | boolean | TTypeMap['walker'] | Partial<Record<LowLevel.JSType.Scalar, boolean | TTypeMap['walker']>>;
|
|
69
|
+
/**
|
|
70
|
+
* @summary Walk atomic ({@link AtomicObjects}) objects rule.\
|
|
71
|
+
* These objects are similar to scalars.\
|
|
72
|
+
* If `null`, translated to `true` for inclusive / to `false` for exclusive behaviour.\
|
|
73
|
+
* If truthy, recursion will walk `{}`.\
|
|
74
|
+
* If value is general `CustomWalker`:
|
|
75
|
+
* - All will be walked custom
|
|
76
|
+
* If value is Map object:
|
|
77
|
+
* - Unexists / `null` — see `null` above
|
|
78
|
+
* - Exists as `CustomWalker` will be walked custom
|
|
79
|
+
* - Exists as thruthy will be walked
|
|
80
|
+
* - Exists as falsy will be NOT walked
|
|
81
|
+
* @see AtomicObjects
|
|
82
|
+
*/
|
|
83
|
+
export type Atomic<TTypeMap extends TypeMap = TypeMap> = null | boolean | TTypeMap['walker'] | ClassMap<TypeMap>;
|
|
84
|
+
/**
|
|
85
|
+
* @summary Walk plain (`Object.isPlainObject`) objects rule.\
|
|
86
|
+
* If `null`, translated to `true` for inclusive / to `false` for exclusive behaviour.\
|
|
87
|
+
* If truthy, recursion will walk `{}`.\
|
|
88
|
+
* If value is general `CustomWalker`:
|
|
89
|
+
* - All will be walked custom
|
|
90
|
+
*/
|
|
91
|
+
export type Plain<TTypeMap extends TypeMap = TypeMap> = null | boolean | TTypeMap['walker'];
|
|
92
|
+
/**
|
|
93
|
+
* @summary Walk rich (not `Object.isPlainObject`) objects rule.\
|
|
94
|
+
* If `null`, translated to `true` for inclusive / to `false` for exclusive behaviour.\
|
|
95
|
+
* If truthy, recursion will walk `Array`, `Set`, `Map`, classes instances etc.\
|
|
96
|
+
* If value is general `CustomWalker`:
|
|
97
|
+
* - All will be walked custom
|
|
98
|
+
* If value is Map object:
|
|
99
|
+
* - Unexists / `null` — see `null` above
|
|
100
|
+
* - Exists as `CustomWalker` will be walked custom
|
|
101
|
+
* - Exists as thruthy will be walked
|
|
102
|
+
* - Exists as falsy will be NOT walked
|
|
103
|
+
*/
|
|
104
|
+
export type Rich<TTypeMap extends TypeMap = TypeMap> = null | boolean | TTypeMap['walker'] | ClassMap<TTypeMap>;
|
|
105
|
+
/**
|
|
106
|
+
* @summary Walk functions rule.\
|
|
107
|
+
* If `null`, translated to `true` for inclusive / to `false` for exclusive behaviour.\
|
|
108
|
+
* If truthy, recursion will walk functions, async/arrow/generator functions, classes etc.\
|
|
109
|
+
* If value is general `CustomWalker`:
|
|
110
|
+
* - All will be walked custom
|
|
111
|
+
* If value is record object:
|
|
112
|
+
* - Unexists / `null` — see `null` above
|
|
113
|
+
* - Exists as `CustomWalker` will be walked custom
|
|
114
|
+
* - Exists as thruthy will be walked
|
|
115
|
+
* - Exists as falsy will be NOT walked
|
|
116
|
+
*/
|
|
117
|
+
export type Funcs<TTypeMap extends TypeMap = TypeMap> = null | boolean | TTypeMap['walker'] | Partial<Record<TS.Func.Type, boolean | TTypeMap['walker']>>;
|
|
118
|
+
type InclusiveExclusive<TNodeType extends NodeType, TWalk> = [
|
|
119
|
+
`walk${Capitalize<TNodeType>}Inc`,
|
|
120
|
+
`walk${Capitalize<TNodeType>}Exc`
|
|
121
|
+
] extends [infer I extends string, infer E extends string] ? [
|
|
122
|
+
{
|
|
123
|
+
[K in I]?: TWalk;
|
|
124
|
+
} & {
|
|
125
|
+
[K in E]?: never;
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
[K in I]?: never;
|
|
129
|
+
} & {
|
|
130
|
+
[K in E]?: TWalk;
|
|
131
|
+
}
|
|
132
|
+
] extends [infer WI, infer WE] ? {
|
|
133
|
+
[K in keyof WI]: WI[K];
|
|
134
|
+
} | {
|
|
135
|
+
[K in keyof WE]: WE[K];
|
|
136
|
+
} : never : never;
|
|
137
|
+
type _Static<TTypeMap extends TypeMap, NTA extends readonly NodeType[] = NodeTypes, R = never> = NTA extends readonly [infer C extends NodeType, ...infer Rest extends readonly NodeType[]] ? _Static<TTypeMap, Rest, R | (C extends TypeMap['nodes'] ? InclusiveExclusive<C, Walk<TTypeMap>[C]> : never)> : R;
|
|
138
|
+
/**
|
|
139
|
+
* @summary Walk static (not extensible) rules pack alternatives.
|
|
140
|
+
*/
|
|
141
|
+
export type Static<TTypeMap extends TypeMap = TypeMap> = _Static<TTypeMap> & {};
|
|
142
|
+
export namespace Static {
|
|
143
|
+
type _United<TTypeMap extends TypeMap, NTA extends readonly NodeType[] = NodeTypes, R = unknown> = NTA extends readonly [
|
|
144
|
+
infer C extends NodeType,
|
|
145
|
+
...infer Rest extends readonly NodeType[]
|
|
146
|
+
] ? _United<TTypeMap, Rest, R & (C extends TypeMap['nodes'] ? {
|
|
147
|
+
[K in `walk${Capitalize<C>}${'Inc' | 'Exc'}`]: Walk<TTypeMap>[C];
|
|
148
|
+
} : unknown)> : {
|
|
149
|
+
[K in keyof R]: R[K];
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* @summary Walk static (not extensible) rules pack (alternatives is united).
|
|
153
|
+
*/
|
|
154
|
+
export type United<TTypeMap extends TypeMap = TypeMap> = _United<TTypeMap>;
|
|
155
|
+
export {};
|
|
156
|
+
}
|
|
157
|
+
export {};
|
|
158
|
+
}
|
|
159
|
+
type Walk<TTypeMap extends TypeMap = TypeMap> = {
|
|
160
|
+
scalar: Walk.Scalar<TTypeMap>;
|
|
161
|
+
atomic: Walk.Atomic<TTypeMap>;
|
|
162
|
+
plain: Walk.Plain<TTypeMap>;
|
|
163
|
+
rich: Walk.Rich<TTypeMap>;
|
|
164
|
+
func: Walk.Funcs<TTypeMap>;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* @summary Deep operation options (extensible `interface`).\
|
|
168
|
+
* Used in pair with `Walk.Static<XXX>` (not extensible)
|
|
169
|
+
* @see Walk.Static
|
|
170
|
+
*/
|
|
171
|
+
interface Options {
|
|
172
|
+
/**
|
|
173
|
+
* @summary If truthy, walks enumirale and own properties,\
|
|
174
|
+
* if falsy — enumirale properties only
|
|
175
|
+
*/
|
|
176
|
+
ownProps?: boolean;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export namespace Code {
|
|
180
|
+
/**
|
|
181
|
+
* @summary Deep operations utils
|
|
182
|
+
*/
|
|
183
|
+
namespace DeepOps {
|
|
184
|
+
/**
|
|
185
|
+
* @summary Deep operations utils common
|
|
186
|
+
*/
|
|
187
|
+
namespace Common {
|
|
188
|
+
/**
|
|
189
|
+
* @summary Deep operations common options
|
|
190
|
+
*/
|
|
191
|
+
type Options<TTypeMap extends TypeMap = TypeMap> = AVStantso.DeepOps.Options & AVStantso.DeepOps.Walk.Static<TTypeMap>;
|
|
192
|
+
/**
|
|
193
|
+
* @summary Deep copy operations commons:
|
|
194
|
+
* - `Clone`
|
|
195
|
+
* - `Merge`
|
|
196
|
+
*/
|
|
197
|
+
namespace CopyOps {
|
|
198
|
+
/**
|
|
199
|
+
* @summary Deep copy operations common options
|
|
200
|
+
* - `Clone`
|
|
201
|
+
* - `Merge`
|
|
202
|
+
*/
|
|
203
|
+
interface Options {
|
|
204
|
+
/**
|
|
205
|
+
* @summary If `true`, copies reference of function instead cloning
|
|
206
|
+
*/
|
|
207
|
+
copyFuncs?: boolean;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @summary Options option
|
|
212
|
+
*/
|
|
213
|
+
namespace Option {
|
|
214
|
+
/**
|
|
215
|
+
* @summary Option value callback
|
|
216
|
+
* @param node Node value the option is being resolved for
|
|
217
|
+
* @param key Node's key/index within its parent, if any (`undefined` at the root)
|
|
218
|
+
*/
|
|
219
|
+
type Callback<R> = (node: unknown, key?: TS.Key) => R;
|
|
220
|
+
}
|
|
221
|
+
type Option<T> = T | Option.Callback<T>;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @summary `DeepOps` typeguards
|
|
225
|
+
*/
|
|
226
|
+
namespace Is {
|
|
227
|
+
/**
|
|
228
|
+
* @summary `DeepOps` options typeguards
|
|
229
|
+
*/
|
|
230
|
+
interface Options {
|
|
231
|
+
/**
|
|
232
|
+
* @summary {@link DeepOps.Common.Options} typeguard
|
|
233
|
+
*/
|
|
234
|
+
common<TTypeMap extends TypeMap = TypeMap>(candidate: unknown): candidate is DeepOps.Common.Options<TTypeMap>;
|
|
235
|
+
/**
|
|
236
|
+
* @summary {@link DeepOps.Clone.Options} typeguard
|
|
237
|
+
*/
|
|
238
|
+
clone(candidate: unknown): candidate is DeepOps.Clone.Options;
|
|
239
|
+
/**
|
|
240
|
+
* @summary {@link DeepOps.Merge.Options} typeguard
|
|
241
|
+
*/
|
|
242
|
+
merge(candidate: unknown): candidate is DeepOps.Merge.Options;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
interface Is {
|
|
246
|
+
/**
|
|
247
|
+
* @summary `DeepOps` options typeguards
|
|
248
|
+
*/
|
|
249
|
+
options: Is.Options;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* @summary Deep feeze operation
|
|
253
|
+
* @template T Argument type
|
|
254
|
+
* @param obj Data for freeze
|
|
255
|
+
* @param options Options for freeze
|
|
256
|
+
*/
|
|
257
|
+
namespace Freeze {
|
|
258
|
+
/**
|
|
259
|
+
* Typemap for freeze
|
|
260
|
+
*/
|
|
261
|
+
type TypeMap = TypeMap.Derive<{
|
|
262
|
+
walker<T extends object | Function>(node: T): Readonly<T>;
|
|
263
|
+
nodes: 'plain' | 'rich' | 'func';
|
|
264
|
+
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Options for freeze
|
|
267
|
+
*/
|
|
268
|
+
type Options = Common.Options<TypeMap>;
|
|
269
|
+
}
|
|
270
|
+
interface Freeze {
|
|
271
|
+
/**
|
|
272
|
+
* @summary `symbol` for custom freeze.\
|
|
273
|
+
* Same symbol of {@link _CodeReg.Administration.symbolFreeze}
|
|
274
|
+
*/
|
|
275
|
+
symbol: symbol;
|
|
276
|
+
/**
|
|
277
|
+
* @summary Deep feeze operation
|
|
278
|
+
* @template T Argument type
|
|
279
|
+
* @param obj Data for freeze
|
|
280
|
+
* @param options Options for freeze
|
|
281
|
+
*/
|
|
282
|
+
<T>(obj: T, options?: Freeze.Options): Readonly<T>;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @summary Deep clone operation
|
|
286
|
+
* @template T Argument type
|
|
287
|
+
* @param obj Data for clone
|
|
288
|
+
* @param options Options for clone
|
|
289
|
+
*/
|
|
290
|
+
namespace Clone {
|
|
291
|
+
/**
|
|
292
|
+
* Typemap for clone
|
|
293
|
+
*/
|
|
294
|
+
type TypeMap = TypeMap.Derive<{
|
|
295
|
+
walker<T>(node: T): T;
|
|
296
|
+
}>;
|
|
297
|
+
/**
|
|
298
|
+
* @summary Deep clone operation options
|
|
299
|
+
*/
|
|
300
|
+
interface Options extends Common.CopyOps.Options {
|
|
301
|
+
}
|
|
302
|
+
namespace Options {
|
|
303
|
+
/**
|
|
304
|
+
* @summary Deep clone operation merged options
|
|
305
|
+
*/
|
|
306
|
+
type Merged = Options & Common.Options<TypeMap>;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
interface Clone {
|
|
310
|
+
/**
|
|
311
|
+
* @summary `symbol` for custom clone.
|
|
312
|
+
*/
|
|
313
|
+
symbol: symbol;
|
|
314
|
+
/**
|
|
315
|
+
* @summary Deep clone operation
|
|
316
|
+
* @template T Argument type
|
|
317
|
+
* @param obj Data for clone
|
|
318
|
+
* @param options Options for clone
|
|
319
|
+
*/
|
|
320
|
+
<T>(obj: T, options?: Clone.Options.Merged): T;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* @summary Deep merge operation
|
|
324
|
+
* @template T Target argument type
|
|
325
|
+
* @template S Source arguments type
|
|
326
|
+
* @param target Data target for merge
|
|
327
|
+
* @param sources Data sources for merge
|
|
328
|
+
* @param options Options for merge
|
|
329
|
+
*/
|
|
330
|
+
namespace Merge {
|
|
331
|
+
/**
|
|
332
|
+
* Typemap for merge
|
|
333
|
+
*/
|
|
334
|
+
type TypeMap = TypeMap.Derive<{
|
|
335
|
+
walker<T, S extends TS.ArrR>(target: T, ...sources: S): T;
|
|
336
|
+
}>;
|
|
337
|
+
/**
|
|
338
|
+
* @summary Deep merge operation options
|
|
339
|
+
*/
|
|
340
|
+
interface Options extends Common.CopyOps.Options {
|
|
341
|
+
/**
|
|
342
|
+
* If resolved as truthy: node for merge must exists in source node
|
|
343
|
+
*/
|
|
344
|
+
onlyExists?: Common.Option<boolean>;
|
|
345
|
+
/**
|
|
346
|
+
* If resolved as truthy: array nodes will merjed as `[...new Set( XXX )]`
|
|
347
|
+
*/
|
|
348
|
+
isUniqueArrItems?: Common.Option<boolean>;
|
|
349
|
+
/**
|
|
350
|
+
* If resolved as truthy: source `null` will delete target key
|
|
351
|
+
*/
|
|
352
|
+
nullAsDelete?: Common.Option<boolean>;
|
|
353
|
+
/**
|
|
354
|
+
* If resolved as truthy: array nodes will be merged by concatenation
|
|
355
|
+
* (`[...target, ...source]`), instead of the default by-index merge
|
|
356
|
+
*/
|
|
357
|
+
concatArrays?: Common.Option<boolean>;
|
|
358
|
+
}
|
|
359
|
+
namespace Options {
|
|
360
|
+
/**
|
|
361
|
+
* @summary Deep merge operation merged options
|
|
362
|
+
*/
|
|
363
|
+
type Merged = Options & Common.Options<TypeMap>;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
interface Merge {
|
|
367
|
+
/**
|
|
368
|
+
* @summary `symbol` for custom merge.
|
|
369
|
+
*/
|
|
370
|
+
symbol: symbol;
|
|
371
|
+
/**
|
|
372
|
+
* @summary Deep merge operation
|
|
373
|
+
* @template T Target argument type
|
|
374
|
+
* @template S Source argument type
|
|
375
|
+
* @param target Data target for merge
|
|
376
|
+
* @param source Data source for merge
|
|
377
|
+
* @param options Options for merge
|
|
378
|
+
*/
|
|
379
|
+
<T, S>(target: T, source: S, options: Merge.Options.Merged): T & Partial<S>;
|
|
380
|
+
/**
|
|
381
|
+
* @summary Deep merge operation
|
|
382
|
+
* @template T Target argument type
|
|
383
|
+
* @template S0 Source0 argument type
|
|
384
|
+
* @template S1 Source1 argument type
|
|
385
|
+
* @param target Data target for merge
|
|
386
|
+
* @param source0 Data source0 for merge
|
|
387
|
+
* @param source1 Data source1 for merge
|
|
388
|
+
* @param options Options for merge
|
|
389
|
+
*/
|
|
390
|
+
<T, S0, S1>(target: T, source0: S0, source1: S1, options: Merge.Options.Merged): T & Partial<S0 & S1>;
|
|
391
|
+
/**
|
|
392
|
+
* @summary Deep merge operation
|
|
393
|
+
* @template T Target argument type
|
|
394
|
+
* @template S0 Source0 argument type
|
|
395
|
+
* @template S1 Source1 argument type
|
|
396
|
+
* @template S2 Source2 argument type
|
|
397
|
+
* @param target Data target for merge
|
|
398
|
+
* @param source0 Data source0 for merge
|
|
399
|
+
* @param source1 Data source1 for merge
|
|
400
|
+
* @param source2 Data source2 for merge
|
|
401
|
+
* @param options Options for merge
|
|
402
|
+
*/
|
|
403
|
+
<T, S0, S1, S2>(target: T, source0: S0, source1: S1, source2: S2, options: Merge.Options.Merged): T & Partial<S0 & S1 & S2>;
|
|
404
|
+
/**
|
|
405
|
+
* @summary Deep merge operation
|
|
406
|
+
* @template T Target argument type
|
|
407
|
+
* @template S0 Source0 argument type
|
|
408
|
+
* @template S1 Source1 argument type
|
|
409
|
+
* @template S2 Source2 argument type
|
|
410
|
+
* @template S3 Source3 argument type
|
|
411
|
+
* @param target Data target for merge
|
|
412
|
+
* @param source0 Data source0 for merge
|
|
413
|
+
* @param source1 Data source1 for merge
|
|
414
|
+
* @param source2 Data source2 for merge
|
|
415
|
+
* @param source3 Data source3 for merge
|
|
416
|
+
* @param options Options for merge
|
|
417
|
+
*/
|
|
418
|
+
<T, S0, S1, S2, S3>(target: T, source0: S0, source1: S1, source2: S2, source3: S3, options: Merge.Options.Merged): T & Partial<S0 & S1 & S2 & S3>;
|
|
419
|
+
/**
|
|
420
|
+
* @summary Deep merge operation
|
|
421
|
+
* @template T Target argument type
|
|
422
|
+
* @template S0 Source0 argument type
|
|
423
|
+
* @template S1 Source1 argument type
|
|
424
|
+
* @template S2 Source2 argument type
|
|
425
|
+
* @template S3 Source3 argument type
|
|
426
|
+
* @template S4 Source4 argument type
|
|
427
|
+
* @param target Data target for merge
|
|
428
|
+
* @param source0 Data source0 for merge
|
|
429
|
+
* @param source1 Data source1 for merge
|
|
430
|
+
* @param source2 Data source2 for merge
|
|
431
|
+
* @param source3 Data source3 for merge
|
|
432
|
+
* @param source4 Data source4 for merge
|
|
433
|
+
* @param options Options for merge
|
|
434
|
+
*/
|
|
435
|
+
<T, S0, S1, S2, S3, S4>(target: T, source0: S0, source1: S1, source2: S2, source3: S3, source4: S4, options: Merge.Options.Merged): T & Partial<S0 & S1 & S2 & S3 & S4>;
|
|
436
|
+
/**
|
|
437
|
+
* @summary Deep merge operation
|
|
438
|
+
* @template T Target argument type
|
|
439
|
+
* @template S Source arguments type
|
|
440
|
+
* @param target Data target for merge
|
|
441
|
+
* @param sources Data sources for merge
|
|
442
|
+
* @param options Options for merge
|
|
443
|
+
*/
|
|
444
|
+
<T, S extends TS.ArrR>(target: T, ...params: [...[...sources: S], ...[options: Merge.Options.Merged]]): T & unknown;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
interface DeepOps {
|
|
448
|
+
/**
|
|
449
|
+
* @summary Deep walk node types
|
|
450
|
+
*/
|
|
451
|
+
NodeTypes: TS.Key2Key<AVStantso.DeepOps.NodeType>;
|
|
452
|
+
/**
|
|
453
|
+
* @summary `DeepOps` typeguards
|
|
454
|
+
*/
|
|
455
|
+
is: DeepOps.Is;
|
|
456
|
+
/**
|
|
457
|
+
* @summary Deep feeze operation.\
|
|
458
|
+
* Default walks logic:
|
|
459
|
+
* - plain objects (`{}`)
|
|
460
|
+
* - `Array`, `Set`, 'Map', class instances
|
|
461
|
+
* - functions, except `class` and `generator` kinds
|
|
462
|
+
* @template T Argument type
|
|
463
|
+
* @param obj Data for freeze
|
|
464
|
+
* @param options Options for freeze
|
|
465
|
+
*/
|
|
466
|
+
freeze: DeepOps.Freeze;
|
|
467
|
+
/**
|
|
468
|
+
* @summary Deep clone operation.\
|
|
469
|
+
* Default walks logic:
|
|
470
|
+
* - scalars (`string`, `number`, etc.)
|
|
471
|
+
* - atomics (`Date`, `Buffer`, etc.)
|
|
472
|
+
* - plain objects (`{}`)
|
|
473
|
+
* - `Array`, `Set`, 'Map'. Not class instances
|
|
474
|
+
* - functions, except `class` and `generator` kinds
|
|
475
|
+
* @template T Argument type
|
|
476
|
+
* @param obj Data for clone
|
|
477
|
+
* @param options Options for clone
|
|
478
|
+
*/
|
|
479
|
+
clone: DeepOps.Clone;
|
|
480
|
+
/**
|
|
481
|
+
* @summary Deep merge operation\
|
|
482
|
+
* Default walks logic:
|
|
483
|
+
* - scalars (`string`, `number`, etc.)
|
|
484
|
+
* - atomics (`Date`, `Buffer`, etc.)
|
|
485
|
+
* - plain objects (`{}`)
|
|
486
|
+
* - `Array`, `Set`, 'Map'. Not class instances
|
|
487
|
+
* - functions, except `class` and `generator` kinds
|
|
488
|
+
* @template T Target argument type
|
|
489
|
+
* @template S Source arguments type
|
|
490
|
+
* @param target Data target for merge
|
|
491
|
+
* @param sources Data sources for merge
|
|
492
|
+
* @param options Options for merge
|
|
493
|
+
*/
|
|
494
|
+
merge: DeepOps.Merge;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
export interface Code {
|
|
498
|
+
/**
|
|
499
|
+
* @summary Deep operations utils
|
|
500
|
+
*/
|
|
501
|
+
DeepOps: Code.DeepOps;
|
|
502
|
+
}
|
|
503
|
+
export const DeepOps: Code.DeepOps;
|
|
504
|
+
export {};
|
|
505
|
+
}
|
package/dist/_global/func.d.ts
CHANGED
|
@@ -13,7 +13,12 @@ declare namespace AVStantso {
|
|
|
13
13
|
} & {
|
|
14
14
|
[x: string]: PropertyDescriptor;
|
|
15
15
|
} & {};
|
|
16
|
+
const runtimeFuncTypes: readonly ["plain", "async", "generator", "class", "arrow", "bound"];
|
|
16
17
|
export namespace TS.Func {
|
|
18
|
+
/**
|
|
19
|
+
* Runtime function type
|
|
20
|
+
*/
|
|
21
|
+
type Type = typeof runtimeFuncTypes[number];
|
|
17
22
|
/**
|
|
18
23
|
* @summary `getOwnPropertyDescriptors` of basic function type
|
|
19
24
|
*/
|
|
@@ -58,6 +63,14 @@ declare namespace AVStantso {
|
|
|
58
63
|
* @summary Functions utilities
|
|
59
64
|
*/
|
|
60
65
|
interface Func {
|
|
66
|
+
/**
|
|
67
|
+
* @summary Types of runtime function Key2Key record
|
|
68
|
+
*/
|
|
69
|
+
Types: TS.Key2Key<TS.Func.Type>;
|
|
70
|
+
/**
|
|
71
|
+
* @summary Determines a type of runtime function
|
|
72
|
+
*/
|
|
73
|
+
determineType(func: Function | TS.Func): TS.Func.Type;
|
|
61
74
|
/**
|
|
62
75
|
* @summary `getOwnPropertyDescriptors` of basic function
|
|
63
76
|
*/
|
|
@@ -227,14 +240,14 @@ declare namespace AVStantso {
|
|
|
227
240
|
* dd.z = 16;
|
|
228
241
|
* expect(isExt(dd)).toBe(true);
|
|
229
242
|
*/
|
|
230
|
-
isExt(f: Function): boolean;
|
|
243
|
+
isExt(f: Function | TS.Func): boolean;
|
|
231
244
|
/**
|
|
232
245
|
* @summary `DEV` dynamic function named as `name`. No affect in `PROD`.
|
|
233
246
|
* @param name Name
|
|
234
247
|
* @param func Implementation
|
|
235
248
|
* @returns In `DEV` — Named function; In `PROD` — `func`
|
|
236
249
|
*/
|
|
237
|
-
Dynamic<N extends string, F extends Function>(name: N, func: F): F;
|
|
250
|
+
Dynamic<N extends string, F extends Function | TS.Func>(name: N, func: F): F;
|
|
238
251
|
}
|
|
239
252
|
}
|
|
240
253
|
export interface Code {
|
package/dist/_global/index.d.ts
CHANGED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
declare namespace AVStantso {
|
|
2
|
+
const jstype: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
3
|
+
const JSStucturalTypes: readonly ["object", "function"];
|
|
4
|
+
enum TypeGroupEnum {
|
|
5
|
+
/**
|
|
6
|
+
* `foo === null || !JSStucturalTypes.includes(typeof foo)`
|
|
7
|
+
*/
|
|
8
|
+
scalar = 0,
|
|
9
|
+
/**
|
|
10
|
+
* `AVStantso.AtomicObjects.is(foo)`
|
|
11
|
+
*/
|
|
12
|
+
atomic = 1,
|
|
13
|
+
/**
|
|
14
|
+
* `typeof foo === 'object' && Object.isPlainObject(foo)`
|
|
15
|
+
*/
|
|
16
|
+
plain = 2,
|
|
17
|
+
/**
|
|
18
|
+
* `typeof foo === 'object' && !Object.isPlainObject(foo)`
|
|
19
|
+
*/
|
|
20
|
+
rich = 3,
|
|
21
|
+
/**
|
|
22
|
+
* `typeof foo === 'function'`
|
|
23
|
+
*/
|
|
24
|
+
func = 4
|
|
25
|
+
}
|
|
26
|
+
const TypeGroups: readonly ["scalar", "atomic", "plain", "rich", "func"];
|
|
27
|
+
/**
|
|
28
|
+
* @summary Low level types and utils
|
|
29
|
+
*/
|
|
30
|
+
export namespace LowLevel {
|
|
31
|
+
/**
|
|
32
|
+
* @summary JavaScript native types union
|
|
33
|
+
*/
|
|
34
|
+
type JSType = typeof jstype;
|
|
35
|
+
namespace JSType {
|
|
36
|
+
/**
|
|
37
|
+
* @summary JavaScript native scalar types + `null`
|
|
38
|
+
*/
|
|
39
|
+
type Scalar = Exclude<JSType, typeof JSStucturalTypes[number]> | 'null';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The group of value type
|
|
43
|
+
*/
|
|
44
|
+
type TypeGroup = TypeGroupEnum;
|
|
45
|
+
namespace TypeGroup {
|
|
46
|
+
/**
|
|
47
|
+
* A type union for a group of value type
|
|
48
|
+
*/
|
|
49
|
+
type Union<TG extends TypeGroup> = TG extends TypeGroupEnum.scalar ? string | number | bigint | boolean | symbol | undefined | null : TG extends TypeGroupEnum.func ? Function : object;
|
|
50
|
+
namespace Union {
|
|
51
|
+
/**
|
|
52
|
+
* A type union for a group of value type\
|
|
53
|
+
* for `scalar`
|
|
54
|
+
*/
|
|
55
|
+
type Scalar = Union<TypeGroupEnum.scalar>;
|
|
56
|
+
/**
|
|
57
|
+
* A type union for a group of value type\
|
|
58
|
+
* for `atomic`
|
|
59
|
+
*/
|
|
60
|
+
type Atomic = Union<TypeGroupEnum.atomic>;
|
|
61
|
+
/**
|
|
62
|
+
* A type union for a group of value type\
|
|
63
|
+
* for `plain`
|
|
64
|
+
*/
|
|
65
|
+
type Plain = Union<TypeGroupEnum.plain>;
|
|
66
|
+
/**
|
|
67
|
+
* A type union for a group of value type\
|
|
68
|
+
* for `rich`
|
|
69
|
+
*/
|
|
70
|
+
type Rich = Union<TypeGroupEnum.rich>;
|
|
71
|
+
/**
|
|
72
|
+
* A type union for a group of value type\
|
|
73
|
+
* for `func`
|
|
74
|
+
*/
|
|
75
|
+
type Func = Union<TypeGroupEnum.func>;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The group of value types array
|
|
80
|
+
*/
|
|
81
|
+
type TypeGroups = typeof TypeGroups;
|
|
82
|
+
}
|
|
83
|
+
export namespace Code {
|
|
84
|
+
/**
|
|
85
|
+
* @summary Low level utils
|
|
86
|
+
*/
|
|
87
|
+
namespace LowLevel {
|
|
88
|
+
}
|
|
89
|
+
interface LowLevel {
|
|
90
|
+
/**
|
|
91
|
+
* @summary Array of JavaScript structural types
|
|
92
|
+
*/
|
|
93
|
+
JSStucturalTypes: typeof JSStucturalTypes;
|
|
94
|
+
/**
|
|
95
|
+
* The group of value type enum
|
|
96
|
+
*/
|
|
97
|
+
TypeGroup: typeof TypeGroupEnum;
|
|
98
|
+
/**
|
|
99
|
+
* The group of value types array
|
|
100
|
+
*/
|
|
101
|
+
TypeGroups: typeof TypeGroups;
|
|
102
|
+
/**
|
|
103
|
+
* Classify the type group of value
|
|
104
|
+
*/
|
|
105
|
+
typeGroupOf(a: unknown): TypeGroupEnum;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export interface Code {
|
|
109
|
+
/**
|
|
110
|
+
* @summary Low level utils
|
|
111
|
+
*/
|
|
112
|
+
LowLevel: Code.LowLevel;
|
|
113
|
+
}
|
|
114
|
+
export const LowLevel: Code.LowLevel;
|
|
115
|
+
export {};
|
|
116
|
+
}
|
package/dist/export.d.ts
CHANGED