@ls-stack/utils 3.25.0 → 3.26.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.
@@ -14,7 +14,7 @@
14
14
  function filterObjectOrArrayKeys(objOrArray, options): Record<string, any> | Record<string, any>[];
15
15
  ```
16
16
 
17
- Defined in: [packages/utils/src/filterObjectOrArrayKeys.ts:38](https://github.com/lucasols/utils/blob/main/packages/utils/src/filterObjectOrArrayKeys.ts#L38)
17
+ Defined in: [packages/utils/src/filterObjectOrArrayKeys.ts:42](https://github.com/lucasols/utils/blob/main/packages/utils/src/filterObjectOrArrayKeys.ts#L42)
18
18
 
19
19
  Filters the keys of an object based on the provided patterns.
20
20
 
@@ -42,6 +42,10 @@ Filtering patterns in `rejectKeys` and `filterKeys`:
42
42
  - `'[*]**nested'` - all `nested` props of all items of the array
43
43
  - `'[0-2]'` - The first three items of the array
44
44
  - `'[4-*]'` - All items of the array from the fourth index to the end
45
+ - Pattern expansion with parentheses:
46
+ - `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3`
47
+ - `'components[*].(table_id|columns|filters[*].value)'` - Expands to `components[*].table_id`, `components[*].columns`, and `components[*].filters[*].value`
48
+ - `'(users|admins)[*].name'` - Expands to `users[*].name` and `admins[*].name`
45
49
 
46
50
  #### Parameters
47
51
 
package/docs/testUtils.md CHANGED
@@ -14,7 +14,7 @@
14
14
  function compactSnapshot(value, options): string;
15
15
  ```
16
16
 
