complete-common 1.3.0 → 2.0.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 (48) hide show
  1. package/dist/functions/array.d.cts +7 -7
  2. package/dist/functions/array.d.mts +7 -7
  3. package/dist/functions/array.d.ts +7 -7
  4. package/dist/functions/array.d.ts.map +1 -1
  5. package/dist/functions/assert.d.cts +12 -0
  6. package/dist/functions/assert.d.mts +12 -0
  7. package/dist/functions/assert.d.ts +12 -0
  8. package/dist/functions/assert.d.ts.map +1 -1
  9. package/dist/functions/enums.d.cts +1 -2
  10. package/dist/functions/enums.d.mts +1 -2
  11. package/dist/functions/enums.d.ts +1 -2
  12. package/dist/functions/enums.d.ts.map +1 -1
  13. package/dist/functions/map.d.cts +6 -2
  14. package/dist/functions/map.d.mts +6 -2
  15. package/dist/functions/map.d.ts +6 -2
  16. package/dist/functions/map.d.ts.map +1 -1
  17. package/dist/functions/object.d.cts +3 -30
  18. package/dist/functions/object.d.mts +3 -30
  19. package/dist/functions/object.d.ts +3 -30
  20. package/dist/functions/object.d.ts.map +1 -1
  21. package/dist/functions/set.d.cts +6 -26
  22. package/dist/functions/set.d.mts +6 -26
  23. package/dist/functions/set.d.ts +6 -26
  24. package/dist/functions/set.d.ts.map +1 -1
  25. package/dist/functions/sort.d.cts +1 -1
  26. package/dist/functions/sort.d.mts +1 -1
  27. package/dist/functions/sort.d.ts +1 -1
  28. package/dist/functions/sort.d.ts.map +1 -1
  29. package/dist/index.cjs +34 -44
  30. package/dist/index.d.cts +1 -0
  31. package/dist/index.d.mts +1 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.mjs +34 -41
  35. package/dist/types/TranspiledEnum.d.cts +3 -0
  36. package/dist/types/TranspiledEnum.d.mts +3 -0
  37. package/dist/types/TranspiledEnum.d.ts +3 -0
  38. package/dist/types/TranspiledEnum.d.ts.map +1 -0
  39. package/package.json +5 -5
  40. package/src/functions/array.ts +8 -13
  41. package/src/functions/assert.ts +23 -0
  42. package/src/functions/enums.ts +1 -1
  43. package/src/functions/map.ts +8 -5
  44. package/src/functions/object.ts +3 -44
  45. package/src/functions/set.ts +8 -41
  46. package/src/functions/sort.ts +3 -2
  47. package/src/index.ts +1 -0
  48. package/src/types/TranspiledEnum.ts +2 -0
@@ -8,7 +8,7 @@ import type { WidenLiteral } from "../index.js";
8
8
  * Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
9
9
  * copied (using the spread operator).
10
10
  */
11
- export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): T[][];
11
+ export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): readonly T[][];
12
12
  /**
13
13
  * Helper function for determining if two arrays contain the exact same elements. Note that this
14
14
  * only performs a shallow comparison.
@@ -21,7 +21,7 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
21
21
  *
22
22
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
23
23
  */
24
- export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): T[];
24
+ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
25
25
  /**
26
26
  * Removes the specified element(s) from the array. If the specified element(s) are not found in the
27
27
  * array, this function will do nothing.
@@ -34,9 +34,9 @@ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsT
34
34
  *
35
35
  * @returns The removed elements. This will be an empty array if no elements were removed.
36
36
  */
37
- export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): T[];
37
+ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): readonly T[];
38
38
  /** Helper function to remove all of the elements in an array in-place. */
39
- export declare function emptyArray<T>(array: T[]): void;
39
+ export declare function emptyArray(array: unknown[]): void;
40
40
  /**
41
41
  * Helper function to perform a filter and a map at the same time. Similar to `Array.map`, provide a
42
42
  * function that transforms a value, but return `undefined` if the value should be skipped. (Thus,
@@ -48,7 +48,7 @@ export declare function emptyArray<T>(array: T[]): void;
48
48
  * This is named `filterMap` after the Rust function:
49
49
  * https://doc.rust-lang.org/std/iter/struct.FilterMap.html
50
50
  */
