tape-six 1.7.12 → 1.7.14
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 +2 -0
- package/bin/tape6-bun.js +9 -3
- package/bin/tape6-deno.js +5 -3
- package/bin/tape6-node.js +8 -3
- package/bin/tape6-seq.js +5 -3
- package/index.js +7 -10
- package/package.json +2 -2
- package/src/deep6/env.d.ts +174 -0
- package/src/deep6/env.js +4 -4
- package/src/deep6/index.d.ts +86 -0
- package/src/deep6/index.js +10 -7
- package/src/deep6/traverse/assemble.d.ts +59 -0
- package/src/deep6/traverse/assemble.js +4 -3
- package/src/deep6/traverse/clone.d.ts +57 -0
- package/src/deep6/traverse/clone.js +4 -2
- package/src/deep6/traverse/deref.d.ts +59 -0
- package/src/deep6/traverse/deref.js +3 -2
- package/src/deep6/traverse/preprocess.d.ts +65 -0
- package/src/deep6/traverse/preprocess.js +2 -1
- package/src/deep6/traverse/walk.d.ts +219 -0
- package/src/deep6/traverse/walk.js +9 -4
- package/src/deep6/unifiers/matchCondition.d.ts +45 -0
- package/src/deep6/unifiers/matchCondition.js +1 -0
- package/src/deep6/unifiers/matchInstanceOf.d.ts +37 -0
- package/src/deep6/unifiers/matchInstanceOf.js +1 -0
- package/src/deep6/unifiers/matchString.d.ts +56 -0
- package/src/deep6/unifiers/matchString.js +1 -0
- package/src/deep6/unifiers/matchTypeOf.d.ts +37 -0
- package/src/deep6/unifiers/matchTypeOf.js +1 -0
- package/src/deep6/unifiers/ref.d.ts +52 -0
- package/src/deep6/unifiers/ref.js +1 -0
- package/src/deep6/unify.d.ts +95 -0
- package/src/deep6/unify.js +130 -66
- package/src/deep6/utils/replaceVars.d.ts +25 -0
- package/src/deep6/utils/replaceVars.js +23 -19
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -425,6 +425,8 @@ Test output can be controlled by flags. See [Supported flags](https://github.com
|
|
|
425
425
|
|
|
426
426
|
The most recent releases:
|
|
427
427
|
|
|
428
|
+
- 1.7.14 _Updated vendored `deep6` to 1.2.0: added `URL` support (unifier/walker/cloner + processors), named exports alongside default exports, fast path for naked objects, performance optimizations, improved TS typings, removed CommonJS build._
|
|
429
|
+
- 1.7.13 _Replaced `process.exit()` / `Deno.exit()` with `process.exitCode` in test runners and `index.js` for graceful stdout flushing. Updated dependencies, GitHub Actions._
|
|
428
430
|
- 1.7.12 _Added `--help`/`-h` and `--version`/`-v` options to all CLI utilities. Added flag documentation to help output._
|
|
429
431
|
- 1.7.11 _Documentation consistency: added missing sequential test commands to AI docs, fixed test glob references._
|
|
430
432
|
- 1.7.10 _Switched from workflows to Agent Skills (agentskills.io) for consumer integration. Improved CJS import docs._
|
package/bin/tape6-bun.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
+
import process from 'node:process';
|
|
3
4
|
import {fileURLToPath} from 'node:url';
|
|
4
5
|
|
|
5
6
|
import {
|
|
@@ -68,12 +69,16 @@ const main = async () => {
|
|
|
68
69
|
|
|
69
70
|
if (currentOptions.optionFlags['--info'] === '') {
|
|
70
71
|
showInfo(currentOptions, files);
|
|
71
|
-
process.
|
|
72
|
+
await new Promise(r => process.stdout.write('', r));
|
|
73
|
+
process.exitCode = 0;
|
|
74
|
+
return;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
if (!files.length) {
|
|
75
78
|
console.log('No files found.');
|
|
76
|
-
process.
|
|
79
|
+
await new Promise(r => process.stdout.write('', r));
|
|
80
|
+
process.exitCode = 1;
|
|
81
|
+
return;
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
const reporter = getReporter(),
|
|
@@ -94,7 +99,8 @@ const main = async () => {
|
|
|
94
99
|
fail: hasFailed
|
|
95
100
|
});
|
|
96
101
|
|
|
97
|
-
process.
|
|
102
|
+
await new Promise(r => process.stdout.write('', r));
|
|
103
|
+
process.exitCode = hasFailed ? 1 : 0;
|
|
98
104
|
};
|
|
99
105
|
|
|
100
106
|
main().catch(error => console.error('ERROR:', error));
|
package/bin/tape6-deno.js
CHANGED
|
@@ -70,13 +70,15 @@ const main = async () => {
|
|
|
70
70
|
if (currentOptions.optionFlags['--info'] === '') {
|
|
71
71
|
showInfo(currentOptions, files);
|
|
72
72
|
await new Promise(r => process.stdout.write('', r));
|
|
73
|
-
|
|
73
|
+
process.exitCode = 0;
|
|
74
|
+
return;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
if (!files.length) {
|
|
77
78
|
console.log('No files found.');
|
|
78
79
|
await new Promise(r => process.stdout.write('', r));
|
|
79
|
-
|
|
80
|
+
process.exitCode = 1;
|
|
81
|
+
return;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
const reporter = getReporter(),
|
|
@@ -98,7 +100,7 @@ const main = async () => {
|
|
|
98
100
|
});
|
|
99
101
|
|
|
100
102
|
await new Promise(r => process.stdout.write('', r));
|
|
101
|
-
|
|
103
|
+
process.exitCode = hasFailed ? 1 : 0;
|
|
102
104
|
};
|
|
103
105
|
|
|
104
106
|
main().catch(error => console.error('ERROR:', error));
|
package/bin/tape6-node.js
CHANGED
|
@@ -69,12 +69,16 @@ const main = async () => {
|
|
|
69
69
|
|
|
70
70
|
if (currentOptions.optionFlags['--info'] === '') {
|
|
71
71
|
showInfo(currentOptions, files);
|
|
72
|
-
process.
|
|
72
|
+
await new Promise(r => process.stdout.write('', r));
|
|
73
|
+
process.exitCode = 0;
|
|
74
|
+
return;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
if (!files.length) {
|
|
76
78
|
console.log('No files found.');
|
|
77
|
-
process.
|
|
79
|
+
await new Promise(r => process.stdout.write('', r));
|
|
80
|
+
process.exitCode = 1;
|
|
81
|
+
return;
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
const reporter = getReporter(),
|
|
@@ -95,7 +99,8 @@ const main = async () => {
|
|
|
95
99
|
fail: hasFailed
|
|
96
100
|
});
|
|
97
101
|
|
|
98
|
-
process.
|
|
102
|
+
await new Promise(r => process.stdout.write('', r));
|
|
103
|
+
process.exitCode = hasFailed ? 1 : 0;
|
|
99
104
|
};
|
|
100
105
|
|
|
101
106
|
main().catch(error => console.error('ERROR:', error));
|
package/bin/tape6-seq.js
CHANGED
|
@@ -79,13 +79,15 @@ const main = async () => {
|
|
|
79
79
|
if (currentOptions.optionFlags['--info'] === '') {
|
|
80
80
|
showInfo(currentOptions, files);
|
|
81
81
|
await new Promise(r => process.stdout.write('', r));
|
|
82
|
-
process.
|
|
82
|
+
process.exitCode = 0;
|
|
83
|
+
return;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
if (!files.length) {
|
|
86
87
|
console.log('No files found.');
|
|
87
88
|
await new Promise(r => process.stdout.write('', r));
|
|
88
|
-
process.
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
return;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
const reporter = getReporter(),
|
|
@@ -107,7 +109,7 @@ const main = async () => {
|
|
|
107
109
|
});
|
|
108
110
|
|
|
109
111
|
await new Promise(r => process.stdout.write('', r));
|
|
110
|
-
process.
|
|
112
|
+
process.exitCode = hasFailed ? 1 : 0;
|
|
111
113
|
};
|
|
112
114
|
|
|
113
115
|
main().catch(error => console.error('ERROR:', error));
|
package/index.js
CHANGED
|
@@ -46,6 +46,7 @@ const init = async () => {
|
|
|
46
46
|
const isNode = typeof process == 'object' && process.versions?.node,
|
|
47
47
|
isDeno = typeof Deno == 'object',
|
|
48
48
|
isBun = typeof Bun == 'object',
|
|
49
|
+
isCli = isNode || isBun || isDeno,
|
|
49
50
|
isBrowser = typeof window == 'object' && !!window.location,
|
|
50
51
|
options = {};
|
|
51
52
|
|
|
@@ -74,7 +75,7 @@ const init = async () => {
|
|
|
74
75
|
|
|
75
76
|
let originalConsole = null,
|
|
76
77
|
setCurrentReporter = null;
|
|
77
|
-
if (!options.noConsoleCapture &&
|
|
78
|
+
if (!options.noConsoleCapture && isCli) {
|
|
78
79
|
const {captureConsole, setCurrentReporter: setReporter} = await import(
|
|
79
80
|
new URL('./src/utils/capture-console.js', import.meta.url)
|
|
80
81
|
);
|
|
@@ -161,7 +162,7 @@ const init = async () => {
|
|
|
161
162
|
setCurrentReporter?.(reporter);
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
return {options, isBrowser, isBun, isDeno, isNode};
|
|
165
|
+
return {options, isBrowser, isBun, isDeno, isNode, isCli};
|
|
165
166
|
};
|
|
166
167
|
|
|
167
168
|
const getTestFileName = ({isBrowser, isBun, isDeno, isNode}) => {
|
|
@@ -193,7 +194,7 @@ const testRunner = async () => {
|
|
|
193
194
|
settings = await init();
|
|
194
195
|
}
|
|
195
196
|
|
|
196
|
-
const {isBrowser,
|
|
197
|
+
const {isBrowser, isCli} = settings,
|
|
197
198
|
reporter = getReporter(),
|
|
198
199
|
testFileName = getTestFileName(settings);
|
|
199
200
|
|
|
@@ -235,13 +236,9 @@ const testRunner = async () => {
|
|
|
235
236
|
fail: runHasFailed
|
|
236
237
|
});
|
|
237
238
|
|
|
238
|
-
if (!getConfiguredFlag()) {
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
} else if (isBun) {
|
|
242
|
-
runHasFailed && process.exit(1);
|
|
243
|
-
} else if (isNode) {
|
|
244
|
-
runHasFailed && process.exit(1);
|
|
239
|
+
if (!getConfiguredFlag() && runHasFailed) {
|
|
240
|
+
if (isCli) {
|
|
241
|
+
process.exitCode = 1;
|
|
245
242
|
}
|
|
246
243
|
}
|
|
247
244
|
if (isBrowser && typeof __tape6_reportResults == 'function') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tape-six",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.14",
|
|
4
4
|
"description": "TAP-inspired unit test library for Node, Deno, Bun, and browsers. ES modules, TypeScript, zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -104,6 +104,6 @@
|
|
|
104
104
|
"@types/chai": "^5.2.3",
|
|
105
105
|
"@types/node": "^25.5.0",
|
|
106
106
|
"chai": "^6.2.2",
|
|
107
|
-
"typescript": "^
|
|
107
|
+
"typescript": "^6.0.2"
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// Type definitions for deep6 environment
|
|
2
|
+
// Generated from src/env.js
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unification environment managing variable bindings and stack frames
|
|
6
|
+
*
|
|
7
|
+
* Maintains two parallel prototype-chain structures:
|
|
8
|
+
* - `variables`: maps variable names to their alias groups
|
|
9
|
+
* - `values`: maps variable names/aliases to their bound values
|
|
10
|
+
*
|
|
11
|
+
* Stack frames enable scoped bindings that can be reverted.
|
|
12
|
+
*/
|
|
13
|
+
export declare class Env {
|
|
14
|
+
/** Map of variable names to their alias groups */
|
|
15
|
+
variables: Record<string | symbol, unknown>;
|
|
16
|
+
/** Map of variable names/aliases to their bound values */
|
|
17
|
+
values: Record<string | symbol, unknown>;
|
|
18
|
+
/** Current stack frame depth */
|
|
19
|
+
depth: number;
|
|
20
|
+
|
|
21
|
+
constructor();
|
|
22
|
+
|
|
23
|
+
/** Pushes a new stack frame for nested scoping */
|
|
24
|
+
push(): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Pops the current stack frame, reverting bindings
|
|
28
|
+
* @throws {Error} If stack is empty
|
|
29
|
+
*/
|
|
30
|
+
pop(): void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reverts to a specific stack frame depth
|
|
34
|
+
* @param depth - Target depth to revert to
|
|
35
|
+
* @throws {Error} If depth is higher than current depth
|
|
36
|
+
*/
|
|
37
|
+
revert(depth: number): void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates an alias between two variable names
|
|
41
|
+
* @param name1 - First variable name
|
|
42
|
+
* @param name2 - Second variable name
|
|
43
|
+
*/
|
|
44
|
+
bindVar(name1: string | symbol, name2: string | symbol): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Binds a variable name (and its aliases) to a value
|
|
48
|
+
* @param name - Variable name to bind
|
|
49
|
+
* @param val - Value to bind
|
|
50
|
+
*/
|
|
51
|
+
bindVal(name: string | symbol, val: unknown): void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Checks if a variable is bound to a value
|
|
55
|
+
* @param name - Variable name to check
|
|
56
|
+
* @returns True if variable has a bound value
|
|
57
|
+
*/
|
|
58
|
+
isBound(name: string | symbol): boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Checks if two variable names are aliases
|
|
62
|
+
* @param name1 - First variable name
|
|
63
|
+
* @param name2 - Second variable name
|
|
64
|
+
* @returns True if variables are aliases
|
|
65
|
+
*/
|
|
66
|
+
isAlias(name1: string | symbol, name2: string | symbol): boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Gets the value bound to a variable
|
|
70
|
+
* @param name - Variable name
|
|
71
|
+
* @returns The bound value, or undefined if unbound
|
|
72
|
+
*/
|
|
73
|
+
get(name: string | symbol): unknown;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns all variable bindings (for debugging)
|
|
77
|
+
* @returns Array of name/value pairs
|
|
78
|
+
*/
|
|
79
|
+
getAllValues(): Array<{name: string | symbol; value: unknown}>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Base class for custom unification behavior
|
|
84
|
+
*
|
|
85
|
+
* Subclasses must implement the `unify` method.
|
|
86
|
+
*/
|
|
87
|
+
export declare class Unifier {
|
|
88
|
+
/**
|
|
89
|
+
* Unifies this unifier with a value
|
|
90
|
+
* @param val - Value to unify with
|
|
91
|
+
* @param ls - Left argument stack
|
|
92
|
+
* @param rs - Right argument stack
|
|
93
|
+
* @param env - Unification environment
|
|
94
|
+
* @returns True if unification succeeds
|
|
95
|
+
*/
|
|
96
|
+
unify(val: unknown, ls: unknown[], rs: unknown[], env: Env): boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Type guard for Unifier instances
|
|
101
|
+
* @param x - Value to check
|
|
102
|
+
* @returns True if x is a Unifier
|
|
103
|
+
*/
|
|
104
|
+
export declare const isUnifier: (x: unknown) => x is Unifier;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Wildcard symbol that matches any value during unification
|
|
108
|
+
*/
|
|
109
|
+
export declare const any: unique symbol;
|
|
110
|
+
|
|
111
|
+
/** Alias for `any` */
|
|
112
|
+
export declare const _: typeof any;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Logical variable for capturing values during unification
|
|
116
|
+
*
|
|
117
|
+
* Variables can be bound to values, aliased to other variables,
|
|
118
|
+
* and dereferenced through an Env.
|
|
119
|
+
*/
|
|
120
|
+
export declare class Variable extends Unifier {
|
|
121
|
+
/** Variable identifier */
|
|
122
|
+
name: string | symbol;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @param name - Optional identifier (defaults to a unique Symbol)
|
|
126
|
+
*/
|
|
127
|
+
constructor(name?: string | symbol);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Checks if this variable is bound in the given environment
|
|
131
|
+
* @param env - Unification environment
|
|
132
|
+
* @returns True if bound
|
|
133
|
+
*/
|
|
134
|
+
isBound(env: Env): boolean;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Checks if this variable is aliased to another
|
|
138
|
+
* @param name - Variable name, symbol, or Variable instance
|
|
139
|
+
* @param env - Unification environment
|
|
140
|
+
* @returns True if aliased
|
|
141
|
+
*/
|
|
142
|
+
isAlias(name: Variable | string | symbol, env: Env): boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Gets the bound value of this variable
|
|
146
|
+
* @param env - Unification environment
|
|
147
|
+
* @returns The bound value, or undefined if unbound
|
|
148
|
+
*/
|
|
149
|
+
get(env: Env): unknown;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Unifies this variable with a value
|
|
153
|
+
* @param val - Value to unify with
|
|
154
|
+
* @param ls - Left argument stack
|
|
155
|
+
* @param rs - Right argument stack
|
|
156
|
+
* @param env - Unification environment
|
|
157
|
+
* @returns True if unification succeeds
|
|
158
|
+
*/
|
|
159
|
+
unify(val: unknown, ls: unknown[], rs: unknown[], env: Env): boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Type guard for Variable instances
|
|
164
|
+
* @param x - Value to check
|
|
165
|
+
* @returns True if x is a Variable
|
|
166
|
+
*/
|
|
167
|
+
export declare const isVariable: (x: unknown) => x is Variable;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Creates a new Variable
|
|
171
|
+
* @param name - Optional identifier (defaults to a unique Symbol)
|
|
172
|
+
* @returns A new Variable instance
|
|
173
|
+
*/
|
|
174
|
+
export declare const variable: (name?: string | symbol) => Variable;
|
package/src/deep6/env.js
CHANGED
|
@@ -13,7 +13,7 @@ const collectSymbols = object => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const ensure = (object, depth) => {
|
|
16
|
-
while (object[keyDepth] > depth) object =
|
|
16
|
+
while (object[keyDepth] > depth) object = Object.getPrototypeOf(object);
|
|
17
17
|
if (object[keyDepth] < depth) {
|
|
18
18
|
object = Object.create(object);
|
|
19
19
|
object[keyDepth] = depth;
|
|
@@ -90,14 +90,14 @@ class Env {
|
|
|
90
90
|
}
|
|
91
91
|
// helpers
|
|
92
92
|
isBound(name) {
|
|
93
|
-
return name in
|
|
93
|
+
return name in this.values;
|
|
94
94
|
}
|
|
95
95
|
isAlias(name1, name2) {
|
|
96
|
-
const u =
|
|
96
|
+
const u = this.variables[name2];
|
|
97
97
|
return u && u[name1] === 1;
|
|
98
98
|
}
|
|
99
99
|
get(name) {
|
|
100
|
-
return
|
|
100
|
+
return this.values[name];
|
|
101
101
|
}
|
|
102
102
|
// debugging
|
|
103
103
|
getAllValues() {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Type definitions for deep6
|
|
2
|
+
// Generated from src/index.js
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for deep equality comparison
|
|
6
|
+
*/
|
|
7
|
+
export interface EqualOptions {
|
|
8
|
+
/** Handle circular references (default: true) */
|
|
9
|
+
circular?: boolean;
|
|
10
|
+
/** Include symbol properties (default: false) */
|
|
11
|
+
symbols?: boolean;
|
|
12
|
+
/** Use loose equality for primitives (default: false) */
|
|
13
|
+
loose?: boolean;
|
|
14
|
+
/** Ignore function properties (default: false) */
|
|
15
|
+
ignoreFunctions?: boolean;
|
|
16
|
+
/** Distinguish +0 from -0 (default: false) */
|
|
17
|
+
signedZero?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Options for pattern matching
|
|
22
|
+
*/
|
|
23
|
+
export interface MatchOptions {
|
|
24
|
+
/** Allow extra keys on target objects (default: true) */
|
|
25
|
+
openObjects?: boolean;
|
|
26
|
+
/** Allow extra entries in target Maps (default: true) */
|
|
27
|
+
openMaps?: boolean;
|
|
28
|
+
/** Allow extra entries in target Sets (default: true) */
|
|
29
|
+
openSets?: boolean;
|
|
30
|
+
/** Allow extra elements in target arrays (default: false) */
|
|
31
|
+
openArrays?: boolean;
|
|
32
|
+
/** Handle circular references (default: true) */
|
|
33
|
+
circular?: boolean;
|
|
34
|
+
/** Include symbol properties (default: false) */
|
|
35
|
+
symbols?: boolean;
|
|
36
|
+
/** Use loose equality for primitives (default: false) */
|
|
37
|
+
loose?: boolean;
|
|
38
|
+
/** Ignore function properties (default: false) */
|
|
39
|
+
ignoreFunctions?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Options for deep cloning via the main API
|
|
44
|
+
*/
|
|
45
|
+
export interface CloneOptions {
|
|
46
|
+
/** Handle circular references (default: true) */
|
|
47
|
+
circular?: boolean;
|
|
48
|
+
/** Clone symbol properties (default: false) */
|
|
49
|
+
symbols?: boolean;
|
|
50
|
+
/** Clone non-enumerable properties (default: false) */
|
|
51
|
+
allProps?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Deep equality check using unification
|
|
56
|
+
* @param a - First value
|
|
57
|
+
* @param b - Second value
|
|
58
|
+
* @param options - Comparison options
|
|
59
|
+
* @returns True if values are deeply equal
|
|
60
|
+
*/
|
|
61
|
+
export declare const equal: (a: unknown, b: unknown, options?: EqualOptions) => boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Deep clone of a value
|
|
65
|
+
* @param a - Value to clone
|
|
66
|
+
* @param options - Cloning options
|
|
67
|
+
* @returns Deep copy of the value
|
|
68
|
+
*/
|
|
69
|
+
export declare const clone: <T>(a: T, options?: CloneOptions) => T;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Pattern matching with wildcards
|
|
73
|
+
* @param object - Value to test
|
|
74
|
+
* @param pattern - Pattern to match against
|
|
75
|
+
* @param options - Matching options
|
|
76
|
+
* @returns True if object matches the pattern
|
|
77
|
+
*/
|
|
78
|
+
export declare const match: (object: unknown, pattern: unknown, options?: MatchOptions) => boolean;
|
|
79
|
+
|
|
80
|
+
/** Alias for `match` */
|
|
81
|
+
export declare const isShape: typeof match;
|
|
82
|
+
|
|
83
|
+
export {any, _} from './env.js';
|
|
84
|
+
|
|
85
|
+
/** Default export — deep equality function */
|
|
86
|
+
export default equal;
|
package/src/deep6/index.js
CHANGED
|
@@ -7,13 +7,16 @@ const defaultOptions = {circular: true};
|
|
|
7
7
|
const equal = (a, b, options = defaultOptions) => !!unify(a, b, null, options);
|
|
8
8
|
|
|
9
9
|
const defaultMatchOptions = {openObjects: true, openMaps: true, openSets: true, circular: true};
|
|
10
|
-
const match = (object, pattern, options = defaultMatchOptions) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const match = (object, pattern, options = defaultMatchOptions) => {
|
|
11
|
+
const processedPattern = preprocess(pattern, options),
|
|
12
|
+
unifyOptions = {
|
|
13
|
+
circular: options.circular,
|
|
14
|
+
symbols: options.symbols,
|
|
15
|
+
loose: options.loose,
|
|
16
|
+
ignoreFunctions: options.ignoreFunctions
|
|
17
|
+
};
|
|
18
|
+
return !!unify(object, processedPattern, null, unifyOptions);
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
const clone = (a, options = defaultOptions) => originalClone(a, null, options);
|
|
19
22
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Type definitions for deep6 assemble
|
|
2
|
+
// Generated from src/traverse/assemble.js
|
|
3
|
+
|
|
4
|
+
import type {Env} from '../env.js';
|
|
5
|
+
import type {WalkContext} from './walk.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options for assembly
|
|
9
|
+
*/
|
|
10
|
+
export interface AssembleOptions {
|
|
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 assembler pairs: [Constructor, handler, ...]
|
|
33
|
+
*
|
|
34
|
+
* Use `registry.push(Type, handler)` to register a custom assembler.
|
|
35
|
+
*/
|
|
36
|
+
export declare const registry: unknown[];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Filter functions for custom assembly processing
|
|
40
|
+
*/
|
|
41
|
+
export declare const filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Replaces variables with their bound values from an environment
|
|
45
|
+
*
|
|
46
|
+
* Creates a new structure only when values differ from the source.
|
|
47
|
+
* Unbound variables are kept as-is.
|
|
48
|
+
*
|
|
49
|
+
* @param source - Value containing variables to resolve
|
|
50
|
+
* @param env - Env with bindings, or options object
|
|
51
|
+
* @param options - Assembly options (when env is provided separately)
|
|
52
|
+
* @returns New value with variables replaced, or original if unchanged
|
|
53
|
+
*/
|
|
54
|
+
export declare const assemble: ((source: unknown, env?: Env | AssembleOptions | null, options?: AssembleOptions) => unknown) & {
|
|
55
|
+
registry: unknown[];
|
|
56
|
+
filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default assemble;
|
|
@@ -52,7 +52,7 @@ function postProcessSeen(context) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
function postProcessMap(context) {
|
|
56
56
|
const stackOut = context.stackOut,
|
|
57
57
|
s = this.s;
|
|
58
58
|
let j = stackOut.length - 1;
|
|
@@ -65,7 +65,7 @@ const postProcessMap = context => {
|
|
|
65
65
|
} else {
|
|
66
66
|
replaceObject(j, s, stackOut);
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
|
|
70
70
|
function postProcessMapSeen(context) {
|
|
71
71
|
const stackOut = context.stackOut,
|
|
@@ -108,6 +108,7 @@ const registry = [
|
|
|
108
108
|
|
|
109
109
|
const addType = (Type, process) => registry.push(Type, process || processOther);
|
|
110
110
|
|
|
111
|
+
typeof URL == 'function' && addType(URL);
|
|
111
112
|
typeof Int8Array == 'function' && addType(Int8Array);
|
|
112
113
|
typeof Uint8Array == 'function' && addType(Uint8Array);
|
|
113
114
|
typeof Uint8ClampedArray == 'function' && addType(Uint8ClampedArray);
|
|
@@ -154,5 +155,5 @@ const assemble = (source, env, options) => {
|
|
|
154
155
|
assemble.registry = registry;
|
|
155
156
|
assemble.filters = filters;
|
|
156
157
|
|
|
157
|
-
export {registry, filters};
|
|
158
|
+
export {registry, filters, assemble};
|
|
158
159
|
export default assemble;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Type definitions for deep6 clone
|
|
2
|
+
// Generated from src/traverse/clone.js
|
|
3
|
+
|
|
4
|
+
import type {Env} from '../env.js';
|
|
5
|
+
import type {WalkContext} from './walk.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options for deep cloning
|
|
9
|
+
*/
|
|
10
|
+
export interface CloneOptions {
|
|
11
|
+
/** Handle circular references (default: true in main API) */
|
|
12
|
+
circular?: boolean;
|
|
13
|
+
/** Clone symbol properties (default: false) */
|
|
14
|
+
symbols?: boolean;
|
|
15
|
+
/** Clone 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 — return true to indicate value was handled */
|
|
28
|
+
filters?: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Flat array of type-specific cloner pairs: [Constructor, handler, Constructor, handler, ...]
|
|
33
|
+
*
|
|
34
|
+
* Use `registry.push(Type, handler)` to register a custom type cloner.
|
|
35
|
+
* Handler signature: `(val, context) => void` (push result to context.stackOut)
|
|
36
|
+
*/
|
|
37
|
+
export declare const registry: unknown[];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Filter functions for custom clone processing — return true to indicate value was handled
|
|
41
|
+
*/
|
|
42
|
+
export declare const filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Deep clones a value with circular reference handling
|
|
46
|
+
*
|
|
47
|
+
* @param source - Value to clone
|
|
48
|
+
* @param env - Optional Env for variable resolution, or options object
|
|
49
|
+
* @param options - Cloning options (when env is provided separately)
|
|
50
|
+
* @returns Deep copy of the value
|
|
51
|
+
*/
|
|
52
|
+
export declare const clone: (<T>(source: T, env?: Env | CloneOptions | null, options?: CloneOptions) => T) & {
|
|
53
|
+
registry: unknown[];
|
|
54
|
+
filters: Array<(val: unknown, context: WalkContext) => boolean>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default clone;
|