17
- Defined in: [packages/utils/src/testUtils.ts:352](https://github.com/lucasols/utils/blob/main/packages/utils/src/testUtils.ts#L352)
17
+ Defined in: [packages/utils/src/testUtils.ts:354](https://github.com/lucasols/utils/blob/main/packages/utils/src/testUtils.ts#L354)
18
18
 
19
19
  Produces a more compact and readable snapshot of a value using yaml.
20
20
  By default booleans are shown as `✅` and `❌`, use `showBooleansAs` to disable/configure this.
@@ -43,6 +43,8 @@ Filtering patterns in `rejectKeys` and `filterKeys`:
43
43
  - `'[*]**nested'` - all `nested` props of all items of the array
44
44
  - `'[0-2]'` - The first three items of the array
45
45
  - `'[4-*]'` - All items of the array from the fourth index to the end
46
+ - Expanding the patterns with parentheses:
47
+ - `'prop.test.(prop1|prop2|prop3.prop4)'` - Will produce `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3.prop4`
46
48
 
47
49
  #### Parameters
48
50
 
@@ -13,77 +13,10 @@ function filterObjectOrArrayKeys(objOrArray, {
13
13
  const rejectPatternsRaw = toArray(rejectKeys);
14
14
  const hasFilters = filterPatternsRaw.length > 0;
15
15
  const hasRejects = rejectPatternsRaw.length > 0;
16
- function parsePattern(pattern) {
17
- const tokens = [];
18
- let i = 0;
19
- const n = pattern.length;
20
- const pushKey = (name) => {
21
- if (name.length === 0) return;
22
- tokens.push({ type: "KEY", name });
23
- };
24
- while (i < n) {
25
- const ch = pattern[i];
26
- if (ch === ".") {
27
- i += 1;
28
- continue;
29
- }
30
- if (ch === "[") {
31
- const end = pattern.indexOf("]", i + 1);
32
- const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
33
- if (inside === "*") {
34
- tokens.push({ type: "INDEX_ANY" });
35
- } else if (inside.includes("-")) {
36
- const parts = inside.split("-");
37
- const startStr = parts[0] ?? "";
38
- const endStr = parts[1] ?? "";
39
- const start = parseInt(startStr, 10);
40
- const endNum = endStr === "*" ? null : parseInt(endStr, 10);
41
- tokens.push({
42
- type: "INDEX_RANGE",
43
- start,
44
- end: endNum === null || Number.isFinite(endNum) ? endNum : null
45
- });
46
- } else if (inside.length > 0) {
47
- const idx = parseInt(inside, 10);
48
- tokens.push({ type: "INDEX", index: idx });
49
- }
50
- i = end === -1 ? n : end + 1;
51
- continue;
52
- }
53
- if (ch === "*") {
54
- if (pattern[i + 1] === "*") {
55
- tokens.push({ type: "WILDCARD_ANY" });
56
- i += 2;
57
- let j2 = i;
58
- while (j2 < n) {
59
- const c = pattern[j2];
60
- if (c === "." || c === "[") break;
61
- j2 += 1;
62
- }
63
- if (j2 > i) {
64
- pushKey(pattern.slice(i, j2));
65
- i = j2;
66
- }
67
- continue;
68
- } else {
69
- tokens.push({ type: "WILDCARD_ONE" });
70
- i += 1;
71
- continue;
72
- }
73
- }
74
- let j = i;
75
- while (j < n) {
76
- const c = pattern[j];
77
- if (c === "." || c === "[") break;
78
- j += 1;
79
- }
80
- pushKey(pattern.slice(i, j));
81
- i = j;
82
- }
83
- return tokens;
84
- }
85
- const filterPatterns = filterPatternsRaw.map(parsePattern);
86
- const rejectPatterns = rejectPatternsRaw.map(parsePattern);
16
+ const expandedFilterPatterns = filterPatternsRaw.flatMap(expandPatterns);
17
+ const expandedRejectPatterns = rejectPatternsRaw.flatMap(expandPatterns);
18
+ const filterPatterns = expandedFilterPatterns.map(parsePattern);
19
+ const rejectPatterns = expandedRejectPatterns.map(parsePattern);
87
20
  function matchPath(path, pattern) {
88
21
  function rec(pi, pti) {
89
22
  if (pti >= pattern.length) return pi === path.length;
@@ -234,6 +167,101 @@ function filterObjectOrArrayKeys(objOrArray, {
234
167
  if (built === void 0) return Array.isArray(objOrArray) ? [] : {};
235
168
  return built;
236
169
  }
170
+ function expandPatterns(pattern) {
171
+ function expandSingle(str) {
172
+ const start = str.indexOf("(");
173
+ if (start === -1) {
174
+ return [str];
175
+ }
176
+ const end = str.indexOf(")", start);
177
+ if (end === -1) {
178
+ return [str];
179
+ }
180
+ const before = str.slice(0, start);
181
+ const inside = str.slice(start + 1, end);
182
+ const after = str.slice(end + 1);
183
+ if (!inside.includes("|")) {
184
+ return expandSingle(before + inside + after);
185
+ }
186
+ const options = inside.split("|").filter((option) => option.trim().length > 0);
187
+ const results = [];
188
+ for (const option of options) {
189
+ const newStr = before + option + after;
190
+ results.push(...expandSingle(newStr));
191
+ }
192
+ return results;
193
+ }
194
+ return expandSingle(pattern);
195
+ }
196
+ function parsePattern(pattern) {
197
+ const tokens = [];
198
+ let i = 0;
199
+ const n = pattern.length;
200
+ const pushKey = (name) => {
201
+ if (name.length === 0) return;
202
+ tokens.push({ type: "KEY", name });
203
+ };
204
+ while (i < n) {
205
+ const ch = pattern[i];
206
+ if (ch === ".") {
207
+ i += 1;
208
+ continue;
209
+ }
210
+ if (ch === "[") {
211
+ const end = pattern.indexOf("]", i + 1);
212
+ const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
213
+ if (inside === "*") {
214
+ tokens.push({ type: "INDEX_ANY" });
215
+ } else if (inside.includes("-")) {
216
+ const parts = inside.split("-");
217
+ const startStr = parts[0] ?? "";
218
+ const endStr = parts[1] ?? "";
219
+ const start = parseInt(startStr, 10);
220
+ const endNum = endStr === "*" ? null : parseInt(endStr, 10);
221
+ tokens.push({
222
+ type: "INDEX_RANGE",
223
+ start,
224
+ end: endNum === null || Number.isFinite(endNum) ? endNum : null
225
+ });
226
+ } else if (inside.length > 0) {
227
+ const idx = parseInt(inside, 10);
228
+ tokens.push({ type: "INDEX", index: idx });
229
+ }
230
+ i = end === -1 ? n : end + 1;
231
+ continue;
232
+ }
233
+ if (ch === "*") {
234
+ if (pattern[i + 1] === "*") {
235
+ tokens.push({ type: "WILDCARD_ANY" });
236
+ i += 2;
237
+ let j2 = i;
238
+ while (j2 < n) {
239
+ const c = pattern[j2];
240
+ if (c === "." || c === "[") break;
241
+ j2 += 1;
242
+ }
243
+ if (j2 > i) {
244
+ pushKey(pattern.slice(i, j2));
245
+ i = j2;
246
+ }
247
+ continue;
248
+ } else {
249
+ tokens.push({ type: "WILDCARD_ONE" });
250
+ i += 1;
251
+ continue;
252
+ }
253
+ }
254
+ let j = i;
255
+ while (j < n) {
256
+ const c = pattern[j];
257
+ if (c === "." || c === "[") break;
258
+ j += 1;
259
+ }
260
+ pushKey(pattern.slice(i, j));
261
+ i = j;
262
+ }
263
+ return tokens;
264
+ }
237
265
 
238
266
  export {
239
267
  filterObjectOrArrayKeys
@@ -48,77 +48,10 @@ function filterObjectOrArrayKeys(objOrArray, {
48
48
  const rejectPatternsRaw = toArray(rejectKeys);
49
49
  const hasFilters = filterPatternsRaw.length > 0;
50
50
  const hasRejects = rejectPatternsRaw.length > 0;
51
- function parsePattern(pattern) {
52
- const tokens = [];
53
- let i = 0;
54
- const n = pattern.length;
55
- const pushKey = (name) => {
56
- if (name.length === 0) return;
57
- tokens.push({ type: "KEY", name });
58
- };
59
- while (i < n) {
60
- const ch = pattern[i];
61
- if (ch === ".") {
62
- i += 1;
63
- continue;
64
- }
65
- if (ch === "[") {
66
- const end = pattern.indexOf("]", i + 1);
67
- const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
68
- if (inside === "*") {
69
- tokens.push({ type: "INDEX_ANY" });
70
- } else if (inside.includes("-")) {
71
- const parts = inside.split("-");
72
- const startStr = parts[0] ?? "";
73
- const endStr = parts[1] ?? "";
74
- const start = parseInt(startStr, 10);
75
- const endNum = endStr === "*" ? null : parseInt(endStr, 10);
76
- tokens.push({
77
- type: "INDEX_RANGE",
78
- start,
79
- end: endNum === null || Number.isFinite(endNum) ? endNum : null
80
- });
81
- } else if (inside.length > 0) {
82
- const idx = parseInt(inside, 10);
83
- tokens.push({ type: "INDEX", index: idx });
84
- }
85
- i = end === -1 ? n : end + 1;
86
- continue;
87
- }
88
- if (ch === "*") {
89
- if (pattern[i + 1] === "*") {
90
- tokens.push({ type: "WILDCARD_ANY" });
91
- i += 2;
92
- let j2 = i;
93
- while (j2 < n) {
94
- const c = pattern[j2];
95
- if (c === "." || c === "[") break;
96
- j2 += 1;
97
- }
98
- if (j2 > i) {
99
- pushKey(pattern.slice(i, j2));
100
- i = j2;
101
- }
102
- continue;
103
- } else {
104
- tokens.push({ type: "WILDCARD_ONE" });
105
- i += 1;
106
- continue;
107
- }
108
- }
109
- let j = i;
110
- while (j < n) {
111
- const c = pattern[j];
112
- if (c === "." || c === "[") break;
113
- j += 1;
114
- }
115
- pushKey(pattern.slice(i, j));
116
- i = j;
117
- }
118
- return tokens;
119
- }
120
- const filterPatterns = filterPatternsRaw.map(parsePattern);
121
- const rejectPatterns = rejectPatternsRaw.map(parsePattern);
51
+ const expandedFilterPatterns = filterPatternsRaw.flatMap(expandPatterns);
52
+ const expandedRejectPatterns = rejectPatternsRaw.flatMap(expandPatterns);
53
+ const filterPatterns = expandedFilterPatterns.map(parsePattern);
54
+ const rejectPatterns = expandedRejectPatterns.map(parsePattern);
122
55
  function matchPath(path, pattern) {
123
56
  function rec(pi, pti) {
124
57
  if (pti >= pattern.length) return pi === path.length;
@@ -269,6 +202,101 @@ function filterObjectOrArrayKeys(objOrArray, {
269
202
  if (built === void 0) return Array.isArray(objOrArray) ? [] : {};
270
203
  return built;
271
204
  }
205
+ function expandPatterns(pattern) {
206
+ function expandSingle(str) {
207
+ const start = str.indexOf("(");
208
+ if (start === -1) {
209
+ return [str];
210
+ }
211
+ const end = str.indexOf(")", start);
212
+ if (end === -1) {
213
+ return [str];
214
+ }
215
+ const before = str.slice(0, start);
216
+ const inside = str.slice(start + 1, end);
217
+ const after = str.slice(end + 1);
218
+ if (!inside.includes("|")) {
219
+ return expandSingle(before + inside + after);
220
+ }
221
+ const options = inside.split("|").filter((option) => option.trim().length > 0);
222
+ const results = [];
223
+ for (const option of options) {
224
+ const newStr = before + option + after;
225
+ results.push(...expandSingle(newStr));
226
+ }
227
+ return results;
228
+ }
229
+ return expandSingle(pattern);
230
+ }
231
+ function parsePattern(pattern) {
232
+ const tokens = [];
233
+ let i = 0;
234
+ const n = pattern.length;
235
+ const pushKey = (name) => {
236
+ if (name.length === 0) return;
237
+ tokens.push({ type: "KEY", name });
238
+ };
239
+ while (i < n) {
240
+ const ch = pattern[i];
241
+ if (ch === ".") {
242
+ i += 1;
243
+ continue;
244
+ }
245
+ if (ch === "[") {
246
+ const end = pattern.indexOf("]", i + 1);
247
+ const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
248
+ if (inside === "*") {
249
+ tokens.push({ type: "INDEX_ANY" });
250
+ } else if (inside.includes("-")) {
251
+ const parts = inside.split("-");
252
+ const startStr = parts[0] ?? "";
253
+ const endStr = parts[1] ?? "";
254
+ const start = parseInt(startStr, 10);
255
+ const endNum = endStr === "*" ? null : parseInt(endStr, 10);
256
+ tokens.push({
257
+ type: "INDEX_RANGE",
258
+ start,
259
+ end: endNum === null || Number.isFinite(endNum) ? endNum : null
260
+ });
261
+ } else if (inside.length > 0) {
262
+ const idx = parseInt(inside, 10);
263
+ tokens.push({ type: "INDEX", index: idx });
264
+ }
265
+ i = end === -1 ? n : end + 1;
266
+ continue;
267
+ }
268
+ if (ch === "*") {
269
+ if (pattern[i + 1] === "*") {
270
+ tokens.push({ type: "WILDCARD_ANY" });
271
+ i += 2;
272
+ let j2 = i;
273
+ while (j2 < n) {
274
+ const c = pattern[j2];
275
+ if (c === "." || c === "[") break;
276
+ j2 += 1;
277
+ }
278
+ if (j2 > i) {
279
+ pushKey(pattern.slice(i, j2));
280
+ i = j2;
281
+ }
282
+ continue;
283
+ } else {
284
+ tokens.push({ type: "WILDCARD_ONE" });
285
+ i += 1;
286
+ continue;
287
+ }
288
+ }
289
+ let j = i;
290
+ while (j < n) {
291
+ const c = pattern[j];
292
+ if (c === "." || c === "[") break;
293
+ j += 1;
294
+ }
295
+ pushKey(pattern.slice(i, j));
296
+ i = j;
297
+ }
298
+ return tokens;
299
+ }
272
300
  // Annotate the CommonJS export names for ESM import in node:
273
301
  0 && (module.exports = {
274
302
  filterObjectOrArrayKeys
@@ -25,6 +25,10 @@
25
25
  * - `'[*]**nested'` - all `nested` props of all items of the array
26
26
  * - `'[0-2]'` - The first three items of the array
27
27
  * - `'[4-*]'` - All items of the array from the fourth index to the end
28
+ * - Pattern expansion with parentheses:
29
+ * - `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3`
30
+ * - `'components[*].(table_id|columns|filters[*].value)'` - Expands to `components[*].table_id`, `components[*].columns`, and `components[*].filters[*].value`
31
+ * - `'(users|admins)[*].name'` - Expands to `users[*].name` and `admins[*].name`
28
32
  *
29
33
  * @param objOrArray - The object or array to filter.
30
34
  * @param options - The options for the filter.
@@ -25,6 +25,10 @@
25
25
  * - `'[*]**nested'` - all `nested` props of all items of the array
26
26
  * - `'[0-2]'` - The first three items of the array
27
27
  * - `'[4-*]'` - All items of the array from the fourth index to the end
28
+ * - Pattern expansion with parentheses:
29
+ * - `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3`
30
+ * - `'components[*].(table_id|columns|filters[*].value)'` - Expands to `components[*].table_id`, `components[*].columns`, and `components[*].filters[*].value`
31
+ * - `'(users|admins)[*].name'` - Expands to `users[*].name` and `admins[*].name`
28
32
  *
29
33
  * @param objOrArray - The object or array to filter.
30
34
  * @param options - The options for the filter.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  filterObjectOrArrayKeys
3
- } from "./chunk-XXYTMSFH.js";
3
+ } from "./chunk-2WZGT4NA.js";
4
4
  import "./chunk-JF2MDHOJ.js";
5
5
  export {
6
6
  filterObjectOrArrayKeys
package/lib/testUtils.cjs CHANGED
@@ -142,77 +142,10 @@ function filterObjectOrArrayKeys(objOrArray, {
142
142
  const rejectPatternsRaw = toArray(rejectKeys);
143
143
  const hasFilters = filterPatternsRaw.length > 0;
144
144
  const hasRejects = rejectPatternsRaw.length > 0;
145
- function parsePattern(pattern) {
146
- const tokens = [];
147
- let i = 0;
148
- const n = pattern.length;
149
- const pushKey = (name) => {
150
- if (name.length === 0) return;
151
- tokens.push({ type: "KEY", name });
152
- };
153
- while (i < n) {
154
- const ch = pattern[i];
155
- if (ch === ".") {
156
- i += 1;
157
- continue;
158
- }
159
- if (ch === "[") {
160
- const end = pattern.indexOf("]", i + 1);
161
- const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
162
- if (inside === "*") {
163
- tokens.push({ type: "INDEX_ANY" });
164
- } else if (inside.includes("-")) {
165
- const parts = inside.split("-");
166
- const startStr = parts[0] ?? "";
167
- const endStr = parts[1] ?? "";
168
- const start = parseInt(startStr, 10);
169
- const endNum = endStr === "*" ? null : parseInt(endStr, 10);
170
- tokens.push({
171
- type: "INDEX_RANGE",
172
- start,
173
- end: endNum === null || Number.isFinite(endNum) ? endNum : null
174
- });
175
- } else if (inside.length > 0) {
176
- const idx = parseInt(inside, 10);
177
- tokens.push({ type: "INDEX", index: idx });
178
- }
179
- i = end === -1 ? n : end + 1;
180
- continue;
181
- }
182
- if (ch === "*") {
183
- if (pattern[i + 1] === "*") {
184
- tokens.push({ type: "WILDCARD_ANY" });
185
- i += 2;
186
- let j2 = i;
187
- while (j2 < n) {
188
- const c = pattern[j2];
189
- if (c === "." || c === "[") break;
190
- j2 += 1;
191
- }
192
- if (j2 > i) {
193
- pushKey(pattern.slice(i, j2));
194
- i = j2;
195
- }
196
- continue;
197
- } else {
198
- tokens.push({ type: "WILDCARD_ONE" });
199
- i += 1;
200
- continue;
201
- }
202
- }
203
- let j = i;
204
- while (j < n) {
205
- const c = pattern[j];
206
- if (c === "." || c === "[") break;
207
- j += 1;
208
- }
209
- pushKey(pattern.slice(i, j));
210
- i = j;
211
- }
212
- return tokens;
213
- }
214
- const filterPatterns = filterPatternsRaw.map(parsePattern);
215
- const rejectPatterns = rejectPatternsRaw.map(parsePattern);
145
+ const expandedFilterPatterns = filterPatternsRaw.flatMap(expandPatterns);
146
+ const expandedRejectPatterns = rejectPatternsRaw.flatMap(expandPatterns);
147
+ const filterPatterns = expandedFilterPatterns.map(parsePattern);
148
+ const rejectPatterns = expandedRejectPatterns.map(parsePattern);
216
149
  function matchPath(path, pattern) {
217
150
  function rec(pi, pti) {
218
151
  if (pti >= pattern.length) return pi === path.length;
@@ -363,6 +296,101 @@ function filterObjectOrArrayKeys(objOrArray, {
363
296
  if (built === void 0) return Array.isArray(objOrArray) ? [] : {};
364
297
  return built;
365
298
  }
299
+ function expandPatterns(pattern) {
300
+ function expandSingle(str) {
301
+ const start = str.indexOf("(");
302
+ if (start === -1) {
303
+ return [str];
304
+ }
305
+ const end = str.indexOf(")", start);
306
+ if (end === -1) {
307
+ return [str];
308
+ }
309
+ const before = str.slice(0, start);
310
+ const inside = str.slice(start + 1, end);
311
+ const after = str.slice(end + 1);
312
+ if (!inside.includes("|")) {
313
+ return expandSingle(before + inside + after);
314
+ }
315
+ const options = inside.split("|").filter((option) => option.trim().length > 0);
316
+ const results = [];
317
+ for (const option of options) {
318
+ const newStr = before + option + after;
319
+ results.push(...expandSingle(newStr));
320
+ }
321
+ return results;
322
+ }
323
+ return expandSingle(pattern);
324
+ }
325
+ function parsePattern(pattern) {
326
+ const tokens = [];
327
+ let i = 0;
328
+ const n = pattern.length;
329
+ const pushKey = (name) => {
330
+ if (name.length === 0) return;
331
+ tokens.push({ type: "KEY", name });
332
+ };
333
+ while (i < n) {
334
+ const ch = pattern[i];
335
+ if (ch === ".") {
336
+ i += 1;
337
+ continue;
338
+ }
339
+ if (ch === "[") {
340
+ const end = pattern.indexOf("]", i + 1);
341
+ const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
342
+ if (inside === "*") {
343
+ tokens.push({ type: "INDEX_ANY" });
344
+ } else if (inside.includes("-")) {
345
+ const parts = inside.split("-");
346
+ const startStr = parts[0] ?? "";
347
+ const endStr = parts[1] ?? "";
348
+ const start = parseInt(startStr, 10);
349
+ const endNum = endStr === "*" ? null : parseInt(endStr, 10);
350
+ tokens.push({
351
+ type: "INDEX_RANGE",
352
+ start,
353
+ end: endNum === null || Number.isFinite(endNum) ? endNum : null
354
+ });
355
+ } else if (inside.length > 0) {
356
+ const idx = parseInt(inside, 10);
357
+ tokens.push({ type: "INDEX", index: idx });
358
+ }
359
+ i = end === -1 ? n : end + 1;
360
+ continue;
361
+ }
362
+ if (ch === "*") {
363
+ if (pattern[i + 1] === "*") {
364
+ tokens.push({ type: "WILDCARD_ANY" });
365
+ i += 2;
366
+ let j2 = i;
367
+ while (j2 < n) {
368
+ const c = pattern[j2];
369
+ if (c === "." || c === "[") break;
370
+ j2 += 1;
371
+ }
372
+ if (j2 > i) {
373
+ pushKey(pattern.slice(i, j2));
374
+ i = j2;
375
+ }
376
+ continue;
377
+ } else {
378
+ tokens.push({ type: "WILDCARD_ONE" });
379
+ i += 1;
380
+ continue;
381
+ }
382
+ }
383
+ let j = i;
384
+ while (j < n) {
385
+ const c = pattern[j];
386
+ if (c === "." || c === "[") break;
387
+ j += 1;
388
+ }
389
+ pushKey(pattern.slice(i, j));
390
+ i = j;
391
+ }
392
+ return tokens;
393
+ }
366
394
 
367
395
  // src/mathUtils.ts
368
396
  function clampMin(value, min) {
@@ -69,6 +69,8 @@ declare function waitController(): {
69
69
  * - `'[*]**nested'` - all `nested` props of all items of the array
70
70
  * - `'[0-2]'` - The first three items of the array
71
71
  * - `'[4-*]'` - All items of the array from the fourth index to the end
72
+ * - Expanding the patterns with parentheses:
73
+ * - `'prop.test.(prop1|prop2|prop3.prop4)'` - Will produce `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3.prop4`
72
74
  *
73
75
  * @param value - The value to snapshot.
74
76
  * @param options - The options for the snapshot.
@@ -69,6 +69,8 @@ declare function waitController(): {
69
69
  * - `'[*]**nested'` - all `nested` props of all items of the array
70
70
  * - `'[0-2]'` - The first three items of the array
71
71
  * - `'[4-*]'` - All items of the array from the fourth index to the end
72
+ * - Expanding the patterns with parentheses:
73
+ * - `'prop.test.(prop1|prop2|prop3.prop4)'` - Will produce `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3.prop4`
72
74
  *
73
75
  * @param value - The value to snapshot.
74
76
  * @param options - The options for the snapshot.
package/lib/testUtils.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-JQFUKJU5.js";
12
12
  import {
13
13
  filterObjectOrArrayKeys
14
- } from "./chunk-XXYTMSFH.js";
14
+ } from "./chunk-2WZGT4NA.js";
15
15
  import {
16
16
  defer
17
17
  } from "./chunk-DFXNVEH6.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Universal TypeScript utilities for browser and Node.js",
4
- "version": "3.25.0",
4
+ "version": "3.26.1",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "lib",