@rimbu/deep 1.1.0 → 2.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.
Files changed (41) hide show
  1. package/dist/cjs/deep.cjs +197 -576
  2. package/dist/cjs/deep.cjs.map +1 -0
  3. package/dist/cjs/deep.d.cts +284 -0
  4. package/dist/cjs/index.cjs +18 -662
  5. package/dist/cjs/index.cjs.map +1 -0
  6. package/dist/cjs/index.d.cts +18 -0
  7. package/dist/cjs/internal.cjs +8 -582
  8. package/dist/cjs/internal.cjs.map +1 -0
  9. package/dist/cjs/internal.d.cts +7 -0
  10. package/dist/cjs/match.cjs +251 -343
  11. package/dist/cjs/match.cjs.map +1 -0
  12. package/dist/cjs/match.d.cts +140 -0
  13. package/dist/cjs/patch.cjs +121 -93
  14. package/dist/cjs/patch.cjs.map +1 -0
  15. package/dist/cjs/patch.d.cts +89 -0
  16. package/dist/cjs/path.cjs +114 -573
  17. package/dist/cjs/path.cjs.map +1 -0
  18. package/dist/cjs/path.d.cts +196 -0
  19. package/dist/cjs/protected.cjs +2 -17
  20. package/dist/cjs/protected.cjs.map +1 -0
  21. package/dist/cjs/selector.cjs +33 -574
  22. package/dist/cjs/selector.cjs.map +1 -0
  23. package/dist/cjs/selector.d.cts +47 -0
  24. package/dist/cjs/tuple.cjs +162 -71
  25. package/dist/cjs/tuple.cjs.map +1 -0
  26. package/dist/esm/match.mjs.map +1 -1
  27. package/dist/esm/patch.mjs.map +1 -1
  28. package/dist/esm/path.mjs.map +1 -1
  29. package/dist/esm/protected.d.mts +17 -0
  30. package/dist/esm/selector.mjs.map +1 -1
  31. package/dist/esm/tuple.d.mts +142 -0
  32. package/package.json +21 -15
  33. /package/dist/{types/protected.d.mts → cjs/protected.d.cts} +0 -0
  34. /package/dist/{types/tuple.d.mts → cjs/tuple.d.cts} +0 -0
  35. /package/dist/{types → esm}/deep.d.mts +0 -0
  36. /package/dist/{types → esm}/index.d.mts +0 -0
  37. /package/dist/{types → esm}/internal.d.mts +0 -0
  38. /package/dist/{types → esm}/match.d.mts +0 -0
  39. /package/dist/{types → esm}/patch.d.mts +0 -0
  40. /package/dist/{types → esm}/path.d.mts +0 -0
  41. /package/dist/{types → esm}/selector.d.mts +0 -0
@@ -1,376 +1,284 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/match.mts
21
- var match_exports = {};
22
- __export(match_exports, {
23
- match: () => match
24
- });
25
- module.exports = __toCommonJS(match_exports);
26
- var import_base = require("@rimbu/base");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.match = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var base_1 = require("@rimbu/base");
6
+ /**
7
+ * Returns true if the given `value` object matches the given `matcher`, false otherwise.
8
+ * @typeparam T - the input value type
9
+ * @typeparam C - utility type
10
+ * @param source - the value to match (should be a plain object)
11
+ * @param matcher - a matcher object or a function taking the matcher API and returning a match object
12
+ * @param failureLog - (optional) a string array that can be passed to collect reasons why the match failed
13
+ * @example
14
+ * ```ts
15
+ * const input = { a: 1, b: { c: true, d: 'a' } }
16
+ * match(input, { a: 1 }) // => true
17
+ * match(input, { a: 2 }) // => false
18
+ * match(input, { a: (v) => v > 10 }) // => false
19
+ * match(input, { b: { c: true }}) // => true
20
+ * match(input, (['every', { a: (v) => v > 0 }, { b: { c: true } }]) // => true
21
+ * match(input, { b: { c: (v, parent, root) => v && parent.d.length > 0 && root.a > 0 } })
22
+ * // => true
23
+ * ```
24
+ */
27
25
  function match(source, matcher, failureLog) {
28
- return matchEntry(source, source, source, matcher, failureLog);
26
+ return matchEntry(source, source, source, matcher, failureLog);
29
27
  }
