deep6 1.1.3 → 1.2.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/LICENSE +1 -1
- package/README.md +44 -38
- package/llms-full.txt +371 -0
- package/llms.txt +154 -0
- package/package.json +31 -109
- package/src/env.d.ts +174 -0
- package/src/env.js +4 -4
- package/src/index.d.ts +86 -0
- package/src/index.js +10 -7
- package/src/traverse/assemble.d.ts +59 -0
- package/src/traverse/assemble.js +4 -3
- package/src/traverse/clone.d.ts +57 -0
- package/src/traverse/clone.js +4 -2
- package/src/traverse/deref.d.ts +59 -0
- package/src/traverse/deref.js +3 -2
- package/src/traverse/preprocess.d.ts +65 -0
- package/src/traverse/preprocess.js +2 -1
- package/src/traverse/walk.d.ts +219 -0
- package/src/traverse/walk.js +9 -4
- package/src/unifiers/matchCondition.d.ts +45 -0
- package/src/unifiers/matchCondition.js +1 -0
- package/src/unifiers/matchInstanceOf.d.ts +37 -0
- package/src/unifiers/matchInstanceOf.js +1 -0
- package/src/unifiers/matchString.d.ts +56 -0
- package/src/unifiers/matchString.js +1 -0
- package/src/unifiers/matchTypeOf.d.ts +37 -0
- package/src/unifiers/matchTypeOf.js +1 -0
- package/src/unifiers/ref.d.ts +52 -0
- package/src/unifiers/ref.js +1 -0
- package/src/unify.d.ts +95 -0
- package/src/unify.js +130 -66
- package/src/utils/replaceVars.d.ts +25 -0
- package/src/utils/replaceVars.js +23 -19
- package/cjs/env.js +0 -227
- package/cjs/index.js +0 -57
- package/cjs/package.json +0 -1
- package/cjs/traverse/assemble.js +0 -145
- package/cjs/traverse/clone.js +0 -94
- package/cjs/traverse/deref.js +0 -102
- package/cjs/traverse/preprocess.js +0 -96
- package/cjs/traverse/walk.js +0 -330
- package/cjs/unifiers/matchCondition.js +0 -25
- package/cjs/unifiers/matchInstanceOf.js +0 -25
- package/cjs/unifiers/matchString.js +0 -49
- package/cjs/unifiers/matchTypeOf.js +0 -25
- package/cjs/unifiers/ref.js +0 -30
- package/cjs/unify.js +0 -549
- package/cjs/utils/replaceVars.js +0 -37
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Type definitions for deep6 deref
|
|
2
|
+
// Generated from src/traverse/deref.js
|
|
3
|
+
|
|
4
|
+
import type {Env} from '../env.js';
|
|
5
|
+
import type {WalkContext} from './walk.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options for dereferencing
|
|
9
|
+
*/
|
|
10
|
+
export interface DerefOptions {
|
|
11
|
+
/** Handle circular references (default: false) */
|
|
12
|
+
circular?: boolean;
|
|
13
|
+
/** Include symbol properties (default: false) */
|
|
14
|
+
symbols?: boolean;
|
|
15
|
+
/** Include non-enumerable properties (default: false) */
|
|
16
|
+
allProps?: boolean;
|
|
17
|
+
/** Custom context object */
|
|
18
|
+
context?: Record<string, unknown>;
|
|
19
|
+
/** Custom object processor */
|
|
20
|
+
processObject?: (object: unknown, context: WalkContext) => void;
|
|
21
|
+
/** Custom non-object value processor */
|
|
22
|
+
processOther?: (value: unknown, context: WalkContext) => void;
|
|
23
|
+
/** Custom circular reference processor */
|
|
24
|
+
processCircular?: (value: unknown, context: WalkContext) => void;
|
|
25
|
+
/** Custom type handler registry (flat array of [Constructor, handler] pairs) */
|
|
26
|
+
registry?: unknown[];
|
|
27
|
+
/** Custom filter functions */
|
|
28
|
+
filters?: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Flat array of type-specific deref pairs: [Constructor, handler, ...]
|
|
33
|
+
*
|
|
34
|
+
* Use `registry.push(Type, handler)` to register a custom handler.
|
|
35
|
+
*/
|
|
36
|
+
export declare const registry: unknown[];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Filter functions for custom deref processing
|
|
40
|
+
*/
|
|
41
|
+
export declare const filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Replaces variables with bound values in-place
|
|
45
|
+
*
|
|
46
|
+
* Unlike assemble(), modifies the existing structure directly
|
|
47
|
+
* rather than creating a new one.
|
|
48
|
+
*
|
|
49
|
+
* @param source - Value to dereference (modified in-place)
|
|
50
|
+
* @param env - Env with bindings, or options object
|
|
51
|
+
* @param options - Deref options (when env is provided separately)
|
|
52
|
+
* @returns The same source value with variables replaced
|
|
53
|
+
*/
|
|
54
|
+
export declare const deref: ((source: unknown, env?: Env | DerefOptions | null, options?: DerefOptions) => unknown) & {
|
|
55
|
+
registry: unknown[];
|
|
56
|
+
filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default deref;
|
package/src/traverse/deref.js
CHANGED
|
@@ -22,7 +22,7 @@ function postProcessMap(context) {
|
|
|
22
22
|
const stackOut = context.stackOut,
|
|
23
23
|
s = this.s;
|
|
24
24
|
let j = stackOut.length - 1;
|
|
25
|
-
for (const key of s) {
|
|
25
|
+
for (const key of s.keys()) {
|
|
26
26
|
s.set(key, stackOut[j--]);
|
|
27
27
|
}
|
|
28
28
|
replaceObject(j, s, stackOut);
|
|
@@ -54,6 +54,7 @@ const registry = [
|
|
|
54
54
|
|
|
55
55
|
const addType = (Type, process) => registry.push(Type, process || processOther);
|
|
56
56
|
|
|
57
|
+
typeof URL == 'function' && addType(URL);
|
|
57
58
|
typeof Int8Array == 'function' && addType(Int8Array);
|
|
58
59
|
typeof Uint8Array == 'function' && addType(Uint8Array);
|
|
59
60
|
typeof Uint8ClampedArray == 'function' && addType(Uint8ClampedArray);
|
|
@@ -100,5 +101,5 @@ const deref = (source, env, options) => {
|
|
|
100
101
|
deref.registry = registry;
|
|
101
102
|
deref.filters = filters;
|
|
102
103
|
|
|
103
|
-
export {registry, filters};
|
|
104
|
+
export {registry, filters, deref};
|
|
104
105
|
export default deref;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Type definitions for deep6 preprocess
|
|
2
|
+
// Generated from src/traverse/preprocess.js
|
|
3
|
+
|
|
4
|
+
import type {WalkContext} from './walk.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for pattern preprocessing
|
|
8
|
+
*/
|
|
9
|
+
export interface PreprocessOptions {
|
|
10
|
+
/** Wrap plain objects with open() (default: false) */
|
|
11
|
+
openObjects?: boolean;
|
|
12
|
+
/** Wrap arrays with open() (default: false) */
|
|
13
|
+
openArrays?: boolean;
|
|
14
|
+
/** Wrap Maps with open() (default: false) */
|
|
15
|
+
openMaps?: boolean;
|
|
16
|
+
/** Wrap Sets with open() (default: false) */
|
|
17
|
+
openSets?: boolean;
|
|
18
|
+
/** Handle circular references */
|
|
19
|
+
circular?: boolean;
|
|
20
|
+
/** Include symbol properties */
|
|
21
|
+
symbols?: boolean;
|
|
22
|
+
/** Include non-enumerable properties */
|
|
23
|
+
allProps?: boolean;
|
|
24
|
+
/** Custom context object */
|
|
25
|
+
context?: Record<string, unknown>;
|
|
26
|
+
/** Custom object processor */
|
|
27
|
+
processObject?: (object: unknown, context: WalkContext) => void;
|
|
28
|
+
/** Custom non-object value processor */
|
|
29
|
+
processOther?: (value: unknown, context: WalkContext) => void;
|
|
30
|
+
/** Custom circular reference processor */
|
|
31
|
+
processCircular?: (value: unknown, context: WalkContext) => void;
|
|
32
|
+
/** Custom type handler registry (flat array of [Constructor, handler] pairs) */
|
|
33
|
+
registry?: unknown[];
|
|
34
|
+
/** Custom filter functions */
|
|
35
|
+
filters?: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Flat array of type-specific preprocessor pairs: [Constructor, handler, ...]
|
|
40
|
+
*
|
|
41
|
+
* Use `registry.push(Type, handler)` to register a custom preprocessor.
|
|
42
|
+
*/
|
|
43
|
+
export declare const registry: unknown[];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Filter functions for custom preprocessing
|
|
47
|
+
*/
|
|
48
|
+
export declare const filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Preprocesses a pattern for unification
|
|
52
|
+
*
|
|
53
|
+
* Wraps objects, arrays, Maps, and Sets with open/soft markers
|
|
54
|
+
* based on options. Used internally by match().
|
|
55
|
+
*
|
|
56
|
+
* @param source - Pattern to preprocess
|
|
57
|
+
* @param options - Preprocessing options
|
|
58
|
+
* @returns Preprocessed pattern ready for unification
|
|
59
|
+
*/
|
|
60
|
+
export declare const preprocess: ((source: unknown, options?: PreprocessOptions) => unknown) & {
|
|
61
|
+
registry: unknown[];
|
|
62
|
+
filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default preprocess;
|
|
@@ -63,6 +63,7 @@ const registry = [
|
|
|
63
63
|
|
|
64
64
|
const addType = (Type, process) => registry.push(Type, process || processOther);
|
|
65
65
|
|
|
66
|
+
typeof URL == 'function' && addType(URL);
|
|
66
67
|
typeof Int8Array == 'function' && addType(Int8Array);
|
|
67
68
|
typeof Uint8Array == 'function' && addType(Uint8Array);
|
|
68
69
|
typeof Uint8ClampedArray == 'function' && addType(Uint8ClampedArray);
|
|
@@ -108,5 +109,5 @@ const preprocess = (source, options) => {
|
|
|
108
109
|
preprocess.registry = registry;
|
|
109
110
|
preprocess.filters = filters;
|
|
110
111
|
|
|
111
|
-
export {registry, filters};
|
|
112
|
+
export {registry, filters, preprocess};
|
|
112
113
|
export default preprocess;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Type definitions for deep6 walk
|
|
2
|
+
// Generated from src/traverse/walk.js
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Context object available during walk traversal
|
|
6
|
+
*/
|
|
7
|
+
export interface WalkContext {
|
|
8
|
+
/** Stack of values to process */
|
|
9
|
+
stack: unknown[];
|
|
10
|
+
/** Output stack for processed values */
|
|
11
|
+
stackOut: unknown[];
|
|
12
|
+
/** Map tracking circular references (present when circular: true) */
|
|
13
|
+
seen: Map<unknown, {value?: unknown; actions?: Array<[unknown, unknown]>}> | null;
|
|
14
|
+
/** Include symbol properties */
|
|
15
|
+
symbols?: boolean;
|
|
16
|
+
/** Include non-enumerable properties */
|
|
17
|
+
allProps?: boolean;
|
|
18
|
+
/** Optional environment for variable handling */
|
|
19
|
+
env?: unknown;
|
|
20
|
+
/** Wrapper for Maps (set by preprocess) */
|
|
21
|
+
wrapMap?: (map: Map<unknown, unknown>) => unknown;
|
|
22
|
+
/** Wrapper for Arrays (set by preprocess) */
|
|
23
|
+
wrapArray?: (array: unknown[]) => unknown;
|
|
24
|
+
/** Wrapper for Objects (set by preprocess) */
|
|
25
|
+
wrapObject?: (object: unknown) => unknown;
|
|
26
|
+
/** Wrapper for Sets (set by preprocess) */
|
|
27
|
+
wrapSet?: (set: Set<unknown>) => unknown;
|
|
28
|
+
/** Additional context properties */
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Options for walk traversal
|
|
34
|
+
*/
|
|
35
|
+
export interface WalkOptions {
|
|
36
|
+
/** Custom object processor */
|
|
37
|
+
processObject?: (object: unknown, context: WalkContext) => void;
|
|
38
|
+
/** Custom non-object value processor */
|
|
39
|
+
processOther?: (value: unknown, context: WalkContext) => void;
|
|
40
|
+
/** Custom circular reference processor */
|
|
41
|
+
processCircular?: (value: unknown, context: WalkContext) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Flat array of type handler pairs: [Constructor, handler, Constructor, handler, ...]
|
|
44
|
+
*
|
|
45
|
+
* Each pair maps a constructor to a processing function.
|
|
46
|
+
*/
|
|
47
|
+
registry?: unknown[];
|
|
48
|
+
/** Array of filter functions — return true to indicate value was handled */
|
|
49
|
+
filters?: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
50
|
+
/** Enable circular reference detection */
|
|
51
|
+
circular?: boolean;
|
|
52
|
+
/** Include symbol properties */
|
|
53
|
+
symbols?: boolean;
|
|
54
|
+
/** Include non-enumerable properties */
|
|
55
|
+
allProps?: boolean;
|
|
56
|
+
/** Custom context object (properties are merged into WalkContext) */
|
|
57
|
+
context?: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Marker for values that were already seen (circular references)
|
|
62
|
+
*/
|
|
63
|
+
export declare class Circular {
|
|
64
|
+
/** The already-seen value */
|
|
65
|
+
value: unknown;
|
|
66
|
+
constructor(value: unknown);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Deferred processing command pushed onto the walk stack
|
|
71
|
+
*/
|
|
72
|
+
export declare class Command {
|
|
73
|
+
/** Function to execute during post-processing */
|
|
74
|
+
f: (context: WalkContext) => void;
|
|
75
|
+
/** Source object being processed */
|
|
76
|
+
s: unknown;
|
|
77
|
+
constructor(f: (context: WalkContext) => void, s: unknown);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Non-recursive stack-based object tree walker
|
|
82
|
+
*
|
|
83
|
+
* Traverses values using an explicit stack with support for
|
|
84
|
+
* circular references, type registries, and filters.
|
|
85
|
+
*
|
|
86
|
+
* @param o - Value to traverse
|
|
87
|
+
* @param options - Walk options and processors
|
|
88
|
+
*/
|
|
89
|
+
export declare const walk: ((o: unknown, options?: WalkOptions) => void) & {
|
|
90
|
+
Command: typeof Command;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Default type handler registry (flat array of [Constructor, handler] pairs)
|
|
95
|
+
*/
|
|
96
|
+
export declare const registry: unknown[];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Default filter functions
|
|
100
|
+
*/
|
|
101
|
+
export declare const filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
102
|
+
|
|
103
|
+
// Utility processors
|
|
104
|
+
|
|
105
|
+
/** Pushes value to stackOut unchanged */
|
|
106
|
+
export declare const processOther: (value: unknown, context: WalkContext) => void;
|
|
107
|
+
|
|
108
|
+
/** Pushes a Circular marker to stackOut */
|
|
109
|
+
export declare const processCircular: (value: unknown, context: WalkContext) => void;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Creates a Map processor with optional post-processing
|
|
113
|
+
* @param postProcess - Post-processor for normal flow
|
|
114
|
+
* @param postProcessSeen - Post-processor when circular refs are tracked
|
|
115
|
+
* @returns Map processing function
|
|
116
|
+
*/
|
|
117
|
+
export declare const processMap: (
|
|
118
|
+
postProcess?: (context: WalkContext) => void,
|
|
119
|
+
postProcessSeen?: (context: WalkContext) => void
|
|
120
|
+
) => (object: Map<unknown, unknown>, context: WalkContext) => void;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Post-processes a Map with circular reference resolution
|
|
124
|
+
* @param source - Original Map
|
|
125
|
+
* @param context - Walk context
|
|
126
|
+
*/
|
|
127
|
+
export declare const postMapCircular: (source: Map<unknown, unknown>, context: WalkContext) => void;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Builds a new Map from processed values on stackOut
|
|
131
|
+
* @param keys - Keys for the new Map
|
|
132
|
+
* @param stackOut - Output stack with values
|
|
133
|
+
* @param wrap - Optional wrapper function
|
|
134
|
+
*/
|
|
135
|
+
export declare const buildNewMap: (keys: Iterable<unknown>, stackOut: unknown[], wrap?: (map: Map<unknown, unknown>) => unknown) => void;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Replaces stackOut entries from upTo to end with a single object
|
|
139
|
+
* @param upTo - Index offset from end
|
|
140
|
+
* @param object - Object to push
|
|
141
|
+
* @param stackOut - Output stack
|
|
142
|
+
*/
|
|
143
|
+
export declare const replaceObject: (upTo: number, object: unknown, stackOut: unknown[]) => void;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates an Object processor with optional post-processing
|
|
147
|
+
* @param postProcess - Post-processor for normal flow
|
|
148
|
+
* @param postProcessSeen - Post-processor when circular refs are tracked
|
|
149
|
+
* @returns Object processing function
|
|
150
|
+
*/
|
|
151
|
+
export declare const processObject: (
|
|
152
|
+
postProcess?: (context: WalkContext) => void,
|
|
153
|
+
postProcessSeen?: (context: WalkContext) => void
|
|
154
|
+
) => (object: unknown, context: WalkContext) => void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Post-processes an Object with circular reference resolution
|
|
158
|
+
* @param source - Original object
|
|
159
|
+
* @param descriptors - Property descriptors
|
|
160
|
+
* @param keys - Property keys
|
|
161
|
+
* @param context - Walk context
|
|
162
|
+
*/
|
|
163
|
+
export declare const postObjectCircular: (
|
|
164
|
+
source: unknown,
|
|
165
|
+
descriptors: Record<string | symbol, PropertyDescriptor>,
|
|
166
|
+
keys: Array<string | symbol>,
|
|
167
|
+
context: WalkContext
|
|
168
|
+
) => void;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Extracts property descriptors and keys from an object
|
|
172
|
+
* @param object - Object to analyze
|
|
173
|
+
* @param context - Walk context (uses symbols and allProps flags)
|
|
174
|
+
* @returns Descriptors and keys
|
|
175
|
+
*/
|
|
176
|
+
export declare const getObjectData: (
|
|
177
|
+
object: unknown,
|
|
178
|
+
context: WalkContext
|
|
179
|
+
) => {descriptors: Record<string | symbol, PropertyDescriptor>; keys: Array<string | symbol>};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Builds a new object from processed values on stackOut
|
|
183
|
+
* @param source - Original object (used for prototype and array detection)
|
|
184
|
+
* @param descriptors - Property descriptors
|
|
185
|
+
* @param keys - Property keys
|
|
186
|
+
* @param stackOut - Output stack with values
|
|
187
|
+
* @param wrap - Optional wrapper function
|
|
188
|
+
*/
|
|
189
|
+
export declare const buildNewObject: (
|
|
190
|
+
source: unknown,
|
|
191
|
+
descriptors: Record<string | symbol, PropertyDescriptor>,
|
|
192
|
+
keys: Array<string | symbol>,
|
|
193
|
+
stackOut: unknown[],
|
|
194
|
+
wrap?: (object: unknown) => unknown
|
|
195
|
+
) => void;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Resolves a Variable to its bound value and pushes to the stack
|
|
199
|
+
* @param val - Variable instance
|
|
200
|
+
* @param context - Walk context (uses context.env)
|
|
201
|
+
*/
|
|
202
|
+
export declare const processVariable: (val: unknown, context: WalkContext) => void;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Executes a Command's function
|
|
206
|
+
* @param val - Command instance
|
|
207
|
+
* @param context - Walk context
|
|
208
|
+
*/
|
|
209
|
+
export declare const processCommand: (val: unknown, context: WalkContext) => void;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Resolves circular reference actions for a seen object
|
|
213
|
+
* @param seen - Map of seen objects
|
|
214
|
+
* @param source - Source object
|
|
215
|
+
* @param value - Resolved value
|
|
216
|
+
*/
|
|
217
|
+
export declare const setObject: (seen: Map<unknown, {value?: unknown; actions?: Array<[unknown, unknown]>}>, source: unknown, value: unknown) => void;
|
|
218
|
+
|
|
219
|
+
export default walk;
|
package/src/traverse/walk.js
CHANGED
|
@@ -34,7 +34,10 @@ const processCircular = (value, context) => context.stackOut.push(new Circular(v
|
|
|
34
34
|
|
|
35
35
|
const processMap = (postProcess, postProcessSeen) => (object, context) => {
|
|
36
36
|
const stack = context.stack;
|
|
37
|
-
|
|
37
|
+
if (postProcess) {
|
|
38
|
+
const processor = context.seen && postProcessSeen ? postProcessSeen : postProcess;
|
|
39
|
+
stack.push(new Command(processor, object));
|
|
40
|
+
}
|
|
38
41
|
for (const value of object.values()) {
|
|
39
42
|
stack.push(value);
|
|
40
43
|
}
|
|
@@ -170,8 +173,9 @@ class Command {
|
|
|
170
173
|
|
|
171
174
|
const processCommand = (val, context) => val.f(context);
|
|
172
175
|
|
|
173
|
-
const defaultRegistry = [Command, processCommand, Array, processObject(), Date, nop, RegExp, nop, Map, processMap(), Set, nop, Promise, nop]
|
|
174
|
-
|
|
176
|
+
const defaultRegistry = [Command, processCommand, Array, processObject(), Date, nop, RegExp, nop, Map, processMap(), Set, nop, Promise, nop];
|
|
177
|
+
typeof URL == 'function' && defaultRegistry.push(URL, nop);
|
|
178
|
+
const defaultFilters = [];
|
|
175
179
|
|
|
176
180
|
// add more types
|
|
177
181
|
|
|
@@ -257,6 +261,7 @@ export {
|
|
|
257
261
|
getObjectData,
|
|
258
262
|
buildNewObject,
|
|
259
263
|
processVariable,
|
|
260
|
-
processCommand
|
|
264
|
+
processCommand,
|
|
265
|
+
walk
|
|
261
266
|
};
|
|
262
267
|
export default walk;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Type definitions for deep6 matchCondition unifier
|
|
2
|
+
// Generated from src/unifiers/matchCondition.js
|
|
3
|
+
|
|
4
|
+
import type {Unifier, Env} from '../env.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Predicate-based matching unifier
|
|
8
|
+
*
|
|
9
|
+
* Delegates matching to a user-supplied function that receives
|
|
10
|
+
* the full unification context (value, stacks, environment).
|
|
11
|
+
*/
|
|
12
|
+
export declare class MatchCondition extends Unifier {
|
|
13
|
+
/** Predicate function */
|
|
14
|
+
f: (val: unknown, ls: unknown[], rs: unknown[], env: Env) => boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param f - Predicate that returns true if the value matches
|
|
18
|
+
*/
|
|
19
|
+
constructor(f: (val: unknown, ls: unknown[], rs: unknown[], env: Env) => boolean);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Delegates to the predicate function
|
|
23
|
+
* @param val - Value to test
|
|
24
|
+
* @param ls - Left argument stack
|
|
25
|
+
* @param rs - Right argument stack
|
|
26
|
+
* @param env - Unification environment
|
|
27
|
+
* @returns Result of the predicate
|
|
28
|
+
*/
|
|
29
|
+
unify(val: unknown, ls: unknown[], rs: unknown[], env: Env): boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates a predicate matcher
|
|
34
|
+
*
|
|
35
|
+
* @param f - Predicate function `(val, ls, rs, env) => boolean`
|
|
36
|
+
* @returns A new MatchCondition instance
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const isPositive = matchCondition(val => typeof val === 'number' && val > 0);
|
|
41
|
+
* match({n: 5}, {n: isPositive}); // true
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const matchCondition: (f: (val: unknown, ls: unknown[], rs: unknown[], env: Env) => boolean) => MatchCondition;
|
|
45
|
+
export default matchCondition;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Type definitions for deep6 matchInstanceOf unifier
|
|
2
|
+
// Generated from src/unifiers/matchInstanceOf.js
|
|
3
|
+
|
|
4
|
+
import type {Unifier} from '../env.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Instanceof-based matching unifier
|
|
8
|
+
*
|
|
9
|
+
* Matches values by their prototype chain. Rejects falsy values and unbound Variables.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MatchInstanceOf extends Unifier {
|
|
12
|
+
/** Array of constructors to match against */
|
|
13
|
+
types: (new (...args: any[]) => unknown)[];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param types - Constructor or array of constructors
|
|
17
|
+
*/
|
|
18
|
+
constructor(types: (new (...args: any[]) => unknown) | (new (...args: any[]) => unknown)[]);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Tests if the value is an instance of one of the configured constructors
|
|
22
|
+
* @param val - Value to check
|
|
23
|
+
* @param ls - Left argument stack (unused)
|
|
24
|
+
* @param rs - Right argument stack (unused)
|
|
25
|
+
* @returns True if val is an instance of any configured type
|
|
26
|
+
*/
|
|
27
|
+
unify(val: unknown, ls: unknown[], rs: unknown[]): boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instanceof matcher
|
|
32
|
+
*
|
|
33
|
+
* @param types - Constructor(s) to match against
|
|
34
|
+
* @returns A new MatchInstanceOf instance
|
|
35
|
+
*/
|
|
36
|
+
export declare const matchInstanceOf: (types: (new (...args: any[]) => unknown) | (new (...args: any[]) => unknown)[]) => MatchInstanceOf;
|
|
37
|
+
export default matchInstanceOf;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Type definitions for deep6 matchString unifier
|
|
2
|
+
// Generated from src/unifiers/matchString.js
|
|
3
|
+
|
|
4
|
+
import type {Unifier} from '../env.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* RegExp-based string matching unifier
|
|
8
|
+
*
|
|
9
|
+
* Matches values against a regular expression. Optionally captures
|
|
10
|
+
* the match array and match properties (index, input) for variable binding.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MatchString extends Unifier {
|
|
13
|
+
/** Regular expression to match against */
|
|
14
|
+
regexp: RegExp;
|
|
15
|
+
/** Pattern to unify with the match result array (optional) */
|
|
16
|
+
matches?: unknown;
|
|
17
|
+
/** Pattern to unify with match properties {index, input} (optional) */
|
|
18
|
+
props?: unknown;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param regexp - Regular expression to match
|
|
22
|
+
* @param matches - Pattern to unify with match array (optional)
|
|
23
|
+
* @param props - Pattern to unify with {index, input} (optional)
|
|
24
|
+
*/
|
|
25
|
+
constructor(regexp: RegExp, matches?: unknown, props?: unknown);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Tests a value against the regex and pushes capture bindings
|
|
29
|
+
* @param val - Value to match (coerced to string)
|
|
30
|
+
* @param ls - Left argument stack
|
|
31
|
+
* @param rs - Right argument stack
|
|
32
|
+
* @returns Truthy if the regex matches
|
|
33
|
+
*/
|
|
34
|
+
unify(val: unknown, ls: unknown[], rs: unknown[]): boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a regex string matcher
|
|
39
|
+
*
|
|
40
|
+
* @param regexp - Regular expression to match against
|
|
41
|
+
* @param matches - Pattern to unify with the full match array (optional)
|
|
42
|
+
* @param props - Pattern to unify with {index, input} (optional)
|
|
43
|
+
* @returns A new MatchString instance
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // Simple matching
|
|
48
|
+
* matchString(/^hello/i);
|
|
49
|
+
*
|
|
50
|
+
* // With captures bound to a variable array
|
|
51
|
+
* const names = [any, variable('first'), variable('last')];
|
|
52
|
+
* matchString(/^(\w+)\s+(\w+)$/, names);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const matchString: (regexp: RegExp, matches?: unknown, props?: unknown) => MatchString;
|
|
56
|
+
export default matchString;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Type definitions for deep6 matchTypeOf unifier
|
|
2
|
+
// Generated from src/unifiers/matchTypeOf.js
|
|
3
|
+
|
|
4
|
+
import type {Unifier} from '../env.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type-based matching unifier
|
|
8
|
+
*
|
|
9
|
+
* Matches values by their `typeof` result. Rejects unbound Variables.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MatchTypeOf extends Unifier {
|
|
12
|
+
/** Array of type names to match against */
|
|
13
|
+
types: string[];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param types - Type name or array of type names
|
|
17
|
+
*/
|
|
18
|
+
constructor(types: string | string[]);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Tests if the value's typeof matches one of the configured types
|
|
22
|
+
* @param val - Value to check
|
|
23
|
+
* @param ls - Left argument stack (unused)
|
|
24
|
+
* @param rs - Right argument stack (unused)
|
|
25
|
+
* @returns True if typeof val matches
|
|
26
|
+
*/
|
|
27
|
+
unify(val: unknown, ls: unknown[], rs: unknown[]): boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates a typeof matcher
|
|
32
|
+
*
|
|
33
|
+
* @param types - Type name(s) to match against (e.g. 'string', ['number', 'bigint'])
|
|
34
|
+
* @returns A new MatchTypeOf instance
|
|
35
|
+
*/
|
|
36
|
+
export declare const matchTypeOf: (types: string | string[]) => MatchTypeOf;
|
|
37
|
+
export default matchTypeOf;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Type definitions for deep6 ref unifier
|
|
2
|
+
// Generated from src/unifiers/ref.js
|
|
3
|
+
|
|
4
|
+
import type {Variable, Env} from '../env.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reference unifier for cross-pattern variable binding
|
|
8
|
+
*
|
|
9
|
+
* Binds both a variable and a value to the same input during unification.
|
|
10
|
+
* Pushes `(this.value, val)` and `(this.variable, val)` onto the stacks.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Ref extends Variable {
|
|
13
|
+
/** The variable being referenced */
|
|
14
|
+
variable: Variable;
|
|
15
|
+
/** The value pattern to unify against */
|
|
16
|
+
value: unknown;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param variable - Variable name (string) or Variable instance
|
|
20
|
+
* @param value - Value pattern to bind alongside the variable
|
|
21
|
+
*/
|
|
22
|
+
constructor(variable: string | Variable, value: unknown);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pushes value and variable bindings onto the stacks
|
|
26
|
+
* @param val - Input value
|
|
27
|
+
* @param ls - Left argument stack
|
|
28
|
+
* @param rs - Right argument stack
|
|
29
|
+
* @param env - Unification environment
|
|
30
|
+
* @returns Always true
|
|
31
|
+
*/
|
|
32
|
+
unify(val: unknown, ls: unknown[], rs: unknown[], env: Env): boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a reference unifier
|
|
37
|
+
*
|
|
38
|
+
* @param variable - Variable name or Variable instance
|
|
39
|
+
* @param value - Value pattern to bind alongside the variable
|
|
40
|
+
* @returns A new Ref instance
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const r = ref('x', variable('y'));
|
|
45
|
+
* // During unification, both 'x' and 'y' get bound to the matched value
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const ref: ((variable: string | Variable, value: unknown) => Ref) & {
|
|
49
|
+
Ref: typeof Ref;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default ref;
|