51
- export declare function filterMap<OldT, NewT>(array: readonly OldT[], func: (element: OldT) => NewT | undefined): NewT[];
51
+ export declare function filterMap<OldT, NewT>(array: readonly OldT[], func: (element: OldT) => NewT | undefined): readonly NewT[];
52
52
  /**
53
53
  * Helper function to get a random element from the provided array.
54
54
  *
@@ -66,7 +66,7 @@ export declare function getRandomArrayElement<T>(array: readonly T[], exceptions
66
66
  * @param exceptions Optional. An array of indexes that will be skipped over when getting the random
67
67
  * index. Default is an empty array.
68
68
  */
69
- export declare function getRandomArrayIndex<T>(array: readonly T[], exceptions?: readonly number[]): number;
69
+ export declare function getRandomArrayIndex(array: readonly unknown[], exceptions?: readonly number[]): number;
70
70
  /**
71
71
  * Similar to the `Array.includes` method, but works on a widened version of the array.
72
72
  *
@@ -77,7 +77,7 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
77
77
  /** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
78
78
  export declare function isArray(arg: unknown): arg is unknown[];
79
79
  /** Initializes an array with all elements containing the specified default value. */
80
- export declare function newArray<T>(length: number, value: T): T[];
80
+ export declare function newArray<T>(length: number, value: T): readonly T[];
81
81
  /** Helper function to sum every value in an array together. */
82
82
  export declare function sumArray(array: readonly number[]): number;
83
83
  //# sourceMappingURL=array.d.ts.map
@@ -8,7 +8,7 @@ import type { WidenLiteral } from "../index.js";
8
8
  * Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
9
9
  * copied (using the spread operator).
10
10
  */
11
- export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): T[][];
11
+ export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): readonly T[][];
12
12
  /**
13
13
  * Helper function for determining if two arrays contain the exact same elements. Note that this
14
14
  * only performs a shallow comparison.
@@ -21,7 +21,7 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
21
21
  *
22
22
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
23
23
  */
24
- export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): T[];
24
+ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
25
25
  /**
26
26
  * Removes the specified element(s) from the array. If the specified element(s) are not found in the
27
27
  * array, this function will do nothing.
@@ -34,9 +34,9 @@ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsT
34
34
  *
35
35
  * @returns The removed elements. This will be an empty array if no elements were removed.
36
36
  */
37
- export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): T[];
37
+ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): readonly T[];
38
38
  /** Helper function to remove all of the elements in an array in-place. */
39
- export declare function emptyArray<T>(array: T[]): void;
39
+ export declare function emptyArray(array: unknown[]): void;
40
40
  /**
41
41
  * Helper function to perform a filter and a map at the same time. Similar to `Array.map`, provide a
42
42
  * function that transforms a value, but return `undefined` if the value should be skipped. (Thus,
@@ -48,7 +48,7 @@ export declare function emptyArray<T>(array: T[]): void;
48
48
  * This is named `filterMap` after the Rust function:
49
49
  * https://doc.rust-lang.org/std/iter/struct.FilterMap.html
50
50
  */
51
- export declare function filterMap<OldT, NewT>(array: readonly OldT[], func: (element: OldT) => NewT | undefined): NewT[];
51
+ export declare function filterMap<OldT, NewT>(array: readonly OldT[], func: (element: OldT) => NewT | undefined): readonly NewT[];
52
52
  /**
53
53
  * Helper function to get a random element from the provided array.
54
54
  *
@@ -66,7 +66,7 @@ export declare function getRandomArrayElement<T>(array: readonly T[], exceptions
66
66
  * @param exceptions Optional. An array of indexes that will be skipped over when getting the random
67
67
  * index. Default is an empty array.
68
68
  */
69
- export declare function getRandomArrayIndex<T>(array: readonly T[], exceptions?: readonly number[]): number;
69
+ export declare function getRandomArrayIndex(array: readonly unknown[], exceptions?: readonly number[]): number;
70
70
  /**
71
71
  * Similar to the `Array.includes` method, but works on a widened version of the array.
72
72
  *
@@ -77,7 +77,7 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
77
77
  /** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
78
78
  export declare function isArray(arg: unknown): arg is unknown[];
79
79
  /** Initializes an array with all elements containing the specified default value. */
