ts-data-forge 7.0.0 → 7.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 (115) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  2. package/dist/array/impl/array-utils-creation.mjs +1 -1
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-iterators.mjs +1 -1
  5. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  6. package/dist/array/impl/array-utils-reducing-value.d.mts +1 -1
  7. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
  8. package/dist/array/impl/array-utils-reducing-value.mjs +0 -1
  9. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  10. package/dist/array/impl/array-utils-search.d.mts +0 -2
  11. package/dist/array/impl/array-utils-search.d.mts.map +1 -1
  12. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  13. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  14. package/dist/array/impl/array-utils-set-op.mjs +0 -1
  15. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  16. package/dist/array/impl/array-utils-transformation.d.mts +1 -1
  17. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  18. package/dist/array/impl/array-utils-transformation.mjs +2 -4
  19. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  20. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  21. package/dist/array/impl/array-utils-validation.mjs +3 -9
  22. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  23. package/dist/collections/imap-mapped.d.mts +622 -3
  24. package/dist/collections/imap-mapped.d.mts.map +1 -1
  25. package/dist/collections/imap-mapped.mjs +111 -18
  26. package/dist/collections/imap-mapped.mjs.map +1 -1
  27. package/dist/collections/imap.d.mts +3 -3
  28. package/dist/collections/imap.d.mts.map +1 -1
  29. package/dist/collections/imap.mjs +6 -5
  30. package/dist/collections/imap.mjs.map +1 -1
  31. package/dist/collections/iset-mapped.d.mts +4 -4
  32. package/dist/collections/iset-mapped.d.mts.map +1 -1
  33. package/dist/collections/iset-mapped.mjs +8 -4
  34. package/dist/collections/iset-mapped.mjs.map +1 -1
  35. package/dist/collections/iset.d.mts +2 -2
  36. package/dist/collections/iset.d.mts.map +1 -1
  37. package/dist/collections/iset.mjs +5 -2
  38. package/dist/collections/iset.mjs.map +1 -1
  39. package/dist/collections/queue.mjs +20 -20
  40. package/dist/collections/queue.mjs.map +1 -1
  41. package/dist/collections/stack.mjs +17 -17
  42. package/dist/collections/stack.mjs.map +1 -1
  43. package/dist/functional/optional/impl/optional-flat-map.d.mts +2 -2
  44. package/dist/functional/pipe.d.mts.map +1 -1
  45. package/dist/functional/pipe.mjs.map +1 -1
  46. package/dist/functional/result/impl/result-flat-map.d.mts +2 -2
  47. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +5 -3
  48. package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -1
  49. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  50. package/dist/guard/has-key.d.mts.map +1 -1
  51. package/dist/guard/has-key.mjs +1 -3
  52. package/dist/guard/has-key.mjs.map +1 -1
  53. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  54. package/dist/guard/is-non-null-object.mjs +1 -3
  55. package/dist/guard/is-non-null-object.mjs.map +1 -1
  56. package/dist/guard/key-is-in.d.mts.map +1 -1
  57. package/dist/guard/key-is-in.mjs +1 -3
  58. package/dist/guard/key-is-in.mjs.map +1 -1
  59. package/dist/json/json.mjs +5 -7
  60. package/dist/json/json.mjs.map +1 -1
  61. package/dist/number/branded-types/non-zero-safe-int.mjs +2 -2
  62. package/dist/number/branded-types/positive-safe-int.mjs +1 -1
  63. package/dist/number/branded-types/safe-int.mjs +2 -2
  64. package/dist/number/branded-types/safe-uint.mjs +1 -1
  65. package/dist/number/num-arithmetic-types.d.mts.map +1 -1
  66. package/dist/number/num.mjs +3 -3
  67. package/dist/object/object.mjs +1 -1
  68. package/dist/object/object.mjs.map +1 -1
  69. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  70. package/dist/others/fast-deep-equal.mjs +0 -1
  71. package/dist/others/fast-deep-equal.mjs.map +1 -1
  72. package/dist/others/unknown-to-string.mjs +2 -2
  73. package/dist/others/unknown-to-string.mjs.map +1 -1
  74. package/package.json +5 -5
  75. package/src/array/impl/array-utils-creation.mts +1 -1
  76. package/src/array/impl/array-utils-iterators.mts +1 -1
  77. package/src/array/impl/array-utils-reducing-value.mts +1 -2
  78. package/src/array/impl/array-utils-search.mts +0 -2
  79. package/src/array/impl/array-utils-set-op.mts +0 -1
  80. package/src/array/impl/array-utils-transformation.mts +8 -6
  81. package/src/array/impl/array-utils-validation.mts +1 -5
  82. package/src/collections/imap-mapped.mts +696 -34
  83. package/src/collections/imap-mapped.test.mts +61 -13
  84. package/src/collections/imap.mts +20 -9
  85. package/src/collections/imap.test.mts +9 -8
  86. package/src/collections/iset-mapped.mts +18 -10
  87. package/src/collections/iset-mapped.test.mts +6 -1
  88. package/src/collections/iset.mts +11 -4
  89. package/src/collections/iset.test.mts +6 -8
  90. package/src/collections/queue.mts +32 -32
  91. package/src/collections/stack.mts +26 -26
  92. package/src/functional/optional/impl/optional-flat-map.mts +2 -2
  93. package/src/functional/optional.test.mts +6 -4
  94. package/src/functional/pipe.mts +0 -1
  95. package/src/functional/pipe.test.mts +2 -1
  96. package/src/functional/result/impl/result-flat-map.mts +2 -2
  97. package/src/functional/result.test.mts +3 -2
  98. package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +5 -3
  99. package/src/functional/ternary-result.test.mts +8 -3
  100. package/src/guard/has-key.mts +1 -3
  101. package/src/guard/is-non-null-object.mts +0 -1
  102. package/src/guard/key-is-in.mts +1 -3
  103. package/src/json/json.mts +5 -8
  104. package/src/json/json.test.mts +2 -2
  105. package/src/number/branded-types/non-zero-safe-int.mts +2 -2
  106. package/src/number/branded-types/positive-safe-int.mts +1 -1
  107. package/src/number/branded-types/safe-int.mts +2 -2
  108. package/src/number/branded-types/safe-uint.mts +1 -1
  109. package/src/number/num-arithmetic-types.mts +0 -4
  110. package/src/number/num.mts +3 -3
  111. package/src/number/num.test.mts +2 -2
  112. package/src/object/object.mts +2 -2
  113. package/src/others/fast-deep-equal.mts +0 -2
  114. package/src/others/map-nullable.test.mts +4 -3
  115. package/src/others/unknown-to-string.mts +2 -2
