@augment-vir/common 31.9.0 → 31.9.2

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 (38) hide show
  1. package/dist/augments/array/array-map.d.ts +12 -3
  2. package/dist/augments/array/array-map.js +12 -3
  3. package/dist/augments/array/array-to-object.d.ts +7 -1
  4. package/dist/augments/array/array-to-object.js +24 -6
  5. package/dist/augments/array/awaited/awaited-filter.d.ts +12 -3
  6. package/dist/augments/array/awaited/awaited-filter.js +12 -3
  7. package/dist/augments/array/awaited/awaited-for-each.d.ts +12 -3
  8. package/dist/augments/array/awaited/awaited-for-each.js +12 -3
  9. package/dist/augments/array/awaited/awaited-map.d.ts +12 -3
  10. package/dist/augments/array/awaited/awaited-map.js +12 -3
  11. package/dist/augments/array/filter.d.ts +11 -1
  12. package/dist/augments/array/filter.js +16 -2
  13. package/dist/augments/array/remove-duplicates.d.ts +16 -2
  14. package/dist/augments/array/remove-duplicates.js +16 -2
  15. package/dist/augments/array/repeat-array.d.ts +5 -1
  16. package/dist/augments/array/repeat-array.js +5 -1
  17. package/dist/augments/enum/enum-value-check.d.ts +11 -1
  18. package/dist/augments/enum/enum-value-check.js +11 -1
  19. package/dist/augments/error/combine-errors.d.ts +4 -1
  20. package/dist/augments/error/combine-errors.js +4 -1
  21. package/dist/augments/json/append-json.js +11 -1
  22. package/dist/augments/json/copy-through-json.d.ts +8 -2
  23. package/dist/augments/json/copy-through-json.js +8 -2
  24. package/dist/augments/json/jsonify.d.ts +8 -2
  25. package/dist/augments/json/jsonify.js +8 -2
  26. package/dist/augments/log/log-colors.js +12 -3
  27. package/dist/augments/number/truncate-number.js +35 -12
  28. package/dist/augments/object/diff.js +20 -5
  29. package/dist/augments/object/map-entries.js +9 -3
  30. package/dist/augments/object/merge-deep.js +2 -2
  31. package/dist/augments/object/merge-defined-properties.js +1 -1
  32. package/dist/augments/object/merge-property-arrays.d.ts +8 -2
  33. package/dist/augments/object/merge-property-arrays.js +9 -3
  34. package/dist/augments/object/object-entries.js +4 -1
  35. package/dist/augments/object/object-filter.js +1 -1
  36. package/dist/augments/regexp/regexp-flags.js +4 -1
  37. package/dist/augments/string/comma.js +6 -2
  38. package/package.json +8 -8
@@ -12,9 +12,18 @@ import { Writable } from '../type/writable.js';
12
12
  * ```ts
13
13
  * import {typedMap} from '@augment-vir/common';
14
14
  *
15
- * const result = await typedMap([1, 2, 3, 4, 5], (value) => {
16
- * return value + 1;
17
- * });
15
+ * const result = await typedMap(
16
+ * [
17
+ * 1,
18
+ * 2,
19
+ * 3,
20
+ * 4,
21
+ * 5,
22
+ * ],
23
+ * (value) => {
24
+ * return value + 1;
25
+ * },
26
+ * );
18
27
  * ```
19
28
  *
20
29
  * @returns A new array (does not mutate).
@@ -10,9 +10,18 @@
10
10
  * ```ts
11
11
  * import {typedMap} from '@augment-vir/common';
12
12
  *
13
- * const result = await typedMap([1, 2, 3, 4, 5], (value) => {
14
- * return value + 1;
15
- * });
13
+ * const result = await typedMap(
14
+ * [
15
+ * 1,
16
+ * 2,
17
+ * 3,
18
+ * 4,
19
+ * 5,
20
+ * ],
21
+ * (value) => {
22
+ * return value + 1;
23
+ * },
24
+ * );
16
25
  * ```
17
26
  *
18
27
  * @returns A new array (does not mutate).
@@ -10,7 +10,13 @@ import { type MaybePromise } from '@augment-vir/core';
10
10
  * ```ts
11
11
  * import {arrayToObject} from '@augment-vir/common';
12
12
  *
13
- * const result = arrayToObject(['a', 'b'], (value) => `key-${value}`);
13
+ * const result = arrayToObject(
14
+ * [
15
+ * 'a',
16
+ * 'b',
17
+ * ],
18
+ * (value) => `key-${value}`,
19
+ * );
14
20
  * // result is `{key-a: ['a'], key-b: ['b']}`
15
21
  * ```
16
22
  */