28
+ exports.match = match;
29
+ /**
30
+ * Match a generic match entry against the given source.
31
+ */
30
32
  function matchEntry(source, parent, root, matcher, failureLog) {
31
- if (Object.is(source, matcher)) {
32
- return true;
33
- }
34
- if (matcher === null || matcher === void 0) {
35
- failureLog?.push(
36
- `value ${JSON.stringify(source)} did not match matcher ${matcher}`
37
- );
38
- return false;
39
- }
40
- if (typeof source === "function") {
41
- const result = Object.is(source, matcher);
42
- if (!result) {
43
- failureLog?.push(
44
- `both value and matcher are functions, but they do not have the same reference`
45
- );
33
+ if (Object.is(source, matcher)) {
34
+ // value and target are exactly the same, always will be true
35
+ return true;
46
36
  }
47
- return result;
48
- }
49
- if (typeof matcher === "function") {
50
- const matcherResult = matcher(source, parent, root);
51
- if (typeof matcherResult === "boolean") {
52
- if (!matcherResult) {
53
- failureLog?.push(
54
- `function matcher returned false for value ${JSON.stringify(source)}`
55
- );
56
- }
57
- return matcherResult;
58
- }
59
- return matchEntry(source, parent, root, matcherResult, failureLog);
60
- }
61
- if ((0, import_base.isPlainObj)(source)) {
62
- return matchPlainObj(source, parent, root, matcher, failureLog);
63
- }
64
- if (Array.isArray(source)) {
65
- return matchArr(source, parent, root, matcher, failureLog);
66
- }
67
- failureLog?.push(
68
- `value ${JSON.stringify(
69
- source
70
- )} does not match given matcher ${JSON.stringify(matcher)}`
71
- );
72
- return false;
73
- }
74
- function matchArr(source, parent, root, matcher, failureLog) {
75
- if (Array.isArray(matcher)) {
76
- const length = source.length;
77
- if (length !== matcher.length) {
78
- failureLog?.push(
79
- `array lengths are not equal: value length ${source.length} !== matcher length ${matcher.length}`
80
- );
81
- return false;
82
- }
83
- let index = -1;
84
- while (++index < length) {
85
- if (!matchEntry(source[index], source, root, matcher[index], failureLog)) {
86
- failureLog?.push(
87
- `index ${index} does not match with value ${JSON.stringify(
88
- source[index]
89
- )} and matcher ${matcher[index]}`
90
- );
37
+ if (matcher === null || matcher === undefined) {
38
+ // these matchers can only be direct matches, and previously it was determined that
39
+ // they are not equal
40
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("value ".concat(JSON.stringify(source), " did not match matcher ").concat(matcher));
91
41
  return false;
92
- }
93
42
  }
94
- return true;
95
- }
96
- if (typeof matcher === "object" && null !== matcher) {
97
- if (`every` in matcher) {
98
- return matchCompound(
99
- source,
100
- parent,
101
- root,
102
- ["every", ...matcher.every],
103
- failureLog
104
- );
105
- }
106
- if (`some` in matcher) {
107
- return matchCompound(
108
- source,
109
- parent,
110
- root,
111
- ["some", ...matcher.some],
112
- failureLog
113
- );
114
- }
115
- if (`none` in matcher) {
116
- return matchCompound(
117
- source,
118
- parent,
119
- root,
120
- ["none", ...matcher.none],
121
- failureLog
122
- );
123
- }
124
- if (`single` in matcher) {
125
- return matchCompound(
126
- source,
127
- parent,
128
- root,
129
- ["single", ...matcher.single],
130
- failureLog
131
- );
43
+ if (typeof source === 'function') {
44
+ // function source values can only be directly matched
45
+ var result = Object.is(source, matcher);
46
+ if (!result) {
47
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("both value and matcher are functions, but they do not have the same reference");
48
+ }
49
+ return result;
132
50
  }
133
- if (`someItem` in matcher) {
134
- return matchTraversal(
135
- source,
136
- root,
137
- "someItem",
138
- matcher.someItem,
139
- failureLog
140
- );
51
+ if (typeof matcher === 'function') {
52
+ // resolve match function first
53
+ var matcherResult = matcher(source, parent, root);
54
+ if (typeof matcherResult === 'boolean') {
55
+ // function resulted in a direct match result
56
+ if (!matcherResult) {
57
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("function matcher returned false for value ".concat(JSON.stringify(source)));
58
+ }
59
+ return matcherResult;
60
+ }
61
+ // function resulted in a value that needs to be further matched
62
+ return matchEntry(source, parent, root, matcherResult, failureLog);
141
63
  }
142
- if (`everyItem` in matcher) {
143
- return matchTraversal(
144
- source,
145
- root,
146
- "everyItem",
147
- matcher.everyItem,
148
- failureLog
149
- );
64
+ if ((0, base_1.isPlainObj)(source)) {
65
+ // source ia a plain object, can be partially matched
66
+ return matchPlainObj(source, parent, root, matcher, failureLog);
150
67
  }
151
- if (`noneItem` in matcher) {
152
- return matchTraversal(
153
- source,
154
- root,
155
- "noneItem",
156
- matcher.noneItem,
157
- failureLog
158
- );
68
+ if (Array.isArray(source)) {
69
+ // source is an array
70
+ return matchArr(source, parent, root, matcher, failureLog);
159
71
  }
160
- if (`singleItem` in matcher) {
161
- return matchTraversal(
162
- source,
163
- root,
164
- "singleItem",
165
- matcher.singleItem,
166
- failureLog
167
- );
72
+ // already determined above that the source and matcher are not equal
73
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("value ".concat(JSON.stringify(source), " does not match given matcher ").concat(JSON.stringify(matcher)));
74
+ return false;
75
+ }
76
+ /**
77
+ * Match an array matcher against the given source.
78
+ */
79
+ function matchArr(source, parent, root, matcher, failureLog) {
80
+ if (Array.isArray(matcher)) {
81
+ // directly compare array contents
82
+ var length = source.length;
83
+ if (length !== matcher.length) {
84
+ // if lengths not equal, arrays are not equal
85
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("array lengths are not equal: value length ".concat(source.length, " !== matcher length ").concat(matcher.length));
86
+ return false;
87
+ }
88
+ // loop over arrays, matching every value
89
+ var index = -1;
90
+ while (++index < length) {
91
+ if (!matchEntry(source[index], source, root, matcher[index], failureLog)) {
92
+ // item did not match, return false
93
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("index ".concat(index, " does not match with value ").concat(JSON.stringify(source[index]), " and matcher ").concat(matcher[index]));
94
+ return false;
95
+ }
96
+ }
97
+ // all items are equal
98
+ return true;
168
99
  }
169
- }
170
- for (const index in matcher) {
171
- const matcherAtIndex = matcher[index];
172
- if (!(index in source)) {
173
- failureLog?.push(
174
- `index ${index} does not exist in source ${JSON.stringify(
175
- source
176
- )} but should match matcher ${JSON.stringify(matcherAtIndex)}`
177
- );
178
- return false;
100
+ // matcher is plain object
101
+ if (typeof matcher === 'object' && null !== matcher) {
102
+ if ("every" in matcher) {
103
+ return matchCompound(source, parent, root, tslib_1.__spreadArray(['every'], tslib_1.__read(matcher.every), false), failureLog);
104
+ }
105
+ if ("some" in matcher) {
106
+ return matchCompound(source, parent, root, tslib_1.__spreadArray(['some'], tslib_1.__read(matcher.some), false), failureLog);
107
+ }
108
+ if ("none" in matcher) {
109
+ return matchCompound(source, parent, root, tslib_1.__spreadArray(['none'], tslib_1.__read(matcher.none), false), failureLog);
110
+ }
111
+ if ("single" in matcher) {
112
+ return matchCompound(source, parent, root, tslib_1.__spreadArray(['single'], tslib_1.__read(matcher.single), false), failureLog);
113
+ }
114
+ if ("someItem" in matcher) {
115
+ return matchTraversal(source, root, 'someItem', matcher.someItem, failureLog);
116
+ }
117
+ if ("everyItem" in matcher) {
118
+ return matchTraversal(source, root, 'everyItem', matcher.everyItem, failureLog);
119
+ }
120
+ if ("noneItem" in matcher) {
121
+ return matchTraversal(source, root, 'noneItem', matcher.noneItem, failureLog);
122
+ }
123
+ if ("singleItem" in matcher) {
124
+ return matchTraversal(source, root, 'singleItem', matcher.singleItem, failureLog);
125
+ }
179
126
  }
180
- const result = matchEntry(
181
- source[index],
182
- source,
183
- root,
184
- matcherAtIndex,
185
- failureLog
186
- );
187
- if (!result) {
188
- failureLog?.push(
189
- `index ${index} does not match with value ${JSON.stringify(
190
- source[index]
191
- )} and matcher ${JSON.stringify(matcherAtIndex)}`
192
- );
193
- return false;
127
+ // matcher is plain object with index keys
128
+ for (var index in matcher) {
129
+ var matcherAtIndex = matcher[index];
130
+ if (!(index in source)) {
131
+ // source does not have item at given index
132
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("index ".concat(index, " does not exist in source ").concat(JSON.stringify(source), " but should match matcher ").concat(JSON.stringify(matcherAtIndex)));
133
+ return false;
134
+ }
135
+ // match the source item at the given index
136
+ var result = matchEntry(source[index], source, root, matcherAtIndex, failureLog);
137
+ if (!result) {
138
+ // item did not match
139
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("index ".concat(index, " does not match with value ").concat(JSON.stringify(source[index]), " and matcher ").concat(JSON.stringify(matcherAtIndex)));
140
+ return false;
141
+ }
194
142
  }
195
- }
196
- return true;
143
+ // all items match
144
+ return true;
197
145
  }
146
+ /**
147
+ * Match an object matcher against the given source.
148
+ */
198
149
  function matchPlainObj(source, parent, root, matcher, failureLog) {
199
- if (Array.isArray(matcher)) {
200
- return matchCompound(source, parent, root, matcher, failureLog);
201
- }
202
- for (const key in matcher) {
203
- if (!(key in source)) {
204
- failureLog?.push(
205
- `key ${key} is specified in matcher but not present in value ${JSON.stringify(
206
- source
207
- )}`
208
- );
209
- return false;
150
+ if (Array.isArray(matcher)) {
151
+ // the matcher is of compound type
152
+ return matchCompound(source, parent, root, matcher, failureLog);
210
153
  }
211
- const result = matchEntry(
212
- source[key],
213
- source,
214
- root,
215
- matcher[key],
216
- failureLog
217
- );
218
- if (!result) {
219
- failureLog?.push(
220
- `key ${key} does not match in value ${JSON.stringify(
221
- source[key]
222
- )} with matcher ${JSON.stringify(matcher[key])}`
223
- );
224
- return false;
154
+ // partial object props matcher
155
+ for (var key in matcher) {
156
+ if (!(key in source)) {
157
+ // the source does not have the given key
158
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("key ".concat(key, " is specified in matcher but not present in value ").concat(JSON.stringify(source)));
159
+ return false;
160
+ }
161
+ // match the source value at the given key with the matcher at given key
162
+ var result = matchEntry(source[key], source, root, matcher[key], failureLog);
163
+ if (!result) {
164
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("key ".concat(key, " does not match in value ").concat(JSON.stringify(source[key]), " with matcher ").concat(JSON.stringify(matcher[key])));
165
+ return false;
166
+ }
225
167
  }
226
- }
227
- return true;
168
+ // all properties match
169
+ return true;
228
170
  }
171
+ /**
172
+ * Match a compound matcher against the given source.
173
+ */
229
174
  function matchCompound(source, parent, root, compound, failureLog) {
230
- const matchType = compound[0];
231
- const length = compound.length;
232
- let index = 0;
233
- switch (matchType) {
234
- case "every": {
235
- while (++index < length) {
236
- const result = matchEntry(
237
- source,
238
- parent,
239
- root,
240
- compound[index],
241
- failureLog
242
- );
243
- if (!result) {
244
- failureLog?.push(
245
- `in compound "every": match at index ${index} failed`
246
- );
247
- return false;
175
+ // first item indicates compound match type
176
+ var matchType = compound[0];
177
+ var length = compound.length;
178
+ // start at index 1
179
+ var index = 0;
180
+ switch (matchType) {
181
+ case 'every': {
182
+ while (++index < length) {
183
+ // if any item does not match, return false
184
+ var result = matchEntry(source, parent, root, compound[index], failureLog);
185
+ if (!result) {
186
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in compound \"every\": match at index ".concat(index, " failed"));
187
+ return false;
188
+ }
189
+ }
190
+ return true;
248
191
  }
249
- }
250
- return true;
251
- }
252
- case "none": {
253
- while (++index < length) {
254
- const result = matchEntry(
255
- source,
256
- parent,
257
- root,
258
- compound[index],
259
- failureLog
260
- );
261
- if (result) {
262
- failureLog?.push(
263
- `in compound "none": match at index ${index} succeeded`
264
- );
265
- return false;
192
+ case 'none': {
193
+ // if any item matches, return false
194
+ while (++index < length) {
195
+ var result = matchEntry(source, parent, root, compound[index], failureLog);
196
+ if (result) {
197
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in compound \"none\": match at index ".concat(index, " succeeded"));
198
+ return false;
199
+ }
200
+ }
201
+ return true;
266
202
  }
267
- }
268
- return true;
269
- }
270
- case "single": {
271
- let onePassed = false;
272
- while (++index < length) {
273
- const result = matchEntry(
274
- source,
275
- parent,
276
- root,
277
- compound[index],
278
- failureLog
279
- );
280
- if (result) {
281
- if (onePassed) {
282
- failureLog?.push(
283
- `in compound "single": multiple matches succeeded`
284
- );
285
- return false;
286
- }
287
- onePassed = true;
203
+ case 'single': {
204
+ // if not exactly one item matches, return false
205
+ var onePassed = false;
206
+ while (++index < length) {
207
+ var result = matchEntry(source, parent, root, compound[index], failureLog);
208
+ if (result) {
209
+ if (onePassed) {
210
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in compound \"single\": multiple matches succeeded");
211
+ return false;
212
+ }
213
+ onePassed = true;
214
+ }
215
+ }
216
+ if (!onePassed) {
217
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in compound \"single\": no matches succeeded");
218
+ }
219
+ return onePassed;
288
220
  }
289
- }
290
- if (!onePassed) {
291
- failureLog?.push(`in compound "single": no matches succeeded`);
292
- }
293
- return onePassed;
294
- }
295
- case "some": {
296
- while (++index < length) {
297
- const result = matchEntry(
298
- source,
299
- parent,
300
- root,
301
- compound[index],
302
- failureLog
303
- );
304
- if (result) {
305
- return true;
221
+ case 'some': {
222
+ // if any item matches, return true
223
+ while (++index < length) {
224
+ var result = matchEntry(source, parent, root, compound[index], failureLog);
225
+ if (result) {
226
+ return true;
227
+ }
228
+ }
229
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in compound \"some\": no matches succeeded");
230
+ return false;
306
231
  }
307
- }
308
- failureLog?.push(`in compound "some": no matches succeeded`);
309
- return false;
310
232
  }
311
- }
312
233
  }
313
234
  function matchTraversal(source, root, matchType, matcher, failureLog) {
314
- let index = -1;
315
- const length = source.length;
316
- switch (matchType) {
317
- case "someItem": {
318
- while (++index < length) {
319
- if (matchEntry(source[index], source, root, matcher, failureLog)) {
320
- return true;
235
+ var index = -1;
236
+ var length = source.length;
237
+ switch (matchType) {
238
+ case 'someItem': {
239
+ while (++index < length) {
240
+ if (matchEntry(source[index], source, root, matcher, failureLog)) {
241
+ return true;
242
+ }
243
+ }
244
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in array traversal \"someItem\": no items matched given matcher");
245
+ return false;
321
246
  }
322
- }
323
- failureLog?.push(
324
- `in array traversal "someItem": no items matched given matcher`
325
- );
326
- return false;
327
- }
328
- case "everyItem": {
329
- while (++index < length) {
330
- if (!matchEntry(source[index], source, root, matcher, failureLog)) {
331
- failureLog?.push(
332
- `in array traversal "everyItem": at least one item did not match given matcher`
333
- );
334
- return false;
247
+ case 'everyItem': {
248
+ while (++index < length) {
249
+ if (!matchEntry(source[index], source, root, matcher, failureLog)) {
250
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in array traversal \"everyItem\": at least one item did not match given matcher");
251
+ return false;
252
+ }
253
+ }
254
+ return true;
335
255
  }
336
- }
337
- return true;
338
- }
339
- case "noneItem": {
340
- while (++index < length) {
341
- if (matchEntry(source[index], source, root, matcher, failureLog)) {
342
- failureLog?.push(
343
- `in array traversal "noneItem": at least one item matched given matcher`
344
- );
345
- return false;
256
+ case 'noneItem': {
257
+ while (++index < length) {
258
+ if (matchEntry(source[index], source, root, matcher, failureLog)) {
259
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in array traversal \"noneItem\": at least one item matched given matcher");
260
+ return false;
261
+ }
262
+ }
263
+ return true;
346
264
  }
347
- }
348
- return true;
349
- }
350
- case "singleItem": {
351
- let singleMatched = false;
352
- while (++index < length) {
353
- if (matchEntry(source[index], source, root, matcher, failureLog)) {
354
- if (singleMatched) {
355
- failureLog?.push(
356
- `in array traversal "singleItem": more than one item matched given matcher`
357
- );
358
- return false;
359
- }
360
- singleMatched = true;
265
+ case 'singleItem': {
266
+ var singleMatched = false;
267
+ while (++index < length) {
268
+ if (matchEntry(source[index], source, root, matcher, failureLog)) {
269
+ if (singleMatched) {
270
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in array traversal \"singleItem\": more than one item matched given matcher");
271
+ return false;
272
+ }
273
+ singleMatched = true;
274
+ }
275
+ }
276
+ if (!singleMatched) {
277
+ failureLog === null || failureLog === void 0 ? void 0 : failureLog.push("in array traversal \"singleItem\": no item matched given matcher");
278
+ return false;
279
+ }
280
+ return true;
361
281
  }
362
- }
363
- if (!singleMatched) {
364
- failureLog?.push(
365
- `in array traversal "singleItem": no item matched given matcher`
366
- );
367
- return false;
368
- }
369
- return true;
370
282
  }
371
- }
372
283
  }
373
- // Annotate the CommonJS export names for ESM import in node:
374
- 0 && (module.exports = {
375
- match
376
- });
284
+ //# sourceMappingURL=match.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.cjs","sourceRoot":"","sources":["../../_cjs_prepare/match.cts"],"names":[],"mappings":";;;;AAAA,oCAMqB;AA0KrB;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,KAAK,CACnB,MAAS,EACT,OAAoB,EACpB,UAA6B;IAE7B,OAAO,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAc,EAAE,UAAU,CAAC,CAAC;AACxE,CAAC;AAND,sBAMC;AAED;;GAEG;AACH,SAAS,UAAU,CACjB,MAAS,EACT,MAAS,EACT,IAAO,EACP,OAAgC,EAChC,UAA6B;IAE7B,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAC/B,6DAA6D;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,mFAAmF;QACnF,qBAAqB;QACrB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,CACd,gBAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,oCAA0B,OAAO,CAAE,CACnE,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,sDAAsD;QACtD,IAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,UAAU,aAAV,UAAU,uBAAV,UAAU,CA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