@ls-stack/utils 3.24.1 → 3.26.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.
Files changed (56) hide show
  1. package/docs/_media/modules.md +1 -0
  2. package/docs/arrayUtils/-internal-.md +1 -1
  3. package/docs/arrayUtils/README.md +12 -12
  4. package/docs/consoleFmt.md +2 -2
  5. package/docs/exhaustiveMatch/-internal-.md +1 -1
  6. package/docs/exhaustiveMatch/README.md +1 -1
  7. package/docs/filterObjectOrArrayKeys.md +82 -0
  8. package/docs/modules.md +1 -0
  9. package/docs/objUtils.md +7 -7
  10. package/docs/parallelAsyncCalls/-internal-.md +3 -3
  11. package/docs/parallelAsyncCalls/README.md +1 -1
  12. package/docs/retryOnError/README.md +1 -1
  13. package/docs/runShellCmd/README.md +9 -9
  14. package/docs/safeJson.md +2 -2
  15. package/docs/saferTyping.md +7 -7
  16. package/docs/stringUtils/README.md +6 -6
  17. package/docs/testUtils.md +40 -6
  18. package/docs/time.md +1 -1
  19. package/docs/tsResult/README.md +17 -11
  20. package/docs/typingFnUtils/-internal-.md +1 -1
  21. package/docs/typingFnUtils/README.md +8 -10
  22. package/lib/arrayUtils.d.cts +6 -1
  23. package/lib/arrayUtils.d.ts +6 -1
  24. package/lib/chunk-FXRZ4RQU.js +257 -0
  25. package/lib/{chunk-JAPKLFIK.js → chunk-QLD7KG5I.js} +34 -20
  26. package/lib/filterObjectOrArrayKeys.cjs +292 -0
  27. package/lib/filterObjectOrArrayKeys.d.cts +44 -0
  28. package/lib/filterObjectOrArrayKeys.d.ts +44 -0
  29. package/lib/filterObjectOrArrayKeys.js +7 -0
  30. package/lib/objUtils.d.cts +4 -1
  31. package/lib/objUtils.d.ts +4 -1
  32. package/lib/parallelAsyncCalls.cjs +4 -1
  33. package/lib/parallelAsyncCalls.d.cts +4 -1
  34. package/lib/parallelAsyncCalls.d.ts +4 -1
  35. package/lib/parallelAsyncCalls.js +4 -1
  36. package/lib/retryOnError.d.cts +2 -0
  37. package/lib/retryOnError.d.ts +2 -0
  38. package/lib/runShellCmd.d.cts +17 -0
  39. package/lib/runShellCmd.d.ts +17 -0
  40. package/lib/safeJson.d.cts +8 -2
  41. package/lib/safeJson.d.ts +8 -2
  42. package/lib/saferTyping.d.cts +3 -0
  43. package/lib/saferTyping.d.ts +3 -0
  44. package/lib/stringUtils.d.cts +1 -0
  45. package/lib/stringUtils.d.ts +1 -0
  46. package/lib/testUtils.cjs +290 -144
  47. package/lib/testUtils.d.cts +40 -12
  48. package/lib/testUtils.d.ts +40 -12
  49. package/lib/testUtils.js +10 -125
  50. package/lib/tsResult.d.cts +31 -7
  51. package/lib/tsResult.d.ts +31 -7
  52. package/lib/typingFnUtils.d.cts +20 -6
  53. package/lib/typingFnUtils.d.ts +20 -6
  54. package/lib/yamlStringify.cjs +34 -20
  55. package/lib/yamlStringify.js +1 -1
  56. package/package.json +5 -1