@@ -14,7 +14,13 @@ import { filterMap } from './filter.js';
14
14
  * ```ts
15
15
  * import {arrayToObject} from '@augment-vir/common';
16
16
  *
17
- * const result = arrayToObject(['a', 'b'], (value) => `key-${value}`);
17
+ * const result = arrayToObject(
18
+ * [
19
+ * 'a',
20
+ * 'b',
21
+ * ],
22
+ * (value) => `key-${value}`,
23
+ * );
18
24
  * // result is `{key-a: ['a'], key-b: ['b']}`
19
25
  * ```
20
26
  */
@@ -40,9 +46,15 @@ export function groupArrayBy(inputArray, callback) {
40
46
  * ```ts
41
47
  * import {arrayToObject} from '@augment-vir/common';
42
48
  *
43
- * const result = arrayToObject(['a', 'b'], (value) => {
44
- * return {key: `key-${value}`, value};
45
- * });
49
+ * const result = arrayToObject(
50
+ * [
51
+ * 'a',
52
+ * 'b',
53
+ * ],
54
+ * (value) => {
55
+ * return {key: `key-${value}`, value};
56
+ * },
57
+ * );
46
58
  * // result is `{key-a: 'a', key-b: 'b'}`
47
59
  * ```
48
60
  *
@@ -59,7 +71,10 @@ export function arrayToObject(inputArray, callback) {
59
71
  return output;
60
72
  }
61
73
  else if (output) {
62
- return [output.key, output.value];
74
+ return [
75
+ output.key,
76
+ output.value,
77
+ ];
63
78
  }
64
79
  else {
65
80
  return undefined;
@@ -77,7 +92,10 @@ export function arrayToObject(inputArray, callback) {
77
92
  return entry;
78
93
  }
79
94
  else {
80
- return [entry.key, entry.value];
95
+ return [
96
+ entry.key,
97
+ entry.value,
98
+ ];
81
99
  }
82
100
  }, check.isTruthy);
83
101
  resolve(typedObjectFromEntries(entries));
@@ -10,9 +10,18 @@
10
10
  * ```ts
11
11
  * import {awaitedFilter} from '@augment-vir/common';
12
12
  *
13
- * const result = await awaitedFilter([1, 2, 3, 4, 5], async (value) => {
14
- * return await Promise.resolve(value > 2);
15
- * });
13
+ * const result = await awaitedFilter(
14
+ * [
15
+ * 1,
16
+ * 2,
17
+ * 3,
18
+ * 4,
19
+ * 5,
20
+ * ],
21
+ * async (value) => {
22
+ * return await Promise.resolve(value > 2);
23
+ * },
24
+ * );
16
25
  * ```
17
26
  *
18
27
  * @returns A new array (does not mutate).
@@ -11,9 +11,18 @@ import { awaitedBlockingMap } from './awaited-map.js';
11
11
  * ```ts
12
12
  * import {awaitedFilter} from '@augment-vir/common';
13
13
  *
14
- * const result = await awaitedFilter([1, 2, 3, 4, 5], async (value) => {
15
- * return await Promise.resolve(value > 2);
16
- * });
14
+ * const result = await awaitedFilter(
15
+ * [
16
+ * 1,
17
+ * 2,
18
+ * 3,
19
+ * 4,
20
+ * 5,
21
+ * ],
22
+ * async (value) => {
23
+ * return await Promise.resolve(value > 2);
24
+ * },
25
+ * );
17
26
  * ```
18
27
  *
19
28
  * @returns A new array (does not mutate).
@@ -12,9 +12,18 @@
12
12
  * ```ts
13
13
  * import {awaitedForEach} from '@augment-vir/common';
14
14
  *
15
- * await awaitedForEach([1, 2, 3, 4, 5], async (value) => {
16
- * await Promise.resolve(value);
17
- * });
15
+ * await awaitedForEach(
16
+ * [
17
+ * 1,
18
+ * 2,
19
+ * 3,
20
+ * 4,
21
+ * 5,
22
+ * ],
23
+ * async (value) => {
24
+ * await Promise.resolve(value);
25
+ * },
26
+ * );
18
27
  * ```
19
28
  *
20
29
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
@@ -13,9 +13,18 @@ import { awaitedBlockingMap } from './awaited-map.js';
13
13
  * ```ts
14
14
  * import {awaitedForEach} from '@augment-vir/common';
15
15
  *
16
- * await awaitedForEach([1, 2, 3, 4, 5], async (value) => {
17
- * await Promise.resolve(value);
18
- * });
16
+ * await awaitedForEach(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 4,
22
+ * 5,
23
+ * ],
24
+ * async (value) => {
25
+ * await Promise.resolve(value);
26
+ * },
27
+ * );
19
28
  * ```