@@ -12,9 +12,9 @@ import { type UnwrapErr, type UnwrapOk } from './types.mjs';
12
12
  *
13
13
  * ```ts
14
14
  * const parseNumber = (input: string): Result<number, string> => {
15
- * const num = Number.parseInt(input, 10);
15
+ * const num = Num.safeParseInt(input);
16
16
  *
17
- * return Number.isNaN(num) ? Result.err('not a number') : Result.ok(num);
17
+ * return Result.mapErr(num, () => 'not a number');
18
18
  * };
19
19
  *
20
20
  * const parsed = Result.flatMap(Result.ok('42'), parseNumber);
@@ -1,4 +1,5 @@
1
1
  import { expectType } from '../expect-type.mjs';
2
+ import { Num } from '../number/index.mjs';
2
3
  import { type Err, type Ok } from '../types.mjs';
3
4
  import { Optional } from './optional/index.mjs';
4
5
  import { pipe } from './pipe.mjs';
@@ -467,7 +468,7 @@ describe('Result test', () => {
467
468
 
468
469
  test('should support chaining multiple flatMaps', () => {
469
470
  const parseNumber = (s: string): Result<number, string> => {
470
- const n = Number(s);
471
+ const n = Result.unwrapOkOr(Num.safeParseFloat(s), Number.NaN);
471
472
 
472
473
  return Number.isNaN(n) ? Result.err('Not a number') : Result.ok(n);
473
474
  };
@@ -518,7 +519,7 @@ describe('Result test', () => {
518
519
 
519
520
  test('should work with pipe when curried', () => {
520
521
  const parseNumber = (s: string): Result<number, string> => {
521
- const n = Number(s);
522
+ const n = Result.unwrapOkOr(Num.safeParseFloat(s), Number.NaN);
522
523
 
523
524
  return Number.isNaN(n) ? Result.err('Not a number') : Result.ok(n);
524
525
  };
@@ -15,9 +15,11 @@ import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs';
15
15
  *
16
16
  * ```ts
17
17
  * const parse = (value: string): TernaryResult<number, string, string> =>
18
- * Number.isNaN(Number(value))
19
- * ? TernaryResult.err('NaN')
20
- * : TernaryResult.ok(Number(value));
18
+ * pipe(Num.safeParseFloat(value)).map((result) =>
19
+ * Result.isErr(result)
20
+ * ? TernaryResult.err('NaN')
21
+ * : TernaryResult.ok(result.value),
22
+ * ).value;
21
23
  *