80
- export declare function newArray<T>(length: number, value: T): T[];
80
+ export declare function newArray<T>(length: number, value: T): readonly T[];
81
81
  /** Helper function to sum every value in an array together. */
82
82
  export declare function sumArray(array: readonly number[]): number;
83
83
  //# sourceMappingURL=array.d.ts.map
@@ -8,7 +8,7 @@ import type { WidenLiteral } from "../index.js";
8
8
  * Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
9
9
  * copied (using the spread operator).
10
10
  */
11
- export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): T[][];
11
+ export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): readonly T[][];
12
12
  /**
13
13
  * Helper function for determining if two arrays contain the exact same elements. Note that this
14
14
  * only performs a shallow comparison.
@@ -21,7 +21,7 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
21
21
  *
22
22
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
23
23
  */
24
- export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): T[];
24
+ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
25
25
  /**
26
26
  * Removes the specified element(s) from the array. If the specified element(s) are not found in the
27
27
  * array, this function will do nothing.
@@ -34,9 +34,9 @@ export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsT
34
34
  *
35
35
  * @returns The removed elements. This will be an empty array if no elements were removed.
36
36
  */
37
- export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): T[];
37
+ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: readonly T[]): readonly T[];
38
38
  /** Helper function to remove all of the elements in an array in-place. */
39
- export declare function emptyArray<T>(array: T[]): void;
39
+ export declare function emptyArray(array: unknown[]): void;
40
40
  /**
41
41
  * Helper function to perform a filter and a map at the same time. Similar to `Array.map`, provide a
42
42
  * function that transforms a value, but return `undefined` if the value should be skipped. (Thus,
@@ -48,7 +48,7 @@ export declare function emptyArray<T>(array: T[]): void;
48
48
  * This is named `filterMap` after the Rust function:
49
49
  * https://doc.rust-lang.org/std/iter/struct.FilterMap.html
50
50
  */
51
- export declare function filterMap<OldT, NewT>(array: readonly OldT[], func: (element: OldT) => NewT | undefined): NewT[];
51
+ export declare function filterMap<OldT, NewT>(array: readonly OldT[], func: (element: OldT) => NewT | undefined): readonly NewT[];
52
52
  /**
53
53
  * Helper function to get a random element from the provided array.
54
54
  *
@@ -66,7 +66,7 @@ export declare function getRandomArrayElement<T>(array: readonly T[], exceptions
66
66
  * @param exceptions Optional. An array of indexes that will be skipped over when getting the random
67
67
  * index. Default is an empty array.
68
68
  */
69
- export declare function getRandomArrayIndex<T>(array: readonly T[], exceptions?: readonly number[]): number;
69
+ export declare function getRandomArrayIndex(array: readonly unknown[], exceptions?: readonly number[]): number;
70
70
  /**
71
71
  * Similar to the `Array.includes` method, but works on a widened version of the array.
72
72
  *
@@ -77,7 +77,7 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
77
77
  /** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
78
78
  export declare function isArray(arg: unknown): arg is unknown[];
79
79
  /** Initializes an array with all elements containing the specified default value. */
80
- export declare function newArray<T>(length: number, value: T): T[];
80
+ export declare function newArray<T>(length: number, value: T): readonly T[];
81
81
  /** Helper function to sum every value in an array together. */
82
82
  export declare function sumArray(array: readonly number[]): number;
83
83
  //# sourceMappingURL=array.d.ts.map
@@ -1 +1 @@
1
- {"version":3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
7
  /** Helper function to throw an error if the provided value is not an array. */
7
8
  export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
8
9
  /** Helper function to throw an error if the provided value is not a boolean. */
@@ -15,6 +16,17 @@ export declare function assertBoolean(value: unknown, msg: string): asserts valu
15
16
  export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends [T] ? [string] : [
16
17
  "The assertion is useless because the provided value does not contain undefined."
17
18
  ]): asserts value is Exclude<T, undefined>;