20
29
  *
21
30
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
@@ -13,9 +13,18 @@
13
13
  * ```ts
14
14
  * import {awaitedBlockingMap} from '@augment-vir/common';
15
15
  *
16
- * const result = await awaitedBlockingMap([1, 2, 3, 4, 5], async (value) => {
17
- * return await Promise.resolve(value);
18
- * });
16
+ * const result = await awaitedBlockingMap(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 4,
22
+ * 5,
23
+ * ],
24
+ * async (value) => {
25
+ * return await Promise.resolve(value);
26
+ * },
27
+ * );
19
28
  * ```
20
29
  *
21
30
  * @returns A new array (does not mutate).
@@ -13,9 +13,18 @@
13
13
  * ```ts
14
14
  * import {awaitedBlockingMap} from '@augment-vir/common';
15
15
  *
16
- * const result = await awaitedBlockingMap([1, 2, 3, 4, 5], async (value) => {
17
- * return await Promise.resolve(value);
18
- * });
16
+ * const result = await awaitedBlockingMap(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 4,
22
+ * 5,
23
+ * ],
24
+ * async (value) => {
25
+ * return await Promise.resolve(value);
26
+ * },
27
+ * );
19
28
  * ```
20
29
  *
21
30
  * @returns A new array (does not mutate).
@@ -8,7 +8,17 @@
8
8
  * ```ts
9
9
  * import {filterOutIndexes} from '@augment-vir/common';
10
10
  *
11
- * const result = filterOutIndexes(['a', 'b', ''], [0, 2]);
11
+ * const result = filterOutIndexes(
12
+ * [
13
+ * 'a',
14
+ * 'b',
15
+ * '',
16
+ * ],
17
+ * [
18
+ * 0,
19
+ * 2,
20
+ * ],
21
+ * );
12
22
  * // result is `['b']`
13
23
  * ```
14
24
  *
@@ -8,7 +8,17 @@
8
8
  * ```ts
9
9
  * import {filterOutIndexes} from '@augment-vir/common';
10
10
  *
11
- * const result = filterOutIndexes(['a', 'b', ''], [0, 2]);
11
+ * const result = filterOutIndexes(
12
+ * [
13
+ * 'a',
14
+ * 'b',
15
+ * '',
16
+ * ],
17
+ * [
18
+ * 0,
19
+ * 2,
20
+ * ],
21
+ * );
12
22
  * // result is `['b']`
13
23
  * ```
14
24
  *