@@ -18,12 +18,12 @@ function yamlStringify(obj, {
18
18
  addRootObjSpaces = "beforeAndAfter"
19
19
  } = {}) {
20
20
  if (isObject(obj) || Array.isArray(obj) || typeof obj === "function") {
21
- return `${stringifyValue(obj, "", maxLineLength, !!showUndefined, maxDepth, 0, collapseObjects, addRootObjSpaces)}
21
+ return `${stringifyValue(obj, "", maxLineLength, !!showUndefined, maxDepth, 0, collapseObjects, addRootObjSpaces, false)}
22
22
  `;
23
23
  }
24
24
  return JSON.stringify(obj) || "undefined";
25
25
  }
26
- function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, depth, collapseObjects, addObjSpaces) {
26
+ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, depth, collapseObjects, addObjSpaces, isArrayItem) {
27
27
  let result = "";
28
28
  const childIndent = `${indent} `;
29
29
  if (isPlainObject(value)) {
@@ -42,7 +42,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
42
42
  return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
43
43
  }
44
44
  );
45
- if (isSimpleObject && entries.length > 0) {
45
+ const shouldCollapse = isArrayItem ? entries.length > 1 : entries.length > 0;
46
+ if (isSimpleObject && shouldCollapse) {
46
47
  let line = "{ ";
47
48
  line += entries.map(([key, val]) => {
48
49
  let valueStr;
@@ -89,20 +90,29 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
89
90
  maxDepth,
90
91
  depth + 1,
91
92
  collapseObjects,
92
- addObjSpaces
93
+ addObjSpaces,
94
+ false
93
95
  );
94
- const willBeCollapsed = isObject(objVal) && (Object.keys(objVal).length === 0 || collapseObjects && depth + 1 > 0 && Object.entries(objVal).filter(([, val]) => val !== void 0 || showUndefined).every(([, val]) => {
95
- if (typeof val === "string") {
96
- return !val.includes("'") && !val.includes('"') && !val.includes("\\");
97
- }
98
- return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
99
- }));
100
- const prevWasCollapsed = prevValue && isObject(prevValue) && (Object.keys(prevValue).length === 0 || collapseObjects && depth + 1 > 0 && Object.entries(prevValue).filter(([, val]) => val !== void 0 || showUndefined).every(([, val]) => {
101
- if (typeof val === "string") {
102
- return !val.includes("'") && !val.includes('"') && !val.includes("\\");
103
- }
104
- return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
105
- }));
96
+ const willBeCollapsed = isObject(objVal) && (Object.keys(objVal).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
97
+ const filteredEntries = Object.entries(objVal).filter(([, val]) => val !== void 0 || showUndefined);
98
+ const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
99
+ return shouldCollapseThis && filteredEntries.every(([, val]) => {
100
+ if (typeof val === "string") {
101
+ return !val.includes("'") && !val.includes('"') && !val.includes("\\");
102
+ }
103
+ return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
104
+ });
105
+ })());
106
+ const prevWasCollapsed = prevValue && isObject(prevValue) && (Object.keys(prevValue).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
107
+ const filteredEntries = Object.entries(prevValue).filter(([, val]) => val !== void 0 || showUndefined);
108
+ const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
109
+ return shouldCollapseThis && filteredEntries.every(([, val]) => {
110
+ if (typeof val === "string") {
111
+ return !val.includes("'") && !val.includes('"') && !val.includes("\\");
112
+ }
113
+ return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
114
+ });
115
+ })());
106
116
  if (!afterSpaceWasAdded && indent === "" && isObject(objVal) && !willBeCollapsed && prevValue && !prevWasCollapsed && (addObjSpaces === "before" || addObjSpaces === "beforeAndAfter")) {
107
117
  result += "\n";
108
118
  }
@@ -165,7 +175,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
165
175
  maxDepth,
166
176
  depth + 1,
167
177
  collapseObjects,
168
- addObjSpaces
178
+ addObjSpaces,
179
+ true
169
180
  );
170
181
  }).join(", ");
171
182
  line += "]";
@@ -189,7 +200,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
189
200
  maxDepth,
190
201
  depth + 1,
191
202
  collapseObjects,
192
- addObjSpaces
203
+ addObjSpaces,
204
+ true
193
205
  );
194
206
  arrayString = arrayString.trimStart();
195
207
  result += arrayString;
@@ -202,7 +214,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
202
214
  maxDepth,
203
215
  depth + 1,
204
216
  collapseObjects,
205
- addObjSpaces
217
+ addObjSpaces,
218
+ true
206
219
  );
207
220
  }
208
221
  result += "\n";
@@ -256,7 +269,8 @@ ${indent}${line}
256
269
  maxDepth,
257
270
  depth + 1,
258
271
  collapseObjects,
259
- addObjSpaces
272
+ addObjSpaces,
273
+ false
260
274
  );
261
275
  }
262
276
  return JSON.stringify(value);
@@ -0,0 +1,292 @@
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/filterObjectOrArrayKeys.ts
21
+ var filterObjectOrArrayKeys_exports = {};
22
+ __export(filterObjectOrArrayKeys_exports, {
23
+ filterObjectOrArrayKeys: () => filterObjectOrArrayKeys
24
+ });
25
+ module.exports = __toCommonJS(filterObjectOrArrayKeys_exports);
26
+
27
+ // src/typeGuards.ts
28
+ function isPlainObject(value) {
29
+ if (!value || typeof value !== "object") return false;
30
+ const proto = Object.getPrototypeOf(value);
31
+ if (proto === null) {
32
+ return true;
33
+ }
34
+ const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
35
+ if (Ctor === Object) return true;
36
+ const objectCtorString = Object.prototype.constructor.toString();
37
+ return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString;
38
+ }
39
+
40
+ // src/filterObjectOrArrayKeys.ts
41
+ function filterObjectOrArrayKeys(objOrArray, {
42
+ filterKeys,
43
+ rejectKeys,
44
+ rejectEmptyObjectsInArray = true
45
+ }) {
46
+ const toArray = (v) => v === void 0 ? [] : Array.isArray(v) ? v : [v];
47
+ const filterPatternsRaw = toArray(filterKeys);
48
+ const rejectPatternsRaw = toArray(rejectKeys);
49
+ const hasFilters = filterPatternsRaw.length > 0;
50
+ const hasRejects = rejectPatternsRaw.length > 0;
51
+ const filterPatterns = filterPatternsRaw.map(parsePattern);
52
+ const rejectPatterns = rejectPatternsRaw.map(parsePattern);
53
+ function matchPath(path, pattern) {
54
+ function rec(pi, pti) {
55
+ if (pti >= pattern.length) return pi === path.length;
56
+ const pt = pattern[pti];
57
+ if (pt.type === "WILDCARD_ANY") {
58
+ if (rec(pi, pti + 1)) return true;
59
+ if (pi < path.length) return rec(pi + 1, pti);
60
+ return false;
61
+ }
62
+ if (pt.type === "WILDCARD_ONE") {
63
+ let j = pi;
64
+ let sawKey = false;
65
+ while (j < path.length) {
66
+ if (path[j].type === "KEY") sawKey = true;
67
+ if (sawKey && rec(j, pti + 1)) return true;
68
+ j += 1;
69
+ }
70
+ return false;
71
+ }
72
+ if (pi >= path.length) return false;
73
+ const ct = path[pi];
74
+ switch (pt.type) {
75
+ case "KEY":
76
+ if (ct.type === "KEY" && ct.name === pt.name)
77
+ return rec(pi + 1, pti + 1);
78
+ if (ct.type === "INDEX") return rec(pi + 1, pti);
79
+ return false;
80
+ case "MULTI_KEY":
81
+ if (ct.type === "KEY" && pt.names.includes(ct.name))
82
+ return rec(pi + 1, pti + 1);
83
+ if (ct.type === "INDEX") return rec(pi + 1, pti);
84
+ return false;
85
+ case "INDEX":
86
+ if (ct.type === "INDEX" && ct.index === pt.index)
87
+ return rec(pi + 1, pti + 1);
88
+ return false;
89
+ case "INDEX_ANY":
90
+ if (ct.type === "INDEX") return rec(pi + 1, pti + 1);
91
+ return false;
92
+ case "INDEX_RANGE":
93
+ if (ct.type === "INDEX") {
94
+ const okLower = ct.index >= pt.start;
95
+ const okUpper = pt.end === null ? true : ct.index <= pt.end;
96
+ if (okLower && okUpper) return rec(pi + 1, pti + 1);
97
+ }
98
+ return false;
99
+ }
100
+ }
101
+ return rec(0, 0);
102
+ }
103
+ const matchesAnyFilter = (path) => filterPatterns.some((p) => matchPath(path, p));
104
+ const matchesAnyReject = (path) => rejectPatterns.some((p) => matchPath(path, p));
105
+ const build = (value, path, allowedByFilter, stack2, isRoot, parentIsArray) => {
106
+ if (Array.isArray(value)) {
107
+ if (stack2.has(value)) {
108
+ throw new TypeError("Circular references are not supported");
109
+ }
110
+ stack2.add(value);
111
+ const out = [];
112
+ const includeAllChildren = allowedByFilter || !hasFilters;
113
+ for (let index = 0; index < value.length; index += 1) {
114
+ const childPath = path.concat({ type: "INDEX", index });
115
+ if (hasRejects && matchesAnyReject(childPath)) continue;
116
+ const child = value[index];
117
+ const directInclude = hasFilters ? matchesAnyFilter(childPath) : true;
118
+ const childAllowed = includeAllChildren || directInclude;
119
+ if (isPlainObject(child) || Array.isArray(child)) {
120
+ const builtChild = build(
121
+ child,
122
+ childPath,
123
+ childAllowed,
124
+ stack2,
125
+ false,
126
+ true
127
+ );
128
+ if (builtChild !== void 0) {
129
+ out.push(builtChild);
130
+ }
131
+ } else {
132
+ if (childAllowed) {
133
+ out.push(child);
134
+ }
135
+ }
136
+ }
137
+ stack2.delete(value);
138
+ const filteredOut = rejectEmptyObjectsInArray ? out.filter(
139
+ (item) => !(isPlainObject(item) && Object.keys(item).length === 0)
140
+ ) : out;
141
+ if (filteredOut.length === 0 && !allowedByFilter && !isRoot)
142
+ return void 0;
143
+ return filteredOut;
144
+ }
145
+ if (isPlainObject(value)) {
146
+ if (stack2.has(value)) {
147
+ throw new TypeError("Circular references are not supported");
148
+ }
149
+ stack2.add(value);
150
+ const result = {};
151
+ const includeAllChildren = allowedByFilter || !hasFilters;
152
+ for (const key of Object.keys(value)) {
153
+ const childPath = path.concat({ type: "KEY", name: key });
154
+ if (hasRejects && matchesAnyReject(childPath)) continue;
155
+ const val = value[key];
156
+ const directInclude = hasFilters ? matchesAnyFilter(childPath) : true;
157
+ const childAllowed = includeAllChildren || directInclude;
158
+ if (isPlainObject(val) || Array.isArray(val)) {
159
+ const builtChild = build(
160
+ val,
161
+ childPath,
162
+ childAllowed,
163
+ stack2,
164
+ false,
165
+ false
166
+ );
167
+ if (builtChild === void 0) {
168
+ continue;
169
+ }
170
+ if (Array.isArray(builtChild) && builtChild.length === 0 && !childAllowed) {
171
+ continue;
172
+ }
173
+ if (isPlainObject(builtChild) && Object.keys(builtChild).length === 0 && !childAllowed) {
174
+ continue;
175
+ }
176
+ result[key] = builtChild;
177
+ } else {
178
+ if (childAllowed) {
179
+ result[key] = val;
180
+ }
181
+ }
182
+ }
183
+ stack2.delete(value);
184
+ if (Object.keys(result).length === 0 && !allowedByFilter && !isRoot) {
185
+ if (parentIsArray && !rejectEmptyObjectsInArray) {
186
+ return {};
187
+ }
188
+ return void 0;
189
+ }
190
+ return result;
191
+ }
192
+ return allowedByFilter || !hasFilters ? value : void 0;
193
+ };
194
+ const startPath = [];
195
+ const initialAllowed = !hasFilters;
196
+ const stack = /* @__PURE__ */ new WeakSet();
197
+ const built = build(
198
+ objOrArray,
199
+ startPath,
200
+ initialAllowed,
201
+ stack,
202
+ true,
203
+ false
204
+ );
205
+ if (built === void 0) return Array.isArray(objOrArray) ? [] : {};
206
+ return built;
207
+ }
208
+ function parsePattern(pattern) {
209
+ const tokens = [];
210
+ let i = 0;
211
+ const n = pattern.length;
212
+ const pushKey = (name) => {
213
+ if (name.length === 0) return;
214
+ tokens.push({ type: "KEY", name });
215
+ };
216
+ while (i < n) {
217
+ const ch = pattern[i];
218
+ if (ch === ".") {
219
+ i += 1;
220
+ continue;
221
+ }
222
+ if (ch === "[") {
223
+ const end = pattern.indexOf("]", i + 1);
224
+ const inside = end === -1 ? pattern.slice(i + 1) : pattern.slice(i + 1, end);
225
+ if (inside === "*") {
226
+ tokens.push({ type: "INDEX_ANY" });
227
+ } else if (inside.includes("-")) {
228
+ const parts = inside.split("-");
229
+ const startStr = parts[0] ?? "";
230
+ const endStr = parts[1] ?? "";
231
+ const start = parseInt(startStr, 10);
232
+ const endNum = endStr === "*" ? null : parseInt(endStr, 10);
233
+ tokens.push({
234
+ type: "INDEX_RANGE",
235
+ start,
236
+ end: endNum === null || Number.isFinite(endNum) ? endNum : null
237
+ });
238
+ } else if (inside.length > 0) {
239
+ const idx = parseInt(inside, 10);
240
+ tokens.push({ type: "INDEX", index: idx });
241
+ }
242
+ i = end === -1 ? n : end + 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.includes("|") && inside.trim().length > 0) {
249
+ const names = inside.split("|").filter((name) => name.length > 0);
250
+ if (names.length > 0) {
251
+ tokens.push({ type: "MULTI_KEY", names });
252
+ }
253
+ }
254
+ i = end === -1 ? n : end + 1;
255
+ continue;
256
+ }
257
+ if (ch === "*") {
258
+ if (pattern[i + 1] === "*") {
259
+ tokens.push({ type: "WILDCARD_ANY" });
260
+ i += 2;
261
+ let j2 = i;
262
+ while (j2 < n) {
263
+ const c = pattern[j2];
264
+ if (c === "." || c === "[") break;
265
+ j2 += 1;
266
+ }
267
+ if (j2 > i) {
268
+ pushKey(pattern.slice(i, j2));
269
+ i = j2;
270
+ }
271
+ continue;
272
+ } else {
273
+ tokens.push({ type: "WILDCARD_ONE" });
274
+ i += 1;
275
+ continue;
276
+ }
277
+ }
278
+ let j = i;
279
+ while (j < n) {
280
+ const c = pattern[j];
281
+ if (c === "." || c === "[") break;
282
+ j += 1;
283
+ }
284
+ pushKey(pattern.slice(i, j));
285
+ i = j;
286
+ }
287
+ return tokens;
288
+ }
289
+ // Annotate the CommonJS export names for ESM import in node:
290
+ 0 && (module.exports = {
291
+ filterObjectOrArrayKeys
292
+ });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Filters the keys of an object based on the provided patterns.
3
+ *
4
+ * Filtering patterns in `rejectKeys` and `filterKeys`:
5
+ * - `'prop'` - Only root-level properties named 'prop'
6
+ * - `'**prop'` - Any property named exactly 'prop' at any level (root or nested)
7
+ * - `'*.prop'` - Any nested property named 'prop' at second level (excludes root-level matches)
8
+ * - `'test.*.prop'` - Any property named 'prop' at second level of 'test'
9
+ * - `'test.*.test.**prop'` - Any property named 'prop' inside of 'test.*.test'
10
+ * - `'prop.nested'` - Exact nested property paths like `obj.prop.nested`
11
+ * - `'prop.**nested'` - All nested properties inside root `prop` with name `nested`
12
+ * - `'prop[0]'` - The first item of the `prop` array
13
+ * - `'prop[*]'` - All items of the `prop` array
14
+ * - `'prop[0].nested'` - `nested` prop of the first item of the `prop` array
15
+ * - `'prop[*].nested'` - `nested` prop of all items of the `prop` array
16
+ * - `'prop[*]**nested'` - all `nested` props of all items of the `prop` array
17
+ * - `'prop[0-2]'` - The first three items of the `prop` array
18
+ * - `'prop[4-*]'` - All items of the `prop` array from the fourth index to the end
19
+ * - `'prop[0-2].nested.**prop'` - Combining multiple nested patterns is supported
20
+ * - Root array:
21
+ * - `'[0]'` - The first item of the root array
22
+ * - `'[*]'` - All items of the array
23
+ * - `'[0].nested'` - `nested` prop of the first item of the array
24
+ * - `'[*].nested'` - `nested` prop of all items of the array
25
+ * - `'[*]**nested'` - all `nested` props of all items of the array
26
+ * - `'[0-2]'` - The first three items of the array
27
+ * - `'[4-*]'` - All items of the array from the fourth index to the end
28
+ * - Selecting multiple properties:
29
+ * - `'prop.test.(prop1|prop2|prop3)'` - The `prop1`, `prop2`, and `prop3` properties of `prop.test` object
30
+ *
31
+ * @param objOrArray - The object or array to filter.
32
+ * @param options - The options for the filter.
33
+ * @param options.filterKeys - The keys to filter.
34
+ * @param options.rejectKeys - The keys to reject.
35
+ * @param options.rejectEmptyObjectsInArray - Whether to reject empty objects in arrays (default: true).
36
+ * @returns The filtered object or array.
37
+ */
38
+ declare function filterObjectOrArrayKeys(objOrArray: Record<string, any> | Record<string, any>[], { filterKeys, rejectKeys, rejectEmptyObjectsInArray, }: {
39
+ filterKeys?: string[] | string;
40
+ rejectKeys?: string[] | string;
41
+ rejectEmptyObjectsInArray?: boolean;
42
+ }): Record<string, any> | Record<string, any>[];
43
+
44
+ export { filterObjectOrArrayKeys };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Filters the keys of an object based on the provided patterns.
3
+ *
4
+ * Filtering patterns in `rejectKeys` and `filterKeys`:
5
+ * - `'prop'` - Only root-level properties named 'prop'
6
+ * - `'**prop'` - Any property named exactly 'prop' at any level (root or nested)
7
+ * - `'*.prop'` - Any nested property named 'prop' at second level (excludes root-level matches)
8
+ * - `'test.*.prop'` - Any property named 'prop' at second level of 'test'
9
+ * - `'test.*.test.**prop'` - Any property named 'prop' inside of 'test.*.test'
10
+ * - `'prop.nested'` - Exact nested property paths like `obj.prop.nested`
11
+ * - `'prop.**nested'` - All nested properties inside root `prop` with name `nested`
12
+ * - `'prop[0]'` - The first item of the `prop` array
13
+ * - `'prop[*]'` - All items of the `prop` array
14
+ * - `'prop[0].nested'` - `nested` prop of the first item of the `prop` array
15
+ * - `'prop[*].nested'` - `nested` prop of all items of the `prop` array
16
+ * - `'prop[*]**nested'` - all `nested` props of all items of the `prop` array
17
+ * - `'prop[0-2]'` - The first three items of the `prop` array
18
+ * - `'prop[4-*]'` - All items of the `prop` array from the fourth index to the end
19
+ * - `'prop[0-2].nested.**prop'` - Combining multiple nested patterns is supported
20
+ * - Root array:
21
+ * - `'[0]'` - The first item of the root array
22
+ * - `'[*]'` - All items of the array
23
+ * - `'[0].nested'` - `nested` prop of the first item of the array
24
+ * - `'[*].nested'` - `nested` prop of all items of the array
25
+ * - `'[*]**nested'` - all `nested` props of all items of the array
26
+ * - `'[0-2]'` - The first three items of the array
27
+ * - `'[4-*]'` - All items of the array from the fourth index to the end
28
+ * - Selecting multiple properties:
29
+ * - `'prop.test.(prop1|prop2|prop3)'` - The `prop1`, `prop2`, and `prop3` properties of `prop.test` object
30
+ *
31
+ * @param objOrArray - The object or array to filter.
32
+ * @param options - The options for the filter.
33
+ * @param options.filterKeys - The keys to filter.
34
+ * @param options.rejectKeys - The keys to reject.
35
+ * @param options.rejectEmptyObjectsInArray - Whether to reject empty objects in arrays (default: true).
36
+ * @returns The filtered object or array.
37
+ */
38
+ declare function filterObjectOrArrayKeys(objOrArray: Record<string, any> | Record<string, any>[], { filterKeys, rejectKeys, rejectEmptyObjectsInArray, }: {
39
+ filterKeys?: string[] | string;
40
+ rejectKeys?: string[] | string;
41
+ rejectEmptyObjectsInArray?: boolean;
42
+ }): Record<string, any> | Record<string, any>[];
43
+
44
+ export { filterObjectOrArrayKeys };
@@ -0,0 +1,7 @@
1
+ import {
2
+ filterObjectOrArrayKeys
3
+ } from "./chunk-FXRZ4RQU.js";
4
+ import "./chunk-JF2MDHOJ.js";
5
+ export {
6
+ filterObjectOrArrayKeys
7
+ };
@@ -1,4 +1,7 @@
1
- /** @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead */
1
+ /**
2
+ * @param obj
3
+ * @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead
4
+ */
2
5
  declare function objectTypedEntries<T extends Record<string, unknown>>(obj: T): [Extract<keyof T, string>, T[keyof T]][];
3
6
  declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
4
7
  declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (item: T, index: number) => [K, O]): Record<K, O>;
package/lib/objUtils.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- /** @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead */
1
+ /**
2
+ * @param obj
3
+ * @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead
4
+ */
2
5
  declare function objectTypedEntries<T extends Record<string, unknown>>(obj: T): [Extract<keyof T, string>, T[keyof T]][];
3
6
  declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
4
7
  declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (item: T, index: number) => [K, O]): Record<K, O>;
@@ -55,7 +55,10 @@ var ParallelAsyncResultCalls = class {
55
55
  );
56
56
  return this;
57
57
  }
58
- /** adds calls return tuples with inferred results */
58
+ /**
59
+ * adds calls return tuples with inferred results
60
+ * @param calls
61
+ */
59
62
  addTuple(...calls) {
60
63
  for (const call of calls) {
61
64
  this.pendingCalls.push(
@@ -37,7 +37,10 @@ declare class ParallelAsyncResultCalls<M extends ValidMetadata | undefined = und
37
37
  metadata: M;
38
38
  fn: () => Promise<Result<R>>;
39
39
  }): this;
40
- /** adds calls return tuples with inferred results */
40
+ /**
41
+ * adds calls return tuples with inferred results
42
+ * @param calls
43
+ */
41
44
  addTuple<T extends (M extends undefined ? () => Promise<Result<R>> : {
42
45
  metadata: M;
43
46
  fn: () => Promise<Result<R>>;
@@ -37,7 +37,10 @@ declare class ParallelAsyncResultCalls<M extends ValidMetadata | undefined = und
37
37
  metadata: M;
38
38
  fn: () => Promise<Result<R>>;
39
39
  }): this;
40
- /** adds calls return tuples with inferred results */
40
+ /**
41
+ * adds calls return tuples with inferred results
42
+ * @param calls
43
+ */
41
44
  addTuple<T extends (M extends undefined ? () => Promise<Result<R>> : {
42
45
  metadata: M;
43
46
  fn: () => Promise<Result<R>>;
@@ -20,7 +20,10 @@ var ParallelAsyncResultCalls = class {
20
20
  );
21
21
  return this;
22
22
  }
23
- /** adds calls return tuples with inferred results */
23
+ /**
24
+ * adds calls return tuples with inferred results
25
+ * @param calls
26
+ */
24
27
  addTuple(...calls) {
25
28
  for (const call of calls) {
26
29
  this.pendingCalls.push(
@@ -18,6 +18,8 @@ type RetryOptions = {
18
18
  * @param fn - Function to retry that receives context with retry count
19
19
  * @param maxRetries - Maximum number of retries
20
20
  * @param options - Configuration options
21
+ * @param retry
22
+ * @param originalMaxRetries
21
23
  * @returns Promise resolving to the function result or rejecting with the final error
22
24
  *
23
25
  * @example
@@ -18,6 +18,8 @@ type RetryOptions = {
18
18
  * @param fn - Function to retry that receives context with retry count
19
19
  * @param maxRetries - Maximum number of retries
20
20
  * @param options - Configuration options
21
+ * @param retry
22
+ * @param originalMaxRetries
21
23
  * @returns Promise resolving to the function result or rejecting with the final error
22
24
  *
23
25
  * @example
@@ -13,6 +13,14 @@ type RunCmdOptions = {
13
13
  noCiColorForce?: boolean;
14
14
  };
15
15
  /**
16
+ * @param label
17
+ * @param command
18
+ * @param root0
19
+ * @param root0.mock
20
+ * @param root0.silent
21
+ * @param root0.throwOnError
22
+ * @param root0.cwd
23
+ * @param root0.noCiColorForce
16
24
  * @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
17
25
  * ```
18
26
  * // Old (deprecated)
@@ -24,6 +32,9 @@ type RunCmdOptions = {
24
32
  */
25
33
  declare function runCmd(label: string | null, command: string | string[], { mock, silent, throwOnError, cwd, noCiColorForce, }?: RunCmdOptions): Promise<CmdResult>;
26
34
  /**
35
+ * @param label
36
+ * @param cmd
37
+ * @param onResult
27
38
  * @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
28
39
  * ```
29
40
  * // Old (deprecated)
@@ -35,6 +46,10 @@ declare function runCmd(label: string | null, command: string | string[], { mock
35
46
  */
36
47
  declare function concurrentCmd(label: string, cmd: string | string[], onResult: (result: CmdResult) => void): Promise<() => void>;
37
48
  /**
49
+ * @param label
50
+ * @param command
51
+ * @param root0
52
+ * @param root0.silent
38
53
  * @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
39
54
  * ```
40
55
  * // Old (deprecated)
@@ -48,6 +63,7 @@ declare function runCmdUnwrap(label: string | null, command: string | string[],
48
63
  silent?: boolean | 'timeOnly';
49
64
  }): Promise<string>;
50
65
  /**
66
+ * @param command
51
67
  * @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
52
68
  * ```
53
69
  * // Old (deprecated)
@@ -59,6 +75,7 @@ declare function runCmdUnwrap(label: string | null, command: string | string[],
59
75
  */
60
76
  declare function runCmdSilent(command: string | string[]): Promise<CmdResult>;
61
77
  /**
78
+ * @param command
62
79
  * @deprecated This utility has been moved to @ls-stack/node-utils. Please update your imports:
63
80
  * ```
64
81
  * // Old (deprecated)