22
24
  * const doubled = TernaryResult.flatMap(TernaryResult.ok('3'), (text) =>
23
25
  * TernaryResult.map(parse(text), (num) => num * 2),
@@ -1,5 +1,8 @@
1
1
  import { expectType } from '../expect-type.mjs';
2
+ import { Num } from '../number/index.mjs';
2
3
  import { Optional } from './optional/index.mjs';
4
+ import { pipe } from './pipe.mjs';
5
+ import { Result } from './result/index.mjs';
3
6
  import { TernaryResult } from './ternary-result/index.mjs';
4
7
 
5
8
  describe('TernaryResult test', () => {
@@ -69,9 +72,11 @@ describe('TernaryResult test', () => {
69
72
 
70
73
  test('flatMap propagates Warn and Err while keeping warnings', () => {
71
74
  const parse = (value: string): TernaryResult<number, string, never> =>
72
- Number.isNaN(Number(value))
73
- ? TernaryResult.err('NaN')
74
- : TernaryResult.ok(Number(value));
75
+ pipe(Num.safeParseFloat(value)).map((result) =>
76
+ Result.isErr(result)
77
+ ? TernaryResult.err('NaN')
78
+ : TernaryResult.ok(result.value),
79
+ ).value;
75
80
 
76
81
  const warn = TernaryResult.warn('3', 'slow');
77
82
 
@@ -47,9 +47,7 @@ export const hasKey = <
47
47
  >(
48
48
  obj: R,
49
49
  key: K,
50
- ): obj is HasKeyReturnType<R, K> =>
51
- // eslint-disable-next-line ts-data-forge/prefer-is-record-and-has-key
52
- Object.hasOwn(obj, key);
50
+ ): obj is HasKeyReturnType<R, K> => Object.hasOwn(obj, key);
53
51
 
54
52
  /**
55
53
  * @internal
@@ -33,5 +33,4 @@
33
33
  */
34
34
  // eslint-disable-next-line @typescript-eslint/no-restricted-types
35
35
  export const isNonNullObject = (u: unknown): u is object =>
36
- // eslint-disable-next-line ts-data-forge/prefer-is-non-null-object
37
36
  typeof u === 'object' && u !== null;
@@ -46,6 +46,4 @@ export const keyIsIn = <
46
46
  >(
47
47
  key: K,
48
48
  obj: R,
49
- ): key is K & keyof typeof obj =>
50
- // eslint-disable-next-line ts-data-forge/prefer-is-record-and-has-key
51
- Object.hasOwn(obj, key);
49
+ ): key is K & keyof typeof obj => Object.hasOwn(obj, key);
package/src/json/json.mts CHANGED
@@ -350,18 +350,15 @@ const keysDeepImpl = (
350
350
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
351
351
  mut_keys: string[],
352
352
  ): void => {
353
- for (const k of Object.keys(obj)) {
353
+ for (const [k, v] of Object.entries(obj)) {
354
354
  mut_keys.push(k);
355
355
 
356
- const o = obj[k];
357
-
358
- if (isRecord(o)) {
359
- keysDeepImpl(o, mut_keys);
356
+ if (isRecord(v)) {
357
+ keysDeepImpl(v, mut_keys);
360
358
  }
361
359
 
362
- // eslint-disable-next-line ts-data-forge/prefer-arr-is-array
363
- if (Array.isArray(o)) {
364
- for (const li of o) {
360
+ if (Array.isArray(v)) {
361
+ for (const li of v) {
365
362
  if (isRecord(li)) {
366
363
  keysDeepImpl(li, mut_keys);
367
364
  }
@@ -1,6 +1,7 @@
1
1
  import { Arr } from '../array/index.mjs';
2
2
  import { Result } from '../functional/index.mjs';
3
3
  import { hasKey, isRecord, isString } from '../guard/index.mjs';
4
+ import { Num } from '../number/index.mjs';
4
5
  import { Json } from './json.mjs';
5
6
 
6
7
  describe('parse', () => {
@@ -154,7 +155,7 @@ describe('parse', () => {
154
155
  test('should handle reviver returning different types', () => {
155
156
  const transformReviver = (key: string, value: unknown): unknown => {
156
157
  if (key === 'number' && typeof value === 'string') {
157
- return Number.parseInt(value, 10);
158
+ return Result.unwrapOkOr(Num.safeParseInt(value), Number.NaN);
158
159
  }
159
160
 
160
161
  return value;
@@ -465,7 +466,6 @@ describe('stringifySelected', () => {
465
466
 
466
467
  // Note: stringifySelected works with JSON.stringify's replacer parameter
467
468
  // which may not work as expected with arrays
468
- // eslint-disable-next-line ts-data-forge/prefer-arr-is-array
469
469
  assert.isTrue(Array.isArray(parsed));
470
470
 
471
471
  expect(parsed).toHaveLength(3);
@@ -31,9 +31,9 @@ const {
31
31
  >({
32
32
  integerOrSafeInteger: 'SafeInteger',
33
33
  nonZero: true,
34
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-min-safe-integer, ts-data-forge/prefer-as-int
34
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-min-safe-integer
35
35
  MIN_VALUE: Number.MIN_SAFE_INTEGER as SafeInt,
36
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer, ts-data-forge/prefer-as-int
36
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
37
37
  MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,
38
38
  typeNameInMessage,
39
39
  } as const);
@@ -32,7 +32,7 @@ const {
32
32
  >({
33
33
  integerOrSafeInteger: 'SafeInteger',
34
34
  MIN_VALUE: 1,
35
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer, ts-data-forge/prefer-as-int
35
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
36
36
  MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,
37
37
  typeNameInMessage,
38
38
  } as const);
@@ -32,9 +32,9 @@ const {
32
32
  SafeUint
33
33
  >({
34
34
  integerOrSafeInteger: 'SafeInteger',
35
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-min-safe-integer, ts-data-forge/prefer-as-int
35
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-min-safe-integer
36
36
  MIN_VALUE: Number.MIN_SAFE_INTEGER as SafeInt,
37
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer, ts-data-forge/prefer-as-int
37
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
38
38
  MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,
39
39
  typeNameInMessage,
40
40
  } as const);
@@ -29,7 +29,7 @@ const {
29
29
  >({
30
30
  integerOrSafeInteger: 'SafeInteger',
31
31
  MIN_VALUE: 0,
32
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer, ts-data-forge/prefer-as-int
32
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
33
33
  MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,
34
34
  typeNameInMessage,
35
35
  } as const);
@@ -52,7 +52,6 @@ type Sign = 'any' | 'neg' | 'nonneg' | 'nonpos' | 'nonzero' | 'pos';
52
52
  type Level = 'finite' | 'int' | 'number' | 'safeint';
53
53
 
54
54
  /** Classifies a numeric type's sign. */
55
- // transformer-ignore-next-line convert-to-readonly
56
55
  export type SignOf<N> = [N] extends [PositiveNumber]
57
56
  ? 'pos'
58
57
  : [N] extends [NegativeNumber]
@@ -66,7 +65,6 @@ export type SignOf<N> = [N] extends [PositiveNumber]
66
65
  : 'any';
67
66
 
68
67
  /** Classifies a numeric type's level. */
69
- // transformer-ignore-next-line convert-to-readonly
70
68
  export type LevelOf<N> = [N] extends [SafeInt]
71
69
  ? 'safeint'
72
70
  : [N] extends [Int]
@@ -77,7 +75,6 @@ export type LevelOf<N> = [N] extends [SafeInt]
77
75
 
78
76
  // --- boolean fact algebra over a sign ----------------------------------------
79
77
 
80
- // transformer-ignore-next-line convert-to-readonly
81
78
  type And<A extends boolean, B extends boolean> = [A, B] extends [true, true]
82
79
  ? true
83
80
  : false;
@@ -171,7 +168,6 @@ type DivLevel<LA extends Level, LB extends Level> = 'number' extends LA | LB
171
168
  : 'finite';
172
169
 
173
170
  /** Floor division yields an integer; the safe range is preserved. */
174
- // transformer-ignore-next-line convert-to-readonly
175
171
  type DivIntLevel<LA extends Level, LB extends Level> = 'number' extends LA | LB
176
172
  ? 'number'
177
173
  : [LA, LB] extends ['safeint', 'safeint']
@@ -134,7 +134,7 @@ export namespace Num {
134
134
  ? Result.err(
135
135
  new Error(`safeParseInt: "${s}" is not a valid base-10 integer`),
136
136
  )
137
- : // eslint-disable-next-line total-functions/no-unsafe-type-assertion, ts-data-forge/prefer-as-int
137
+ : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
138
138
  Result.ok(Math.trunc(viaNumber) as Int);
139
139
  };
140
140
 
@@ -214,7 +214,7 @@ export namespace Num {
214
214
  ? Result.err(
215
215
  new Error(`safeParseFloat: "${s}" is not a valid finite number`),
216
216
  )
217
- : // eslint-disable-next-line total-functions/no-unsafe-type-assertion, ts-data-forge/prefer-as-int
217
+ : // eslint-disable-next-line total-functions/no-unsafe-type-assertion
218
218
  Result.ok(viaNumber as FiniteNumber);
219
219
  };
220
220
 
@@ -649,7 +649,7 @@ export namespace Num {
649
649
  * @param num - The number to round
650
650
  * @returns The rounded integer as an Int branded type
651
651
  */
652
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, ts-data-forge/prefer-as-int
652
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
653
653
  export const roundToInt = (num: number): Int => Math.trunc(num + 0.5) as Int;
654
654
 
655
655
  /**
@@ -164,7 +164,7 @@ describe('Num test', () => {
164
164
  test('rejects empty / whitespace-only input (unlike Number)', () => {
165
165
  assert.isTrue(Result.isErr(Num.safeParseInt('')));
166
166
 
167
- assert.isTrue(Result.isErr(Num.safeParseInt(' ')));
167
+ assert.isTrue(Result.isErr(Num.safeParseInt(' '.repeat(3))));
168
168
  });
169
169
 
170
170
  test('rejects non-finite words', () => {
@@ -222,7 +222,7 @@ describe('Num test', () => {
222
222
  test('rejects empty / whitespace-only input (unlike Number)', () => {
223
223
  assert.isTrue(Result.isErr(Num.safeParseFloat('')));
224
224
 
225
- assert.isTrue(Result.isErr(Num.safeParseFloat(' ')));
225
+ assert.isTrue(Result.isErr(Num.safeParseFloat(' '.repeat(3))));
226
226
  });
227
227
 
228
228
  test('rejects non-finite values', () => {
@@ -505,10 +505,10 @@ const deepOmitImpl = (
505
505
 
506
506
  const head = path[0];
507
507
 
508
- const tail = path.slice(1);
509
-
510
508
  if (!hasKey(record, head)) return record;
511
509
 
510
+ const tail = path.slice(1);
511
+
512
512
  if (!Arr.isNonEmpty(tail)) {
513
513
  return Object.fromEntries(
514
514
  Object.entries(record).filter(([k]) => k !== head),
@@ -1,5 +1,3 @@
1
- /* eslint-disable ts-data-forge/prefer-arr-is-array */
2
-
3
1
  import { isMap, isRegExp, isSet, isTypedArray } from '@sindresorhus/is';
4
2
  import { hasKey, isRecord } from '../guard/index.mjs';
5
3
 
@@ -1,6 +1,7 @@
1
1
  import { type DeepReadonly } from 'ts-type-forge';
2
2
  import { expectType } from '../expect-type.mjs';
3
- import { pipe } from '../functional/index.mjs';
3
+ import { pipe, Result } from '../functional/index.mjs';
4
+ import { Num } from '../number/index.mjs';
4
5
  import { mapNullable } from './map-nullable.mjs';
5
6
 
6
7
  describe(mapNullable, () => {
@@ -306,7 +307,7 @@ describe(mapNullable, () => {
306
307
  const extractAge = mapNullable((data: FormDataType) => data.age);
307
308
 
308
309
  const parseAge = mapNullable((ageStr: string) =>
309
- Number.parseInt(ageStr, 10),
310
+ Result.unwrapOkOr(Num.safeParseInt(ageStr), Number.NaN),
310
311
  );
311
312
 
312
313
  const validateAge = mapNullable((age: number) =>
@@ -336,7 +337,7 @@ describe(mapNullable, () => {
336
337
  const extractAge = mapNullable((data: FormDataType) => data.age);
337
338
 
338
339
  const parseAge = mapNullable((ageStr: string) =>
339
- Number.parseInt(ageStr, 10),
340
+ Result.unwrapOkOr(Num.safeParseInt(ageStr), Number.NaN),
340
341
  );
341
342
 
342
343
  const extractedAge = extractAge(incompleteFormData);
@@ -78,7 +78,7 @@ export const unknownToString = (
78
78
 
79
79
  // Special handling for Map
80
80
  if (isMap(value)) {
81
- const entries = Array.from(value.entries());
81
+ const entries = Array.from(value);
82
82
 
83
83
  const entriesStr = prettyPrintObject
84
84
  ? JSON.stringify(entries, undefined, 2)
@@ -89,7 +89,7 @@ export const unknownToString = (
89
89
 
90
90
  // Special handling for Set
91
91
  if (isSet(value)) {
92
- const values = Array.from(value.values());
92
+ const values = Array.from(value);
93
93
 
94
94
  const valuesStr = prettyPrintObject
95
95
  ? JSON.stringify(values, undefined, 2)