@ls-stack/utils 3.24.1 → 3.25.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 +80 -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-JAPKLFIK.js → chunk-QLD7KG5I.js} +34 -20
  25. package/lib/chunk-XXYTMSFH.js +240 -0
  26. package/lib/filterObjectOrArrayKeys.cjs +275 -0
  27. package/lib/filterObjectOrArrayKeys.d.cts +42 -0
  28. package/lib/filterObjectOrArrayKeys.d.ts +42 -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 +273 -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
package/lib/testUtils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  yamlStringify
3
- } from "./chunk-JAPKLFIK.js";
3
+ } from "./chunk-QLD7KG5I.js";
4
4
  import {
5
5
  omit,
6
6
  pick
@@ -9,6 +9,9 @@ import "./chunk-IATIXMCE.js";
9
9
  import {
10
10
  deepEqual
11
11
  } from "./chunk-JQFUKJU5.js";
12
+ import {
13
+ filterObjectOrArrayKeys
14
+ } from "./chunk-XXYTMSFH.js";
12
15
  import {
13
16
  defer
14
17
  } from "./chunk-DFXNVEH6.js";
@@ -253,126 +256,6 @@ function waitController() {
253
256
  }
254
257
  };
255
258
  }
256
- function matchesKeyPattern(fullPath, key, pattern, currentPath) {
257
- if (fullPath === pattern) {
258
- return true;
259
- }
260
- if (pattern.startsWith("*.")) {
261
- const propName = pattern.slice(2);
262
- return currentPath !== "" && key === propName;
263
- }
264
- if (pattern.startsWith("*") && !pattern.startsWith("*.")) {
265
- const propName = pattern.slice(1);
266
- return key === propName;
267
- }
268
- if (!pattern.includes("*")) {
269
- return currentPath === "" && key === pattern;
270
- }
271
- return false;
272
- }
273
- function isParentOfPattern(path, pattern) {
274
- if (pattern.includes("*")) {
275
- const patternParts = pattern.split(".");
276
- const pathParts = path.split(".");
277
- if (pathParts.length >= patternParts.length) {
278
- return false;
279
- }
280
- for (let i = 0; i < pathParts.length; i++) {
281
- const pathPart = pathParts[i];
282
- const patternPart = patternParts[i];
283
- if (patternPart === "*") {
284
- continue;
285
- }
286
- if (pathPart !== patternPart) {
287
- return false;
288
- }
289
- }
290
- return true;
291
- } else {
292
- return pattern.startsWith(`${path}.`);
293
- }
294
- }
295
- function applyKeyFiltering(value, { rejectKeys, filterKeys }, currentPath = "", visited = /* @__PURE__ */ new Set()) {
296
- if (!isPlainObject(value) && !Array.isArray(value)) {
297
- return value;
298
- }
299
- if (Array.isArray(value)) {
300
- if (visited.has(value)) {
301
- throw new Error(
302
- "Circular reference detected in array during key filtering"
303
- );
304
- }
305
- visited.add(value);
306
- try {
307
- return value.map(
308
- (item, index) => applyKeyFiltering(
309
- item,
310
- { rejectKeys, filterKeys },
311
- currentPath ? `${currentPath}[${index}]` : `[${index}]`,
312
- visited
313
- )
314
- );
315
- } finally {
316
- visited.delete(value);
317
- }
318
- }
319
- if (isPlainObject(value)) {
320
- if (visited.has(value)) {
321
- throw new Error(
322
- "Circular reference detected in object during key filtering"
323
- );
324
- }
325
- visited.add(value);
326
- try {
327
- const result = {};
328
- for (const [key, itemValue] of Object.entries(value)) {
329
- const fullPath = currentPath ? `${currentPath}.${key}` : key;
330
- if (rejectKeys?.some(
331
- (rejectPath) => matchesKeyPattern(fullPath, key, rejectPath, currentPath)
332
- )) {
333
- continue;
334
- }
335
- if (filterKeys) {
336
- const exactMatch = filterKeys.some(
337
- (filterPath) => matchesKeyPattern(fullPath, key, filterPath, currentPath)
338
- );
339
- const isParent = filterKeys.some(
340
- (filterPath) => isParentOfPattern(fullPath, filterPath)
341
- );
342
- if (!exactMatch && !isParent) {
343
- continue;
344
- }
345
- if (exactMatch) {
346
- result[key] = applyKeyFiltering(
347
- itemValue,
348
- { rejectKeys },
349
- fullPath,
350
- visited
351
- );
352
- } else {
353
- result[key] = applyKeyFiltering(
354
- itemValue,
355
- { rejectKeys, filterKeys },
356
- fullPath,
357
- visited
358
- );
359
- }
360
- } else {
361
- result[key] = applyKeyFiltering(
362
- itemValue,
363
- { rejectKeys, filterKeys },
364
- fullPath,
365
- visited
366
- );
367
- }
368
- }
369
- return result;
370
- } finally {
371
- visited.delete(value);
372
- }
373
- }
374
- return value;
375
- }
376
259
  function compactSnapshot(value, {
377
260
  collapseObjects = true,
378
261
  maxLineLength = 100,
@@ -384,10 +267,12 @@ function compactSnapshot(value, {
384
267
  } = {}) {
385
268
  let processedValue = value;
386
269
  if (rejectKeys || filterKeys) {
387
- processedValue = applyKeyFiltering(processedValue, {
388
- rejectKeys: Array.isArray(rejectKeys) ? rejectKeys : rejectKeys ? [rejectKeys] : void 0,
389
- filterKeys: Array.isArray(filterKeys) ? filterKeys : filterKeys ? [filterKeys] : void 0
390
- });
270
+ if (isPlainObject(processedValue) || Array.isArray(processedValue)) {
271
+ processedValue = filterObjectOrArrayKeys(processedValue, {
272
+ rejectKeys,
273
+ filterKeys
274
+ });
275
+ }
391
276
  }
392
277
  processedValue = showBooleansAs ? replaceBooleansWithEmoji(processedValue, showBooleansAs) : processedValue;
393
278
  return `
@@ -36,12 +36,21 @@ type ResultMethods<T, E extends ResultValidErrors> = {
36
36
  type ResultMethodsKeys = keyof ResultMethods<any, any>;
37
37
  /** @deprecated Use `t-result` library instead. */
38
38
  declare function ok(): Ok<void>;
39
- /** @deprecated Use `t-result` library instead. */
39
+ /**
40
+ * @param value
41
+ * @deprecated Use `t-result` library instead.
42
+ */
40
43
  declare function ok<T>(value: T): Ok<T>;
41
- /** @deprecated Use `t-result` library instead. */
44
+ /**
45
+ * @param error
46
+ * @deprecated Use `t-result` library instead.
47
+ */
42
48
  declare function err<E extends ResultValidErrors>(error: E): Err<E>;
43
49
  declare function unknownToResultError(error: unknown): Err<Error>;
44
- /** Unwraps a promise result */
50
+ /**
51
+ * Unwraps a promise result
52
+ * @param result
53
+ */
45
54
  declare function asyncUnwrap<T>(result: Promise<Result<T, ResultValidErrors>>): Promise<T>;
46
55
  declare function asyncMap<T, E extends ResultValidErrors>(resultPromise: Promise<Result<T, E>>): {
47
56
  err: <NewError extends ResultValidErrors>(mapFn: (error: E) => NewError) => Promise<Result<T, NewError>>;
@@ -62,13 +71,28 @@ declare const Result: {
62
71
  asyncMap: typeof asyncMap;
63
72
  getOkErr: typeof getOkErr;
64
73
  };
65
- /** @deprecated Use `t-result` library instead. */
74
+ /**
75
+ * @param fn
76
+ * @param errorNormalizer
77
+ * @deprecated Use `t-result` library instead.
78
+ */
66
79
  declare function resultify<T, E extends ResultValidErrors = Error>(fn: () => T extends Promise<any> ? never : T, errorNormalizer?: (err: unknown) => E): Result<T, E>;
67
- /** @deprecated Use `t-result` library instead. */
80
+ /**
81
+ * @param fn
82
+ * @param errorNormalizer
83
+ * @deprecated Use `t-result` library instead.
84
+ */
68
85
  declare function resultify<T, E extends ResultValidErrors = Error>(fn: () => Promise<T>, errorNormalizer?: (err: unknown) => E): Promise<Result<Awaited<T>, E>>;
69
- /** @deprecated Use `t-result` library instead. */
86
+ /**
87
+ * @param fn
88
+ * @param errorNormalizer
89
+ * @deprecated Use `t-result` library instead.
90
+ */
70
91
  declare function resultify<T, E extends ResultValidErrors = Error>(fn: Promise<T>, errorNormalizer?: (err: unknown) => E): Promise<Result<T, E>>;
71
- /** @deprecated Use `t-result` library instead. */
92
+ /**
93
+ * @param error
94
+ * @deprecated Use `t-result` library instead.
95
+ */
72
96
  declare function unknownToError(error: unknown): Error;
73
97
  /** @deprecated Use `t-result` library instead. */
74
98
  type TypedResult<T, E extends ResultValidErrors = Error> = {
package/lib/tsResult.d.ts CHANGED
@@ -36,12 +36,21 @@ type ResultMethods<T, E extends ResultValidErrors> = {
36
36
  type ResultMethodsKeys = keyof ResultMethods<any, any>;
37
37
  /** @deprecated Use `t-result` library instead. */
38
38
  declare function ok(): Ok<void>;
39
- /** @deprecated Use `t-result` library instead. */
39
+ /**
40
+ * @param value
41
+ * @deprecated Use `t-result` library instead.
42
+ */
40
43
  declare function ok<T>(value: T): Ok<T>;
41
- /** @deprecated Use `t-result` library instead. */
44
+ /**
45
+ * @param error
46
+ * @deprecated Use `t-result` library instead.
47
+ */
42
48
  declare function err<E extends ResultValidErrors>(error: E): Err<E>;
43
49
  declare function unknownToResultError(error: unknown): Err<Error>;
44
- /** Unwraps a promise result */
50
+ /**
51
+ * Unwraps a promise result
52
+ * @param result
53
+ */
45
54
  declare function asyncUnwrap<T>(result: Promise<Result<T, ResultValidErrors>>): Promise<T>;
46
55
  declare function asyncMap<T, E extends ResultValidErrors>(resultPromise: Promise<Result<T, E>>): {
47
56
  err: <NewError extends ResultValidErrors>(mapFn: (error: E) => NewError) => Promise<Result<T, NewError>>;
@@ -62,13 +71,28 @@ declare const Result: {
62
71
  asyncMap: typeof asyncMap;
63
72
  getOkErr: typeof getOkErr;
64
73
  };
65
- /** @deprecated Use `t-result` library instead. */
74
+ /**
75
+ * @param fn
76
+ * @param errorNormalizer
77
+ * @deprecated Use `t-result` library instead.
78
+ */
66
79
  declare function resultify<T, E extends ResultValidErrors = Error>(fn: () => T extends Promise<any> ? never : T, errorNormalizer?: (err: unknown) => E): Result<T, E>;
67
- /** @deprecated Use `t-result` library instead. */
80
+ /**
81
+ * @param fn
82
+ * @param errorNormalizer
83
+ * @deprecated Use `t-result` library instead.
84
+ */
68
85
  declare function resultify<T, E extends ResultValidErrors = Error>(fn: () => Promise<T>, errorNormalizer?: (err: unknown) => E): Promise<Result<Awaited<T>, E>>;
69
- /** @deprecated Use `t-result` library instead. */
86
+ /**
87
+ * @param fn
88
+ * @param errorNormalizer
89
+ * @deprecated Use `t-result` library instead.
90
+ */
70
91
  declare function resultify<T, E extends ResultValidErrors = Error>(fn: Promise<T>, errorNormalizer?: (err: unknown) => E): Promise<Result<T, E>>;
71
- /** @deprecated Use `t-result` library instead. */
92
+ /**
93
+ * @param error
94
+ * @deprecated Use `t-result` library instead.
95
+ */
72
96
  declare function unknownToError(error: unknown): Error;
73
97
  /** @deprecated Use `t-result` library instead. */
74
98
  type TypedResult<T, E extends ResultValidErrors = Error> = {
@@ -1,28 +1,43 @@
1
1
  import { NonPartial } from './typingUtils.cjs';
2
2
 
3
3
  declare function asNonPartial<T extends Record<string, unknown>>(obj: T): NonPartial<T>;
4
- /** a wrapper to Object.entries with a better typing inference */
4
+ /**
5
+ * a wrapper to Object.entries with a better typing inference
6
+ * @param obj
7
+ */
5
8
  declare function typedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
6
9
  [K in keyof T]: [K, T[K]];
7
10
  }[keyof T]>[];
8
- /** a wrapper to Object.keys with a better typing inference */
11
+ /**
12
+ * a wrapper to Object.keys with a better typing inference
13
+ * @param obj
14
+ */
9
15
  declare function typedObjectKeys<T extends Record<string, unknown>>(obj: T): (keyof T)[];
10
- /** a safe way to cast types, use to substitute the `as Type` */
16
+ /**
17
+ * a safe way to cast types, use to substitute the `as Type`
18
+ * @param value
19
+ */
11
20
  declare function asType<T = unknown>(value: T): T;
12
- /** narrow a string to a union of strings */
21
+ /**
22
+ * narrow a string to a union of strings
23
+ * @param key
24
+ * @param union
25
+ */
13
26
  declare function narrowStringToUnion<const T extends string>(key: string | undefined | null, union: T[] | readonly T[] | Set<T>): T | undefined;
14
27
  /**
15
28
  * Type helper to check if a type is a subtype of another type.
16
29
  *
17
30
  * @template BaseType - The base type to check against
18
31
  * @template SubType - The type that should extend BaseType
19
- * @returns {unknown} Returns undefined, only used for type checking
32
+ * @returns Returns undefined, only used for type checking
20
33
  */
21
34
  declare function typeOnRightExtendsLeftType<BaseType, SubType extends BaseType>(): unknown;
22
35
  /** @deprecated use typeOnRightExtendsLeftType instead */
23
36
  declare const isSubTypeOf: typeof typeOnRightExtendsLeftType;
24
37
  /**
25
38
  * Type helper to narrow a string to a key of an object.
39
+ * @param key
40
+ * @param obj
26
41
  */
27
42
  declare function isObjKey<T extends Record<string, unknown>>(key: unknown, obj: T): key is keyof T;
28
43
  type UnionDiff<T, U> = [
@@ -43,7 +58,6 @@ type UnionDiff<T, U> = [
43
58
  * @template T - The first union type (left side)
44
59
  * @template U - The second union type (right side)
45
60
  * @param _diff - null if unions are identical, or an object describing the errors
46
- * @returns void - This function is only used for type checking
47
61
  */
48
62
  declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
49
63
 
@@ -1,28 +1,43 @@
1
1
  import { NonPartial } from './typingUtils.js';
2
2
 
3
3
  declare function asNonPartial<T extends Record<string, unknown>>(obj: T): NonPartial<T>;
4
- /** a wrapper to Object.entries with a better typing inference */
4
+ /**
5
+ * a wrapper to Object.entries with a better typing inference
6
+ * @param obj
7
+ */
5
8
  declare function typedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
6
9
  [K in keyof T]: [K, T[K]];
7
10
  }[keyof T]>[];
8
- /** a wrapper to Object.keys with a better typing inference */
11
+ /**
12
+ * a wrapper to Object.keys with a better typing inference
13
+ * @param obj
14
+ */
9
15
  declare function typedObjectKeys<T extends Record<string, unknown>>(obj: T): (keyof T)[];
10
- /** a safe way to cast types, use to substitute the `as Type` */
16
+ /**
17
+ * a safe way to cast types, use to substitute the `as Type`
18
+ * @param value
19
+ */
11
20
  declare function asType<T = unknown>(value: T): T;
12
- /** narrow a string to a union of strings */
21
+ /**
22
+ * narrow a string to a union of strings
23
+ * @param key
24
+ * @param union
25
+ */
13
26
  declare function narrowStringToUnion<const T extends string>(key: string | undefined | null, union: T[] | readonly T[] | Set<T>): T | undefined;
14
27
  /**
15
28
  * Type helper to check if a type is a subtype of another type.
16
29
  *
17
30
  * @template BaseType - The base type to check against
18
31
  * @template SubType - The type that should extend BaseType
19
- * @returns {unknown} Returns undefined, only used for type checking
32
+ * @returns Returns undefined, only used for type checking
20
33
  */
21
34
  declare function typeOnRightExtendsLeftType<BaseType, SubType extends BaseType>(): unknown;
22
35
  /** @deprecated use typeOnRightExtendsLeftType instead */
23
36
  declare const isSubTypeOf: typeof typeOnRightExtendsLeftType;
24
37
  /**
25
38
  * Type helper to narrow a string to a key of an object.
39
+ * @param key
40
+ * @param obj
26
41
  */
27
42
  declare function isObjKey<T extends Record<string, unknown>>(key: unknown, obj: T): key is keyof T;
28
43
  type UnionDiff<T, U> = [
@@ -43,7 +58,6 @@ type UnionDiff<T, U> = [
43
58
  * @template T - The first union type (left side)
44
59
  * @template U - The second union type (right side)
45
60
  * @param _diff - null if unions are identical, or an object describing the errors
46
- * @returns void - This function is only used for type checking
47
61
  */
48
62
  declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
49
63
 
@@ -72,12 +72,12 @@ function yamlStringify(obj, {
72
72
  addRootObjSpaces = "beforeAndAfter"
73
73
  } = {}) {
74
74
  if (isObject(obj) || Array.isArray(obj) || typeof obj === "function") {
75
- return `${stringifyValue(obj, "", maxLineLength, !!showUndefined, maxDepth, 0, collapseObjects, addRootObjSpaces)}
75
+ return `${stringifyValue(obj, "", maxLineLength, !!showUndefined, maxDepth, 0, collapseObjects, addRootObjSpaces, false)}
76
76
  `;
77
77
  }
78
78
  return JSON.stringify(obj) || "undefined";
79
79
  }
80
- function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, depth, collapseObjects, addObjSpaces) {
80
+ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, depth, collapseObjects, addObjSpaces, isArrayItem) {
81
81
  let result = "";
82
82
  const childIndent = `${indent} `;
83
83
  if (isPlainObject(value)) {
@@ -96,7 +96,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
96
96
  return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
97
97
  }
98
98
  );