19
+ /**
20
+ * Helper function to throw an error if the provided value is not contained within an enum.
21
+ *
22
+ * @param value The value to check.
23
+ * @param transpiledEnum The enum to check against.
24
+ * @param msg The error message to throw if the check fails.
25
+ * @param set Optional. A set that contains all of the values of an enum. If provided, this function
26
+ * will check for existence using the set (instead of the enum itself). Using a set
27
+ * should be more performant for enums with around 52 or more elements.
28
+ */
29
+ export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
18
30
  /**
19
31
  * Helper function to throw an error if the provided value is equal to `null`.
20
32
  *
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ import type { TranspiledEnum } from "../types/TranspiledEnum.js";
6
7
  /** Helper function to throw an error if the provided value is not an array. */
7
8
  export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
8
9
  /** Helper function to throw an error if the provided value is not a boolean. */
@@ -15,6 +16,17 @@ export declare function assertBoolean(value: unknown, msg: string): asserts valu
15
16
  export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends [T] ? [string] : [
16
17
  "The assertion is useless because the provided value does not contain undefined."
17
18
  ]): asserts value is Exclude<T, undefined>;
19
+ /**
20
+ * Helper function to throw an error if the provided value is not contained within an enum.
21
+ *
22
+ * @param value The value to check.
23
+ * @param transpiledEnum The enum to check against.
24
+ * @param msg The error message to throw if the check fails.
25
+ * @param set Optional. A set that contains all of the values of an enum. If provided, this function
26
+ * will check for existence using the set (instead of the enum itself). Using a set
27
+ * should be more performant for enums with around 52 or more elements.
28
+ */
29
+ export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
18
30
  /**
19
31
  * Helper function to throw an error if the provided value is equal to `null`.
20
32
  *
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ import type { TranspiledEnum } from "../types/TranspiledEnum.js";
6
7
  /** Helper function to throw an error if the provided value is not an array. */
7
8
  export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
8
9
  /** Helper function to throw an error if the provided value is not a boolean. */
@@ -15,6 +16,17 @@ export declare function assertBoolean(value: unknown, msg: string): asserts valu
15
16
  export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends [T] ? [string] : [
16
17
  "The assertion is useless because the provided value does not contain undefined."
17
18
  ]): asserts value is Exclude<T, undefined>;
19
+ /**
20
+ * Helper function to throw an error if the provided value is not contained within an enum.
21
+ *
22
+ * @param value The value to check.
23
+ * @param transpiledEnum The enum to check against.
24
+ * @param msg The error message to throw if the check fails.
25
+ * @param set Optional. A set that contains all of the values of an enum. If provided, this function
26
+ * will check for existence using the set (instead of the enum itself). Using a set
27
+ * should be more performant for enums with around 52 or more elements.
28
+ */
29
+ export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
18
30
  /**
19
31
  * Helper function to throw an error if the provided value is equal to `null`.
20
32
  *
@@ -1 +1 @@
1
- {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/functions/assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,+EAA+E;AAC/E,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE,CAI5B;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,GAA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AAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI1C;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,MAAM,CAIzB"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- type TranspiledEnum = Record<string, string | number>;
6
+ import type { TranspiledEnum } from "../types/TranspiledEnum.js";
7
7
  /**
8
8
  * Helper function to get the entries of an enum.
9
9
  *
@@ -69,5 +69,4 @@ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>,
69
69
  * should be more performant for enums with around 52 or more elements.
70
70
  */
71
71
  export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<string | number>): value is T[keyof T];
72
- export {};
73
72
  //# sourceMappingURL=enums.d.ts.map
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- type TranspiledEnum = Record<string, string | number>;
6
+ import type { TranspiledEnum } from "../types/TranspiledEnum.js";
7
7
  /**
8
8
  * Helper function to get the entries of an enum.
9
9
  *
@@ -69,5 +69,4 @@ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>,
69
69
  * should be more performant for enums with around 52 or more elements.
70
70
  */
71
71
  export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<string | number>): value is T[keyof T];
