@voxgig/struct 0.0.8 → 0.0.10

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.
@@ -1,10 +1,34 @@
1
+ declare const M_KEYPRE = 1;
2
+ declare const M_KEYPOST = 2;
3
+ declare const M_VAL = 4;
4
+ declare const T_any: number;
5
+ declare const T_noval: number;
6
+ declare const T_boolean: number;
7
+ declare const T_decimal: number;
8
+ declare const T_integer: number;
9
+ declare const T_number: number;
10
+ declare const T_string: number;
11
+ declare const T_function: number;
12
+ declare const T_symbol: number;
13
+ declare const T_null: number;
14
+ declare const T_list: number;
15
+ declare const T_map: number;
16
+ declare const T_instance: number;
17
+ declare const T_scalar: number;
18
+ declare const T_node: number;
19
+ declare const SKIP: {
20
+ '`$SKIP`': boolean;
21
+ };
22
+ declare const DELETE: {
23
+ '`$DELETE`': boolean;
24
+ };
1
25
  type PropKey = string | number;
2
26
  type Indexable = {
3
27
  [key: string]: any;
4
28
  } & {
5
29
  [key: number]: any;
6
30
  };
7
- type InjectMode = 'key:pre' | 'key:post' | 'val';
31
+ type InjectMode = number;
8
32
  type Injector = (inj: Injection, // Injection state.
9
33
  val: any, // Injection value specification.
10
34
  ref: string, // Original injection reference string.
@@ -15,6 +39,8 @@ parent?: any, // Parent node, if any.
15
39
  inj?: Injection, // Injection state, if any.
16
40
  store?: any) => void;
17
41
  type WalkApply = (key: string | number | undefined, val: any, parent: any, path: string[]) => any;
42
+ declare function typename(t: number): any;
43
+ declare function getdef(val: any, alt: any): any;
18
44
  declare function isnode(val: any): val is Indexable;