99
- if (isSimpleObject && entries.length > 0) {
99
+ const shouldCollapse = isArrayItem ? entries.length > 1 : entries.length > 0;
100
+ if (isSimpleObject && shouldCollapse) {
100
101
  let line = "{ ";
101
102
  line += entries.map(([key, val]) => {
102
103
  let valueStr;
@@ -143,20 +144,29 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
143
144
  maxDepth,
144
145
  depth + 1,
145
146
  collapseObjects,
146
- addObjSpaces
147
+ addObjSpaces,
148
+ false
147
149
  );
148
- const willBeCollapsed = isObject(objVal) && (Object.keys(objVal).length === 0 || collapseObjects && depth + 1 > 0 && Object.entries(objVal).filter(([, val]) => val !== void 0 || showUndefined).every(([, val]) => {
149
- if (typeof val === "string") {
150
- return !val.includes("'") && !val.includes('"') && !val.includes("\\");
151
- }
152
- return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
153
- }));
154
- 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]) => {
155
- if (typeof val === "string") {
156
- return !val.includes("'") && !val.includes('"') && !val.includes("\\");
157
- }
158
- return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
159
- }));
150
+ const willBeCollapsed = isObject(objVal) && (Object.keys(objVal).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
151
+ const filteredEntries = Object.entries(objVal).filter(([, val]) => val !== void 0 || showUndefined);
152
+ const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
153
+ return shouldCollapseThis && filteredEntries.every(([, val]) => {
154
+ if (typeof val === "string") {
155
+ return !val.includes("'") && !val.includes('"') && !val.includes("\\");
156
+ }
157
+ return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
158
+ });
159
+ })());
160
+ const prevWasCollapsed = prevValue && isObject(prevValue) && (Object.keys(prevValue).length === 0 || collapseObjects && depth + 1 > 0 && (() => {
161
+ const filteredEntries = Object.entries(prevValue).filter(([, val]) => val !== void 0 || showUndefined);
162
+ const shouldCollapseThis = isArrayItem ? filteredEntries.length > 1 : filteredEntries.length > 0;
163
+ return shouldCollapseThis && filteredEntries.every(([, val]) => {
164
+ if (typeof val === "string") {
165
+ return !val.includes("'") && !val.includes('"') && !val.includes("\\");
166
+ }
167
+ return typeof val === "number" || typeof val === "boolean" || val === null || val === void 0;
168
+ });
169
+ })());
160
170
  if (!afterSpaceWasAdded && indent === "" && isObject(objVal) && !willBeCollapsed && prevValue && !prevWasCollapsed && (addObjSpaces === "before" || addObjSpaces === "beforeAndAfter")) {
161
171
  result += "\n";
162
172
  }