72
- export {};
73
72
  //# sourceMappingURL=enums.d.ts.map
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- type TranspiledEnum = Record<string, string | number>;
6
+ import type { TranspiledEnum } from "../types/TranspiledEnum.js";
7
7
  /**
8
8
  * Helper function to get the entries of an enum.
9
9
  *
@@ -69,5 +69,4 @@ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>,
69
69
  * should be more performant for enums with around 52 or more elements.
70
70
  */
71
71
  export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<string | number>): value is T[keyof T];
72
- export {};
73
72
  //# sourceMappingURL=enums.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/functions/enums.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,cAAc,EACrD,cAAc,EAAE,CAAC,GAChB,aAAa,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CASjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,MAAM,EAAE,CAG7E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,EACpD,cAAc,EAAE,CAAC,GAChB,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAG3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CAEpC,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG;AAEZ;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAClD,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,cAAc,EAAE,CAAC,EACjB,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,GACjC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAOrB"}
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/functions/enums.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,cAAc,EACrD,cAAc,EAAE,CAAC,GAChB,aAAa,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CASjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,MAAM,EAAE,CAG7E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,EACpD,cAAc,EAAE,CAAC,GAChB,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAG3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CAEpC,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG;AAEZ;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAClD,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,cAAc,EAAE,CAAC,EACjB,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,GACjC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAOrB"}
@@ -13,12 +13,16 @@
13
13
  * If you want to perform a filter and a map at the same time on an array, use the `filterMap`
14
14
  * helper function instead.
15
15
  */
16
- export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V[];
16
+ export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): readonly V[];
17
17
  /**
18
18
  * Helper function to find a value in a `Map`. Similar to the `Array.find` method, but works for
19
19
  * maps.
20
20
  *
21
21
  * This is efficient such that it avoids converting the map values into an array.
22
+ *
23
+ * @param map The map to search through.
24
+ * @param predicate Function that tests each value for a condition.
25
+ * @returns The first value that satisfies the predicate, or undefined if no values satisfy.
22
26
  */
23
- export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V | undefined;
27
+ export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V, key: K, map: ReadonlyMap<K, V>) => boolean): V | undefined;
24
28
  //# sourceMappingURL=map.d.ts.map
@@ -13,12 +13,16 @@
13
13
  * If you want to perform a filter and a map at the same time on an array, use the `filterMap`
14
14
  * helper function instead.
15
15
  */
16
- export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V[];
16
+ export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): readonly V[];
17
17
  /**
18
18
  * Helper function to find a value in a `Map`. Similar to the `Array.find` method, but works for
19
19
  * maps.
20
20
  *
21
21
  * This is efficient such that it avoids converting the map values into an array.
22
+ *
23
+ * @param map The map to search through.
24
+ * @param predicate Function that tests each value for a condition.
25
+ * @returns The first value that satisfies the predicate, or undefined if no values satisfy.
22
26
  */
23
- export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V | undefined;
27
+ export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V, key: K, map: ReadonlyMap<K, V>) => boolean): V | undefined;
24
28
  //# sourceMappingURL=map.d.ts.map
@@ -13,12 +13,16 @@
13
13
  * If you want to perform a filter and a map at the same time on an array, use the `filterMap`
14
14
  * helper function instead.
15
15
  */
16
- export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V[];
16
+ export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): readonly V[];
17
17
  /**
18
18
  * Helper function to find a value in a `Map`. Similar to the `Array.find` method, but works for
19
19
  * maps.
20
20
  *
21
21
  * This is efficient such that it avoids converting the map values into an array.
22
+ *
23
+ * @param map The map to search through.
24
+ * @param predicate Function that tests each value for a condition.
25
+ * @returns The first value that satisfies the predicate, or undefined if no values satisfy.
22
26
  */
23
- export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V | undefined;
27
+ export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V, key: K, map: ReadonlyMap<K, V>) => boolean): V | undefined;
24
28
  //# sourceMappingURL=map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AAEH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,CAAC,EAAE,CAWL;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,CAAC,GAAG,SAAS,CASf"}
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,SAAS,CAAC,EAAE,CAWd;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,GAC/D,CAAC,GAAG,SAAS,CASf"}
@@ -10,7 +10,7 @@ import type { ReadonlyRecord } from "../types/ReadonlyRecord.js";
10
10
  *