@@ -33,7 +43,11 @@ export function filterOutIndexes(array, indexes) {
33
43
  * import {filterMap} from '@augment-vir/common';
34
44
  *
35
45
  * const result = filterMap(
36
- * ['a', 'b', ''],
46
+ * [
47
+ * 'a',
48
+ * 'b',
49
+ * '',
50
+ * ],
37
51
  * // map callback
38
52
  * (value) => {
39
53
  * return `value-${value}`;
@@ -9,7 +9,15 @@
9
9
  * ```ts
10
10
  * import {removeDuplicates} from '@augment-vir/common';
11
11
  *
12
- * const result = removeDuplicates([1, 1, 1, 1, 1, 2, 4]);
12
+ * const result = removeDuplicates([
13
+ * 1,
14
+ * 1,
15
+ * 1,
16
+ * 1,
17
+ * 1,
18
+ * 2,
19
+ * 4,
20
+ * ]);
13
21
  * // result is `[1, 2, 4]`
14
22
  *
15
23
  * const exampleEntry = {id: 5};
@@ -34,7 +42,13 @@
34
42
  * const exampleEntry = {id: 5};
35
43
  *
36
44
  * const result2 = removeDuplicates(
37
- * [{id: 1}, {id: 1}, exampleEntry, exampleEntry, {id: 4}],
45
+ * [
46
+ * {id: 1},
47
+ * {id: 1},
48
+ * exampleEntry,
49
+ * exampleEntry,
50
+ * {id: 4},
51
+ * ],
38
52
  * (entry) => entry.id,
39
53
  * );
40
54
  * // result2 is `[{id: 1}, exampleEntry, {id: 4}]`
@@ -9,7 +9,15 @@
9
9
  * ```ts
10
10
  * import {removeDuplicates} from '@augment-vir/common';
11
11
  *
12
- * const result = removeDuplicates([1, 1, 1, 1, 1, 2, 4]);
12
+ * const result = removeDuplicates([
13
+ * 1,
14
+ * 1,
15
+ * 1,
16
+ * 1,
17
+ * 1,
18
+ * 2,
19
+ * 4,
20
+ * ]);
13
21
  * // result is `[1, 2, 4]`
14
22
  *
15
23
  * const exampleEntry = {id: 5};
@@ -34,7 +42,13 @@
34
42
  * const exampleEntry = {id: 5};
35
43
  *
36
44
  * const result2 = removeDuplicates(
37
- * [{id: 1}, {id: 1}, exampleEntry, exampleEntry, {id: 4}],
45
+ * [
46
+ * {id: 1},
47
+ * {id: 1},
48
+ * exampleEntry,
49
+ * exampleEntry,
50
+ * {id: 4},
51
+ * ],
38
52
  * (entry) => entry.id,
39
53
  * );
40
54
  * // result2 is `[{id: 1}, exampleEntry, {id: 4}]`
@@ -9,7 +9,11 @@
9
9
  * ```ts
10
10
  * import {repeatArray} from '@augment-vir/common';
11
11
  *
12
- * const result = repeatArray(3, ['a', 'b', 'c']);
12
+ * const result = repeatArray(3, [
13
+ * 'a',
14
+ * 'b',
15
+ * 'c',
16
+ * ]);
13
17
  * // result is `['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']`
14
18
  * ```
15
19
  *
@@ -9,7 +9,11 @@
9
9
  * ```ts
10
10
  * import {repeatArray} from '@augment-vir/common';
11
11
  *
12
- * const result = repeatArray(3, ['a', 'b', 'c']);
12
+ * const result = repeatArray(3, [
13
+ * 'a',
14
+ * 'b',
15
+ * 'c',
16
+ * ]);
13
17
  * // result is `['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']`
14
18
  * ```
15
19
  *
@@ -13,7 +13,17 @@ import type { EnumBaseType } from '@augment-vir/core';
13
13
  * B = 'b',
14
14
  * }
15
15
  *
16
- * const result = filterToEnumValues([1, 2, 3, 'a', 'b', MyEnum.A], MyEnum); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
16
+ * const result = filterToEnumValues(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 'a',
22
+ * 'b',
23
+ * MyEnum.A,
24
+ * ],
25
+ * MyEnum,
26
+ * ); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
17
27
  * ```
18
28
  *
19
29
  * @returns A new array (does not mutate).
@@ -13,7 +13,17 @@ import { check } from '@augment-vir/assert';
13
13
  * B = 'b',
14
14
  * }
15
15
  *
16
- * const result = filterToEnumValues([1, 2, 3, 'a', 'b', MyEnum.A], MyEnum); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
16
+ * const result = filterToEnumValues(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 'a',
22
+ * 'b',
23
+ * MyEnum.A,
24
+ * ],
25
+ * MyEnum,
26
+ * ); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
17
27
  * ```
18
28
  *
19
29
  * @returns A new array (does not mutate).
@@ -12,7 +12,10 @@
12
12
  * ```ts
13
13
  * import {combineErrors} from '@augment-vir/common';
14
14
  *
15
- * const result1 = combineErrors([new Error('message 1'), new Error('message 2')]); // result1 is a single error with the message 'message 1\nmessage 2'
15
+ * const result1 = combineErrors([
16
+ * new Error('message 1'),
17
+ * new Error('message 2'),
18
+ * ]); // result1 is a single error with the message 'message 1\nmessage 2'
16
19
  * ```
17
20
  *
18
21
  * @returns A single error.
@@ -14,7 +14,10 @@ import { extractErrorMessage } from '@augment-vir/core';
14
14
  * ```ts
15
15
  * import {combineErrors} from '@augment-vir/common';
16
16
  *
17
- * const result1 = combineErrors([new Error('message 1'), new Error('message 2')]); // result1 is a single error with the message 'message 1\nmessage 2'
17
+ * const result1 = combineErrors([
18
+ * new Error('message 1'),
19
+ * new Error('message 2'),
20
+ * ]); // result1 is a single error with the message 'message 1\nmessage 2'
18
21
  * ```
19
22
  *
20
23
  * @returns A single error.
@@ -18,7 +18,17 @@ import { copyThroughJson } from './copy-through-json.js';
18
18
  * // `result2` will be `[{a: 'a'}, {b: 'b'}, {a: 'q'}, 'r']`
19
19
  * const result2 = appendJson([{a: 'a'}], {b: 'b'}, {a: 'q'}, 'r');
20
20
  * // `result3` will be `['a', ['b', 'c'], 'd', 'e']`
21
- * const result3 = appendJson(['a'], [['b', 'c']], ['d'], 'e');
21
+ * const result3 = appendJson(
22
+ * ['a'],
23
+ * [
24
+ * [
25
+ * 'b',
26
+ * 'c',
27
+ * ],
28
+ * ],
29
+ * ['d'],
30
+ * 'e',
31
+ * );
22
32
  * ```
23
33
  *
24
34
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
@@ -16,8 +16,14 @@ import { Jsonify, Writable } from 'type-fest';
16
16
  * // `copy2` will be `{map: {}, b: 'b'}`
17
17
  * const copy2 = copyThroughJson({
18
18
  * map: new Map([
19
- * ['q', 'r'],
20
- * ['s', 't'],
19
+ * [
20
+ * 'q',
21
+ * 'r',
22
+ * ],
23
+ * [
24
+ * 's',
25
+ * 't',
26
+ * ],
21
27
  * ]),
22
28
  * b: 'b',
23
29
  * });
@@ -15,8 +15,14 @@
15
15
  * // `copy2` will be `{map: {}, b: 'b'}`
16
16
  * const copy2 = copyThroughJson({
17
17
  * map: new Map([
18
- * ['q', 'r'],
19
- * ['s', 't'],
18
+ * [
19
+ * 'q',
20
+ * 'r',
21
+ * ],
22
+ * [
23
+ * 's',
24
+ * 't',
25
+ * ],
20
26
  * ]),
21
27
  * b: 'b',
22
28
  * });
@@ -13,8 +13,14 @@ import { Jsonify } from 'type-fest';
13
13
  * // `result` is `{b: 'b'}`
14
14
  * const result = jsonify({
15
15
  * map: new Map([
16
- * ['q', 'r'],
17
- * ['s', 't'],
16
+ * [
17
+ * 'q',
18
+ * 'r',
19
+ * ],
20
+ * [
21
+ * 's',
22
+ * 't',
23
+ * ],
18
24
  * ]),
19
25
  * b: 'b',
20
26
  * });
@@ -13,8 +13,14 @@ import JSON5 from 'json5';
13
13
  * // `result` is `{b: 'b'}`
14
14
  * const result = jsonify({
15
15
  * map: new Map([
16
- * ['q', 'r'],
17
- * ['s', 't'],
16
+ * [
17
+ * 'q',
18
+ * 'r',
19
+ * ],
20
+ * [
21
+ * 's',
22
+ * 't',
23
+ * ],
18
24
  * ]),
19
25
  * b: 'b',
20
26
  * });
@@ -107,7 +107,10 @@ export const defaultLogColorConfig = {
107
107
  logType: LogOutputType.Standard,
108
108
  },
109
109
  [LogColorKey.Mutate]: {
110
- colors: [logColors.mutate, logColors.bold],
110
+ colors: [
111
+ logColors.mutate,
112
+ logColors.bold,
113
+ ],
111
114
  logType: LogOutputType.Standard,
112
115
  },
113
116
  [LogColorKey.NormalWeight]: {
@@ -120,11 +123,17 @@ export const defaultLogColorConfig = {
120
123
  logType: LogOutputType.Standard,
121
124
  },
122
125
  [LogColorKey.Success]: {
123
- colors: [logColors.success, logColors.bold],
126
+ colors: [
127
+ logColors.success,
128
+ logColors.bold,
129
+ ],
124
130
  logType: LogOutputType.Standard,
125
131
  },
126
132
  [LogColorKey.Error]: {
127
- colors: [logColors.error, logColors.bold],
133
+ colors: [
134
+ logColors.error,
135
+ logColors.bold,
136
+ ],
128
137
  logType: LogOutputType.Error,
129
138
  },
130
139
  [LogColorKey.Warning]: {
@@ -32,21 +32,31 @@ function combineBeforeAndAfterDot({ beforeDot, afterDot = '', maxLength, }) {
32
32
  if (!Number(slicedAfterDot)) {
33
33
  return beforeDot;
34
34
  }
35
- return [beforeDot, slicedAfterDot].join('.');
35
+ return [
36
+ beforeDot,
37
+ slicedAfterDot,
38
+ ].join('.');
36
39
  }
37
40
  }
38
41
  return beforeDot;
39
42
  }
40
43
  function truncateBigNumber(numberAsString, suffixes, maxLength) {
41
- const [beforeDot, afterDot] = safeSplit(numberAsString, '.');
44
+ const [beforeDot, afterDot,] = safeSplit(numberAsString, '.');
42
45
  const withCommas = addCommasToNumber(beforeDot);
43
46
  const truncationDepth = safeMatch(withCommas, /,/g).length;
44
47
  const suffix = suffixes[truncationDepth - 1];
45
- const [beforeComma, afterComma] = safeSplit(withCommas, ',');
46
- const trailing = [afterComma, afterDot].join('');
48
+ const [beforeComma, afterComma,] = safeSplit(withCommas, ',');
49
+ const trailing = [
50
+ afterComma,
51
+ afterDot,
52
+ ].join('');
47
53
  if (beforeComma.length + 1 > maxLength) {
48
54
  // will look like 0.9M
49
- return ['0.', beforeComma[0], suffixes[truncationDepth]].join('');
55
+ return [
56
+ '0.',
57
+ beforeComma[0],
58
+ suffixes[truncationDepth],
59
+ ].join('');
50
60
  }
51
61
  else {
52
62
  const combined = combineBeforeAndAfterDot({
@@ -54,22 +64,32 @@ function truncateBigNumber(numberAsString, suffixes, maxLength) {
54
64
  afterDot: trailing,
55
65
  maxLength: maxLength - 1 /* -1 to account for the suffix*/,
56
66
  });
57
- return [combined, suffix].join('');
67
+ return [
68
+ combined,
69
+ suffix,
70
+ ].join('');
58
71
  }
59
72
  }
60
73
  const minScientificNotationLength = '1e+'.length;
61
74
  function truncateScientificNotation({ input, maxLength, }) {
62
75
  const valueString = String(input);
63
- const [beforeExponent, rawExponent] = safeSplit(valueString, 'e');
76
+ const [beforeExponent, rawExponent,] = safeSplit(valueString, 'e');
64
77
  const exponent = rawExponent.replace(/^[-+]/, '');
65
78
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
66
79
  const plusOrMinus = rawExponent[0];
67
- const eSuffix = ['e', plusOrMinus, exponent].join('');
68
- const [beforeDot, afterDot] = safeSplit(beforeExponent, '.');
80
+ const eSuffix = [
81
+ 'e',
82
+ plusOrMinus,
83
+ exponent,
84
+ ].join('');
85
+ const [beforeDot, afterDot,] = safeSplit(beforeExponent, '.');
69
86
  const minLength = exponent.length + minScientificNotationLength;
70
87
  if (minLength === maxLength) {
71
88
  // this will look like "4e+4" or "5e-234"
72
- return [beforeDot, eSuffix].join('');
89
+ return [
90
+ beforeDot,
91
+ eSuffix,
92
+ ].join('');
73
93
  }
74
94
  else if (minLength > maxLength) {
75
95
  // in this case the number is either way too big or way to small for its exponent to fit within the max length so we just jump to 0 or Infinity
@@ -87,11 +107,14 @@ function truncateScientificNotation({ input, maxLength, }) {
87
107
  beforeDot,
88
108
  maxLength: maxLength - exponent.length + minScientificNotationLength,
89
109
  });
90
- return [beforeE, eSuffix].join('');
110
+ return [
111
+ beforeE,
112
+ eSuffix,
113
+ ].join('');
91
114
  }
92
115
  }
93
116
  function handleSmallNumbers(numberAsString, maxLength) {
94
- const [beforeDot, afterDot] = safeSplit(addCommasToNumber(numberAsString), '.');
117
+ const [beforeDot, afterDot,] = safeSplit(addCommasToNumber(numberAsString), '.');
95
118
  if (beforeDot.length <= maxLength) {
96
119
  return combineBeforeAndAfterDot({
97
120
  beforeDot,
@@ -10,7 +10,10 @@ import { getObjectTypedKeys } from '@augment-vir/core';
10
10
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
11
11
  */
12
12
  export function diffObjects(object0, object1) {
13
- const allObjectKeys = Array.from(new Set([...getObjectTypedKeys(object0), ...getObjectTypedKeys(object1)]));
13
+ const allObjectKeys = Array.from(new Set([
14
+ ...getObjectTypedKeys(object0),
15
+ ...getObjectTypedKeys(object1),
16
+ ]));
14
17
  const diffOutput = allObjectKeys.reduce((accum, objectKey) => {
15
18
  const value0 = object0[objectKey];
16
19
  const value1 = object1[objectKey];
@@ -29,7 +32,10 @@ export function diffObjects(object0, object1) {
29
32
  accum[0][objectKey] = diffOutput[0];
30
33
  }
31
34
  return accum;
32
- }, [{}, {}]);
35
+ }, [
36
+ {},
37
+ {},
38
+ ]);
33
39
  if (!Object.keys(diffOutput[0]).length && !Object.keys(diffOutput[1]).length) {
34
40
  return [];
35
41
  }
@@ -47,7 +53,10 @@ export function diffObjects(object0, object1) {
47
53
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
48
54
  */
49
55
  export function diffArrays(array0, array1) {
50
- const allArrayIndexes = Array.from(new Set([...Object.keys(array0), ...Object.keys(array1)].map((index) => Number(index)))).sort();
56
+ const allArrayIndexes = Array.from(new Set([
57
+ ...Object.keys(array0),
58
+ ...Object.keys(array1),
59
+ ].map((index) => Number(index)))).sort();
51
60
  const diffArrays = allArrayIndexes.reduce((accum, arrayIndex) => {
52
61
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
53
62
  const value0 = array0[arrayIndex];
@@ -63,7 +72,10 @@ export function diffArrays(array0, array1) {
63
72
  }
64
73
  }
65
74
  return accum;
66
- }, [[], []]);
75
+ }, [
76
+ [],
77
+ [],
78
+ ]);
67
79
  if (!diffArrays[0].length && !diffArrays[1].length) {
68
80
  return [];
69
81
  }
@@ -87,7 +99,10 @@ areEqual = (value0, value1) => value0 === value1) {
87
99
  return [];
88
100
  }
89
101
  else {
90
- return [value0, value1];
102
+ return [
103
+ value0,
104
+ value1,
105
+ ];
91
106
  }
92
107
  }
93
108
  const orderedValueDiffs = [
@@ -29,14 +29,17 @@ export function mapObject(originalObject, mapCallback) {
29
29
  try {
30
30
  let gotAPromise = false;
31
31
  const mappedEntries = getObjectTypedEntries(originalObject)
32
- .map(([originalKey, originalValue]) => {
32
+ .map(([originalKey, originalValue,]) => {
33
33
  const output = mapCallback(originalKey, originalValue, originalObject);
34
34
  if (output instanceof Promise) {
35
35
  gotAPromise = true;
36
36
  return output;
37
37
  }
38
38
  else if (output) {
39
- return [output.key, output.value];
39
+ return [
40
+ output.key,
41
+ output.value,
42
+ ];
40
43
  }
41
44
  else {
42
45
  return undefined;
@@ -54,7 +57,10 @@ export function mapObject(originalObject, mapCallback) {
54
57
  return entry;
55
58
  }
56
59
  else {
57
- return [entry.key, entry.value];
60
+ return [
61
+ entry.key,
62
+ entry.value,
63
+ ];
58
64
  }
59
65
  }, check.isTruthy);
60
66
  resolve(typedObjectFromEntries(entries));
@@ -30,7 +30,7 @@ export function mergeDeep(...inputs) {
30
30
  /** If result isn't an object then we need to make it into one. */
31
31
  result = { ...individualInput };
32
32
  }
33
- Object.entries(individualInput).forEach(([key, value]) => {
33
+ Object.entries(individualInput).forEach(([key, value,]) => {
34
34
  if (!mergeProps[key]) {
35
35
  mergeProps[key] = [];
36
36
  }
@@ -38,7 +38,7 @@ export function mergeDeep(...inputs) {
38
38
  });
39
39
  });
40
40
  if (check.isObject(result)) {
41
- Object.entries(mergeProps).forEach(([key, mergeValues]) => {
41
+ Object.entries(mergeProps).forEach(([key, mergeValues,]) => {
42
42
  const newValue = mergeDeep(...mergeValues);
43
43
  if (newValue === undefined && key in result) {
44
44
  delete result[key];
@@ -22,7 +22,7 @@ export function mergeDefinedProperties(original, ...overrides) {
22
22
  if (!entry) {
23
23
  return;
24
24
  }
25
- getObjectTypedEntries(entry).forEach(([key, value]) => {
25
+ getObjectTypedEntries(entry).forEach(([key, value,]) => {
26
26
  if (value != undefined) {
27
27
  finalObject[key] = value;
28
28
  }
@@ -10,10 +10,16 @@
10
10
  *
11
11
  * mergePropertyArrays(
12
12
  * {
13
- * a: ['a', 'b'],
13
+ * a: [
14
+ * 'a',
15
+ * 'b',
16
+ * ],
14
17
  * },
15
18
  * {
16
- * a: ['c', 'd'],
19
+ * a: [
20
+ * 'c',
21
+ * 'd',
22
+ * ],
17
23
  * },
18
24
  * ); // output is `{a: ['a', 'b', 'c', 'd']}`
19
25
  * ```
@@ -11,10 +11,16 @@ import { getOrSet } from './get-or-set.js';
11
11
  *
12
12
  * mergePropertyArrays(
13
13
  * {
14
- * a: ['a', 'b'],
14
+ * a: [
15
+ * 'a',
16
+ * 'b',
17
+ * ],
15
18
  * },
16
19
  * {
17
- * a: ['c', 'd'],
20
+ * a: [
21
+ * 'c',
22
+ * 'd',
23
+ * ],
18
24
  * },
19
25
  * ); // output is `{a: ['a', 'b', 'c', 'd']}`
20
26
  * ```
@@ -24,7 +30,7 @@ import { getOrSet } from './get-or-set.js';
24
30
  export function mergePropertyArrays(...inputs) {
25
31
  const combined = {};
26
32
  inputs.forEach((input) => {
27
- Object.entries(input).forEach(([key, newArray]) => {
33
+ Object.entries(input).forEach(([key, newArray,]) => {
28
34
  const currentArray = getOrSet(combined, key, () => []);
29
35
  currentArray.push(...newArray);
30
36
  });
@@ -9,7 +9,10 @@ import { getObjectTypedKeys } from '@augment-vir/core';
9
9
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
10
10
  */
11
11
  export function getObjectTypedEntries(input) {
12
- return getObjectTypedKeys(input).map((key) => [key, input[key]]);
12
+ return getObjectTypedKeys(input).map((key) => [
13
+ key,
14
+ input[key],
15
+ ]);
13
16
  }
14
17
  /**
15
18
  * Create an object from an array of entries. This is the same as
@@ -20,7 +20,7 @@ import { getObjectTypedEntries, typedObjectFromEntries } from './object-entries.
20
20
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
21
21
  */
22
22
  export function filterObject(inputObject, callback) {
23
- const filteredEntries = getObjectTypedEntries(inputObject).filter(([key, value]) => {
23
+ const filteredEntries = getObjectTypedEntries(inputObject).filter(([key, value,]) => {
24
24
  return callback(key, value, inputObject);
25
25
  });
26
26
  return typedObjectFromEntries(filteredEntries);
@@ -17,7 +17,10 @@ import { escapeStringForRegExp } from './regexp-string.js';
17
17
  * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
18
18
  */
19
19
  export function addRegExpFlags(originalRegExpOrString, flags) {
20
- const allFlags = removeDuplicateCharacters([typeof originalRegExpOrString === 'string' ? '' : originalRegExpOrString.flags, flags]
20
+ const allFlags = removeDuplicateCharacters([
21
+ typeof originalRegExpOrString === 'string' ? '' : originalRegExpOrString.flags,
22
+ flags,
23
+ ]
21
24
  .join('')
22
25
  .toLowerCase());
23
26
  return setRegExpFlags(originalRegExpOrString, allFlags);
@@ -33,12 +33,16 @@ export function addCommasToNumber(input) {
33
33
  const numericValue = Number(input);
34
34
  const isNegative = numericValue < 0;
35
35
  const stringValue = String(Math.abs(numericValue));
36
- const [digits = '', decimalValues] = stringValue.split('.');
36
+ const [digits = '', decimalValues,] = stringValue.split('.');
37
37
  const decimalString = decimalValues ? `.${decimalValues}` : '';
38
38
  const separated = safeMatch(digits.split('').reverse().join(''), /.{1,3}/g)
39
39
  .reverse()
40
40
  .map((entry) => entry.split('').reverse().join(''));
41
41
  const valueWithCommas = separated.join(',');
42
42
  const negativeMarker = isNegative ? '-' : '';
43
- return [negativeMarker, valueWithCommas, decimalString].join('');
43
+ return [
44
+ negativeMarker,
45
+ valueWithCommas,
46
+ decimalString,
47
+ ].join('');
44
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/common",
3
- "version": "31.9.0",
3
+ "version": "31.9.2",
4
4
  "description": "A collection of augments, helpers types, functions, and classes for any JavaScript environment.",
5
5
  "keywords": [
6
6
  "augment",
@@ -39,24 +39,24 @@
39
39
  "test:web": "virmator --no-deps test web"
40
40
  },
41
41
  "dependencies": {
42
- "@augment-vir/assert": "^31.9.0",
43
- "@augment-vir/core": "^31.9.0",
44
- "@date-vir/duration": "^7.1.2",
42
+ "@augment-vir/assert": "^31.9.2",
43
+ "@augment-vir/core": "^31.9.2",
44
+ "@date-vir/duration": "^7.2.0",
45
45
  "ansi-styles": "^6.2.1",
46
46
  "json5": "^2.2.3",
47
- "type-fest": "^4.33.0",
47
+ "type-fest": "^4.35.0",
48
48
  "typed-event-target": "^4.0.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@web/dev-server-esbuild": "^1.0.3",
52
- "@web/test-runner": "^0.19.0",
51
+ "@web/dev-server-esbuild": "^1.0.4",
52
+ "@web/test-runner": "^0.20.0",
53
53
  "@web/test-runner-commands": "^0.9.0",
54
54
  "@web/test-runner-playwright": "^0.11.0",
55
55
  "@web/test-runner-visual-regression": "^0.10.0",
56
56
  "concurrently": "^9.1.2",
57
57
  "execute-in-browser": "^1.0.4",
58
58
  "istanbul-smart-text-reporter": "^1.1.5",
59
- "typescript": "^5.7.2"
59
+ "typescript": "^5.7.3"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=22"