@@ -219,7 +229,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
219
229
  maxDepth,
220
230
  depth + 1,
221
231
  collapseObjects,
222
- addObjSpaces
232
+ addObjSpaces,
233
+ true
223
234
  );
224
235
  }).join(", ");
225
236
  line += "]";
@@ -243,7 +254,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
243
254
  maxDepth,
244
255
  depth + 1,
245
256
  collapseObjects,
246
- addObjSpaces
257
+ addObjSpaces,
258
+ true
247
259
  );
248
260
  arrayString = arrayString.trimStart();
249
261
  result += arrayString;
@@ -256,7 +268,8 @@ function stringifyValue(value, indent, maxLineLength, showUndefined, maxDepth, d
256
268
  maxDepth,
257
269
  depth + 1,
258
270
  collapseObjects,
259
- addObjSpaces
271
+ addObjSpaces,
272
+ true
260
273
  );
261
274
  }
262
275
  result += "\n";
@@ -310,7 +323,8 @@ ${indent}${line}
310
323
  maxDepth,
311
324
  depth + 1,
312
325
  collapseObjects,
313
- addObjSpaces
326
+ addObjSpaces,
327
+ false
314
328
  );
315
329
  }
316
330
  return JSON.stringify(value);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  yamlStringify
3
- } from "./chunk-JAPKLFIK.js";
3
+ } from "./chunk-QLD7KG5I.js";
4
4
  import "./chunk-IATIXMCE.js";
5
5
  import "./chunk-4REIIZQY.js";
6
6
  import "./chunk-JF2MDHOJ.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.24.1",
4
+ "version": "3.25.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "lib",
@@ -84,6 +84,10 @@
84
84
  "import": "./lib/exhaustiveMatch.js",
85
85
  "require": "./lib/exhaustiveMatch.cjs"
86
86
  },
87
+ "./filterObjectOrArrayKeys": {
88
+ "import": "./lib/filterObjectOrArrayKeys.js",
89
+ "require": "./lib/filterObjectOrArrayKeys.cjs"
90
+ },
87
91
  "./getAutoIncrementId": {
88
92
  "import": "./lib/getAutoIncrementId.js",
89
93
  "require": "./lib/getAutoIncrementId.cjs"