11
11
  * This is efficient such that it avoids converting the object values into an array.
12
12
  */
13
- export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): V[];
13
+ export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): readonly V[];
14
14
  /**
15
15
  * Helper function to convert an object to a map.
16
16
  *
@@ -21,40 +21,13 @@ export declare function objectFilter<K extends string | number | symbol, V>(obje
21
21
  *
22
22
  * Note that the converted map will only have string keys, due to the nature of JavaScript objects
23
23
  * only having string keys under the hood.
24
- *
25
- * Also see the `objectToReadonlyMap` function.
26
24
  */
27
- export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): Map<K, V>;
28
- /**
29
- * Helper function to convert an object to a read-only map.
30
- *
31
- * This is useful when you need to construct a type safe object with the `satisfies` operator, but
32
- * then later on you need to query it in a way where you expect the return value to be T or
33
- * undefined. In this situation, by converting the object to a map, you can avoid unsafe type
34
- * assertions.
35
- *
36
- * Note that the converted map will only have string keys, due to the nature of JavaScript objects
37
- * only having string keys under the hood.
38
- *
39
- * Also see the `objectToMap` function.
40
- */
41
- export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
25
+ export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
42
26
  /**
43
27
  * Helper function to convert an object to a reverse map.
44
28
  *
45
29
  * Note that the converted map will only have string keys, due to the nature of JavaScript objects
46
30
  * only having string keys under the hood.
47
- *
48
- * Also see the `objectToReverseReadonlyMap` function.
49
- */
50
- export declare function objectToReverseMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): Map<V, K>;
51
- /**
52
- * Helper function to convert an object to a reverse read-only map.
53
- *
54
- * Note that the converted map will only have string keys, due to the nature of JavaScript objects
55
- * only having string keys under the hood.
56
- *
57
- * Also see the `objectToReverseMap` function.
58
31
  */
59
- export declare function objectToReverseReadonlyMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
32
+ export declare function objectToReverseMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
60
33
  //# sourceMappingURL=object.d.ts.map
@@ -10,7 +10,7 @@ import type { ReadonlyRecord } from "../types/ReadonlyRecord.js";
10
10
  *
11
11
  * This is efficient such that it avoids converting the object values into an array.
12
12
  */
13
- export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): V[];
13
+ export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): readonly V[];
14
14
  /**
15
15
  * Helper function to convert an object to a map.
16
16
  *
@@ -21,40 +21,13 @@ export declare function objectFilter<K extends string | number | symbol, V>(obje
21
21
  *
22
22
  * Note that the converted map will only have string keys, due to the nature of JavaScript objects
23
23
  * only having string keys under the hood.
24
- *
25
- * Also see the `objectToReadonlyMap` function.
26
24
  */
27
- export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): Map<K, V>;
28
- /**
29
- * Helper function to convert an object to a read-only map.
30
- *
31
- * This is useful when you need to construct a type safe object with the `satisfies` operator, but
32
- * then later on you need to query it in a way where you expect the return value to be T or
33
- * undefined. In this situation, by converting the object to a map, you can avoid unsafe type
34
- * assertions.
35
- *
36
- * Note that the converted map will only have string keys, due to the nature of JavaScript objects
37
- * only having string keys under the hood.
38
- *
39
- * Also see the `objectToMap` function.
40
- */
41
- export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
25
+ export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
42
26
  /**
43
27
  * Helper function to convert an object to a reverse map.
44
28
  *
45
29
  * Note that the converted map will only have string keys, due to the nature of JavaScript objects
46
30
  * only having string keys under the hood.
47
- *
48
- * Also see the `objectToReverseReadonlyMap` function.
49
- */
50
- export declare function objectToReverseMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): Map<V, K>;
51
- /**
52
- * Helper function to convert an object to a reverse read-only map.
53
- *
54
- * Note that the converted map will only have string keys, due to the nature of JavaScript objects
55
- * only having string keys under the hood.
56
- *
57
- * Also see the `objectToReverseMap` function.
58
31
  */