19
45
  declare function ismap(val: any): val is {
20
46
  [key: string]: any;
@@ -24,18 +50,21 @@ declare function iskey(key: any): key is PropKey;
24
50
  declare function isempty(val: any): boolean;
25
51
  declare function isfunc(val: any): val is Function;
26
52
  declare function size(val: any): number;
27
- declare function slice<V extends any>(val: V, start?: number, end?: number): V;
53
+ declare function slice<V extends any>(val: V, start?: number, end?: number, mutate?: boolean): V;
28
54
  declare function pad(str: any, padding?: number, padchar?: string): string;
29
- declare function typify(value: any): string;
55
+ declare function typify(value: any): number;
30
56
  declare function getelem(val: any, key: any, alt?: any): any;
31
57
  declare function getprop(val: any, key: any, alt?: any): any;
32
58
  declare function strkey(key?: any): string;
33
59
  declare function keysof(val: any): string[];
34
60
  declare function haskey(val: any, key: any): boolean;
35
61
  declare function items(val: any): [string, any][];
62
+ declare function items<T>(val: any, apply: (item: [string, any]) => T): T[];
63
+ declare function flatten(list: any[], depth?: number): any[];
64
+ declare function filter(val: any, check: (item: [string, any]) => boolean): any[];
36
65
  declare function escre(s: string): string;
37
66
  declare function escurl(s: string): string;
38
- declare function joinurl(sarr: any[]): string;
67
+ declare function join(arr: any[], sep?: string, url?: boolean): string;
39
68
  declare function jsonify(val: any, flags?: {
40
69
  indent?: number;
41
70
  offset?: number;
@@ -43,12 +72,13 @@ declare function jsonify(val: any, flags?: {
43
72
  declare function stringify(val: any, maxlen?: number, pretty?: any): string;
44
73
  declare function pathify(val: any, startin?: number, endin?: number): string;
45
74
  declare function clone(val: any): any;
46
- declare function jo(...kv: any[]): Record<string, any>;
47
- declare function ja(...v: any[]): any[];
75
+ declare function jm(...kv: any[]): Record<string, any>;
76
+ declare function jt(...v: any[]): any[];
48
77
  declare function delprop<PARENT>(parent: PARENT, key: any): PARENT;
49
78
  declare function setprop<PARENT>(parent: PARENT, key: any, val: any): PARENT;
50
79
  declare function walk(val: any, before?: WalkApply, after?: WalkApply, maxdepth?: number, key?: string | number, parent?: any, path?: string[]): any;
51
80
  declare function merge(val: any, maxdepth?: number): any;
81
+ declare function setpath(store: any, path: number | string | string[], val: any, injdef?: Partial<Injection>): any;
52
82
  declare function getpath(store: any, path: number | string | string[], injdef?: Partial<Injection>): any;
53
83
  declare function inject(val: any, store: any, injdef?: Partial<Injection>): any;
54
84
  declare function transform(data: any, // Source data to transform into new data (original not mutated)
@@ -81,13 +111,20 @@ declare class Injection {
81
111
  toString(prefix?: string): string;
82
112
  descend(): any;
83
113
  child(keyI: number, keys: string[]): Injection;
84
- setval(val: any, ancestor?: number): any;
114
+ setval(val: any, ancestor?: number): undefined;
85
115
  }
116
+ declare const MODENAME: any;
117
+ declare function checkPlacement(modes: InjectMode, ijname: string, parentTypes: number, inj: Injection): boolean;
118
+ declare function injectorArgs(argTypes: number[], args: any[]): any;
119
+ declare function injectChild(child: any, store: any, inj: Injection): Injection;
86
120
  declare class StructUtility {
87
121
  clone: typeof clone;
88
122
  delprop: typeof delprop;
89
123
  escre: typeof escre;
90
124
  escurl: typeof escurl;
125
+ filter: typeof filter;
126
+ flatten: typeof flatten;
127
+ getdef: typeof getdef;
91
128
  getelem: typeof getelem;
92
129
  getpath: typeof getpath;
93
130
  getprop: typeof getprop;
@@ -100,13 +137,14 @@ declare class StructUtility {
100
137
  ismap: typeof ismap;
101
138
  isnode: typeof isnode;
102
139
  items: typeof items;
103
- joinurl: typeof joinurl;
140
+ join: typeof join;
104
141
  jsonify: typeof jsonify;
105
142
  keysof: typeof keysof;
106
143
  merge: typeof merge;
107
144
  pad: typeof pad;
108
145
  pathify: typeof pathify;
109
146
  select: typeof select;
147
+ setpath: typeof setpath;
110
148
  setprop: typeof setprop;
111
149
  size: typeof size;
112
150
  slice: typeof slice;
@@ -114,10 +152,36 @@ declare class StructUtility {
114
152
  stringify: typeof stringify;
115
153
  transform: typeof transform;
116
154
  typify: typeof typify;
155
+ typename: typeof typename;
117
156
  validate: typeof validate;
118
157
  walk: typeof walk;
119
- jo: typeof jo;
120
- ja: typeof ja;
158
+ SKIP: {
159
+ '`$SKIP`': boolean;
160
+ };
161
+ DELETE: {
162
+ '`$DELETE`': boolean;
163
+ };
164
+ jm: typeof jm;
165
+ jt: typeof jt;
166
+ tn: typeof typename;
167
+ T_any: number;
168
+ T_noval: number;
169
+ T_boolean: number;
170
+ T_decimal: number;
171
+ T_integer: number;
172
+ T_number: number;
173
+ T_string: number;
174
+ T_function: number;
175
+ T_symbol: number;
176
+ T_null: number;
177
+ T_list: number;
178
+ T_map: number;
179
+ T_instance: number;
180
+ T_scalar: number;
181
+ T_node: number;
182
+ checkPlacement: typeof checkPlacement;
183
+ injectorArgs: typeof injectorArgs;
184
+ injectChild: typeof injectChild;
121
185
  }
122
- export { StructUtility, clone, delprop, escre, escurl, getelem, getpath, getprop, haskey, inject, isempty, isfunc, iskey, islist, ismap, isnode, items, joinurl, jsonify, keysof, merge, pad, pathify, select, setprop, size, slice, strkey, stringify, transform, typify, validate, walk, jo, ja, };
186
+ export { StructUtility, clone, delprop, escre, escurl, filter, flatten, getdef, getelem, getpath, getprop, haskey, inject, isempty, isfunc, iskey, islist, ismap, isnode, items, join, jsonify, keysof, merge, pad, pathify, select, setpath, setprop, size, slice, strkey, stringify, transform, typify, typename, validate, walk, SKIP, DELETE, jm, jt, T_any, T_noval, T_boolean, T_decimal, T_integer, T_number, T_string, T_function, T_symbol, T_null, T_list, T_map, T_instance, T_scalar, T_node, M_KEYPRE, M_KEYPOST, M_VAL, MODENAME, checkPlacement, injectorArgs, injectChild, };
123
187
  export type { Injection, Injector, WalkApply };