@voxgig/struct 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/struct.d.ts +103 -0
- package/dist/struct.js +1453 -0
- package/dist/struct.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +46 -0
- package/src/struct.ts +1983 -0
- package/src/tsconfig.json +15 -0
package/dist/struct.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
type PropKey = string | number;
|
|
2
|
+
type InjectMode = 'key:pre' | 'key:post' | 'val';
|
|
3
|
+
type Injector = (inj: Injection, // Injection state.
|
|
4
|
+
val: any, // Injection value specification.
|
|
5
|
+
current: any, // Current source parent value.
|
|
6
|
+
ref: string, // Original injection reference string.
|
|
7
|
+
store: any) => any;
|
|
8
|
+
declare class Injection {
|
|
9
|
+
mode: InjectMode;
|
|
10
|
+
full: boolean;
|
|
11
|
+
keyI: number;
|
|
12
|
+
keys: string[];
|
|
13
|
+
key: string;
|
|
14
|
+
val: any;
|
|
15
|
+
parent: any;
|
|
16
|
+
path: string[];
|
|
17
|
+
nodes: any[];
|
|
18
|
+
handler: Injector;
|
|
19
|
+
errs: any[];
|
|
20
|
+
meta: Record<string, any>;
|
|
21
|
+
base?: string;
|
|
22
|
+
modify?: Modify;
|
|
23
|
+
prior?: Injection;
|
|
24
|
+
constructor(val: any, parent: any, modify?: Modify, errs?: any[]);
|
|
25
|
+
toString(prefix?: string): string;
|
|
26
|
+
child(keyI: number, keys: string[]): Injection;
|
|
27
|
+
setval(val: any, ancestor?: number): any;
|
|
28
|
+
}
|
|
29
|
+
type Modify = (val: any, // Value.
|
|
30
|
+
key?: PropKey, // Value key, if any,
|
|
31
|
+
parent?: any, // Parent node, if any.
|
|
32
|
+
inj?: Injection, // Injection state, if any.
|
|
33
|
+
current?: any, // Current value in store (matches path).
|
|
34
|
+
store?: any) => void;
|
|
35
|
+
type WalkApply = (key: string | number | undefined, val: any, parent: any, path: string[]) => any;
|
|
36
|
+
declare function isnode(val: any): boolean;
|
|
37
|
+
declare function ismap(val: any): boolean;
|
|
38
|
+
declare function islist(val: any): val is any[];
|
|
39
|
+
declare function iskey(key: any): boolean;
|
|
40
|
+
declare function isempty(val: any): boolean;
|
|
41
|
+
declare function isfunc(val: any): boolean;
|
|
42
|
+
declare function size(val: any): number;
|
|
43
|
+
declare function slice<V extends any>(val: V, start: number, end?: number): V;
|
|
44
|
+
declare function pad(str: any, padding?: number, padchar?: string): string;
|
|
45
|
+
declare function typify(value: any): string;
|
|
46
|
+
declare function getelem(val: any, key: any, alt?: any): any;
|
|
47
|
+
declare function getprop(val: any, key: any, alt?: any): any;
|
|
48
|
+
declare function strkey(key?: any): string;
|
|
49
|
+
declare function keysof(val: any): string[];
|
|
50
|
+
declare function haskey(val: any, key: any): boolean;
|
|
51
|
+
declare function items(val: any): [number | string, any][];
|
|
52
|
+
declare function escre(s: string): string;
|
|
53
|
+
declare function escurl(s: string): string;
|
|
54
|
+
declare function joinurl(sarr: any[]): string;
|
|
55
|
+
declare function stringify(val: any, maxlen?: number, pretty?: any): string;
|
|
56
|
+
declare function pathify(val: any, startin?: number, endin?: number): string;
|
|
57
|
+
declare function clone(val: any): any;
|
|
58
|
+
declare function setprop<PARENT>(parent: PARENT, key: any, val: any): PARENT;
|
|
59
|
+
declare function walk(val: any, apply: WalkApply, key?: string | number, parent?: any, path?: string[]): any;
|
|
60
|
+
declare function merge(val: any): any;
|
|
61
|
+
declare function getpath(path: string | string[], store: any, current?: any, inj?: Injection): any;
|
|
62
|
+
declare function inject(val: any, store: any, modify?: Modify, current?: any, inj?: Injection): any;
|
|
63
|
+
declare function transform(data: any, // Source data to transform into new data (original not mutated)
|
|
64
|
+
spec: any, // Transform specification; output follows this shape
|
|
65
|
+
extra?: any, // Additional store of data and transforms.
|
|
66
|
+
modify?: Modify): any;
|
|
67
|
+
declare function validate(data: any, // Source data to transform into new data (original not mutated)
|
|
68
|
+
spec: any, // Transform specification; output follows this shape
|
|
69
|
+
extra?: any, // Additional custom checks
|
|
70
|
+
collecterrs?: any): any;
|
|
71
|
+
declare class StructUtility {
|
|
72
|
+
clone: typeof clone;
|
|
73
|
+
escre: typeof escre;
|
|
74
|
+
escurl: typeof escurl;
|
|
75
|
+
getelem: typeof getelem;
|
|
76
|
+
getpath: typeof getpath;
|
|
77
|
+
getprop: typeof getprop;
|
|
78
|
+
haskey: typeof haskey;
|
|
79
|
+
inject: typeof inject;
|
|
80
|
+
isempty: typeof isempty;
|
|
81
|
+
isfunc: typeof isfunc;
|
|
82
|
+
iskey: typeof iskey;
|
|
83
|
+
islist: typeof islist;
|
|
84
|
+
ismap: typeof ismap;
|
|
85
|
+
isnode: typeof isnode;
|
|
86
|
+
items: typeof items;
|
|
87
|
+
joinurl: typeof joinurl;
|
|
88
|
+
keysof: typeof keysof;
|
|
89
|
+
merge: typeof merge;
|
|
90
|
+
pad: typeof pad;
|
|
91
|
+
pathify: typeof pathify;
|
|
92
|
+
setprop: typeof setprop;
|
|
93
|
+
size: typeof size;
|
|
94
|
+
slice: typeof slice;
|
|
95
|
+
strkey: typeof strkey;
|
|
96
|
+
stringify: typeof stringify;
|
|
97
|
+
transform: typeof transform;
|
|
98
|
+
typify: typeof typify;
|
|
99
|
+
validate: typeof validate;
|
|
100
|
+
walk: typeof walk;
|
|
101
|
+
}
|
|
102
|
+
export { StructUtility, clone, escre, escurl, getelem, getpath, getprop, haskey, inject, isempty, isfunc, iskey, islist, ismap, isnode, items, joinurl, keysof, merge, pad, pathify, setprop, size, slice, strkey, stringify, transform, typify, validate, walk, };
|
|
103
|
+
export type { Injection, Injector, WalkApply };
|