59
- export declare function objectToReverseReadonlyMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
32
+ export declare function objectToReverseMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
60
33
  //# sourceMappingURL=object.d.ts.map
@@ -10,7 +10,7 @@ import type { ReadonlyRecord } from "../types/ReadonlyRecord.js";
10
10
  *
11
11
  * This is efficient such that it avoids converting the object values into an array.
12
12
  */
13
- export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): V[];
13
+ export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): readonly V[];
14
14
  /**
15
15
  * Helper function to convert an object to a map.
16
16
  *
@@ -21,40 +21,13 @@ export declare function objectFilter<K extends string | number | symbol, V>(obje
21
21
  *
22
22
  * Note that the converted map will only have string keys, due to the nature of JavaScript objects
23
23
  * only having string keys under the hood.
24
- *
25
- * Also see the `objectToReadonlyMap` function.
26
24
  */
27
- export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): Map<K, V>;
28
- /**
29
- * Helper function to convert an object to a read-only map.
30
- *
31
- * This is useful when you need to construct a type safe object with the `satisfies` operator, but
32
- * then later on you need to query it in a way where you expect the return value to be T or
33
- * undefined. In this situation, by converting the object to a map, you can avoid unsafe type
34
- * assertions.
35
- *
36
- * Note that the converted map will only have string keys, due to the nature of JavaScript objects
37
- * only having string keys under the hood.
38
- *
39
- * Also see the `objectToMap` function.
40
- */
41
- export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
25
+ export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
42
26
  /**
43
27
  * Helper function to convert an object to a reverse map.
44
28
  *
45
29
  * Note that the converted map will only have string keys, due to the nature of JavaScript objects
46
30
  * only having string keys under the hood.
47
- *
48
- * Also see the `objectToReverseReadonlyMap` function.
49
- */
50
- export declare function objectToReverseMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): Map<V, K>;
51
- /**
52
- * Helper function to convert an object to a reverse read-only map.
53
- *
54
- * Note that the converted map will only have string keys, due to the nature of JavaScript objects
55
- * only having string keys under the hood.
56
- *
57
- * Also see the `objectToReverseMap` function.
58
31
  */
59
- export declare function objectToReverseReadonlyMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
32
+ export declare function objectToReverseMap<K extends string | number | symbol, V extends string | number | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
60
33
  //# sourceMappingURL=object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/functions/object.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EAChE,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5B,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,CAAC,EAAE,CAaL;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAA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G;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EAC/D,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAQnB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAQzC"}
@@ -16,33 +16,13 @@ export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: ReadonlyA
16
16
  *
17
17
  * This function is variadic, meaning that you can specify N sets.
18
18
  */
19
- export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>): Set<T>;
19
+ export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>): ReadonlySet<T>;
20
20
  /** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
21
- export declare function copySet<T>(oldSet: ReadonlySet<T>): Set<T>;
22
- /**
23
- * Helper function to convert the keys of an object to a read-only set.
24
- *
25
- * Also see the `objectKeysToSet` function.
26
- */
27
- export declare function objectKeysToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
28
- /**
29
- * Helper function to convert the keys of an object to a set.
30
- *
31
- * Also see the `objectKeysToReadonlySet` function.
32
- */
33
- export declare function objectKeysToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<K>;
34
- /**
35
- * Helper function to convert the values of an object to a read-only set.
36
- *
37
- * Also see the `objectValuesToSet` function.
38
- */
39
- export declare function objectValuesToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
40
- /**
41
- * Helper function to convert the values of an object to a set.
42
- *
43
- * Also see the `objectValuesToReadonlySet` function.
44
- */
45
- export declare function objectValuesToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<V>;
21
+ export declare function copySet<T>(oldSet: ReadonlySet<T>): ReadonlySet<T>;
22
+ /** Helper function to convert the keys of an object to a set. */
23
+ export declare function objectKeysToSet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
24
+ /** Helper function to convert the values of an object to a set. */
25
+ export declare function objectValuesToSet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
46
26
  /**
47
27
  * Helper function to add one or more elements to a set at once without having to repeatedly call
48
28
  * the `Set.add` method.