complete-common 1.4.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.
- package/dist/functions/array.d.cts +5 -5
- package/dist/functions/array.d.mts +5 -5
- package/dist/functions/array.d.ts +5 -5
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/assert.d.cts +1 -1
- package/dist/functions/assert.d.mts +1 -1
- package/dist/functions/assert.d.ts +1 -1
- package/dist/functions/assert.d.ts.map +1 -1
- package/dist/functions/enums.d.cts +1 -1
- package/dist/functions/enums.d.mts +1 -1
- package/dist/functions/enums.d.ts +1 -1
- package/dist/functions/enums.d.ts.map +1 -1
- package/dist/functions/map.d.cts +6 -2
- package/dist/functions/map.d.mts +6 -2
- package/dist/functions/map.d.ts +6 -2
- package/dist/functions/map.d.ts.map +1 -1
- package/dist/functions/object.d.cts +3 -30
- package/dist/functions/object.d.mts +3 -30
- package/dist/functions/object.d.ts +3 -30
- package/dist/functions/object.d.ts.map +1 -1
- package/dist/functions/set.d.cts +6 -26
- package/dist/functions/set.d.mts +6 -26
- package/dist/functions/set.d.ts +6 -26
- package/dist/functions/set.d.ts.map +1 -1
- package/dist/functions/sort.d.cts +1 -1
- package/dist/functions/sort.d.mts +1 -1
- package/dist/functions/sort.d.ts +1 -1
- package/dist/functions/sort.d.ts.map +1 -1
- package/dist/index.cjs +2 -18
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +3 -15
- package/dist/types/TranspiledEnum.d.cts +3 -0
- package/dist/types/TranspiledEnum.d.mts +3 -0
- package/dist/types/TranspiledEnum.d.ts +3 -0
- package/dist/types/TranspiledEnum.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/functions/array.ts +5 -10
- package/src/functions/assert.ts +1 -1
- package/src/functions/enums.ts +1 -1
- package/src/functions/map.ts +8 -5
- package/src/functions/object.ts +3 -44
- package/src/functions/set.ts +8 -41
- package/src/functions/sort.ts +3 -2
- package/src/index.ts +1 -0
- 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,7 +34,7 @@ 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
39
|
export declare function emptyArray(array: unknown[]): void;
|
|
40
40
|
/**
|
|
@@ -48,7 +48,7 @@ export declare function emptyArray(array: unknown[]): 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
|
*
|
|
@@ -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,7 +34,7 @@ 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
39
|
export declare function emptyArray(array: unknown[]): void;
|
|
40
40
|
/**
|
|
@@ -48,7 +48,7 @@ export declare function emptyArray(array: unknown[]): 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
|
*
|
|
@@ -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,7 +34,7 @@ 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
39
|
export declare function emptyArray(array: unknown[]): void;
|
|
40
40
|
/**
|
|
@@ -48,7 +48,7 @@ export declare function emptyArray(array: unknown[]): 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
|
*
|
|
@@ -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,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD;;;GAGG;
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GACjC,SAAS,CAAC,EAAE,EAAE,CAQhB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,OAAO,CAST;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,SAAS,CAAC,EAAE,EAC3B,GAAG,gBAAgB,EAAE,SAAS,CAAC,EAAE,GAChC,SAAS,CAAC,EAAE,CAWd;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAElC,KAAK,EAAE,CAAC,EAAE,EACV,GAAG,gBAAgB,EAAE,SAAS,CAAC,EAAE,GAChC,SAAS,CAAC,EAAE,CAYd;AAED,0EAA0E;AAE1E,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAEjD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAClC,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,GAAG,SAAS,GACxC,SAAS,IAAI,EAAE,CAWjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,UAAU,GAAE,SAAS,CAAC,EAAO,GAC5B,CAAC,CAiBH;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,UAAU,GAAE,SAAS,MAAM,EAAO,GACjC,MAAM,CAQR;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,YAAY,SAAS,YAAY,CAAC,CAAC,CAAC,EAC9D,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC,GAC7B,aAAa,IAAI,YAAY,CAG/B;AAED,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,EAAE,CAEtD;AAED,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAElE;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEzD"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { TranspiledEnum } from "
|
|
6
|
+
import type { TranspiledEnum } from "../types/TranspiledEnum.js";
|
|
7
7
|
/** Helper function to throw an error if the provided value is not an array. */
|
|
8
8
|
export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
|
|
9
9
|
/** Helper function to throw an error if the provided value is not a boolean. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { TranspiledEnum } from "
|
|
6
|
+
import type { TranspiledEnum } from "../types/TranspiledEnum.js";
|
|
7
7
|
/** Helper function to throw an error if the provided value is not an array. */
|
|
8
8
|
export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
|
|
9
9
|
/** Helper function to throw an error if the provided value is not a boolean. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { TranspiledEnum } from "
|
|
6
|
+
import type { TranspiledEnum } from "../types/TranspiledEnum.js";
|
|
7
7
|
/** Helper function to throw an error if the provided value is not an array. */
|
|
8
8
|
export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
|
|
9
9
|
/** Helper function to throw an error if the provided value is not a boolean. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/functions/assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/functions/assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE,+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,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,CAI1B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAC7B,CAAC,MAAM,CAAC,GACR;IACE,iFAAiF;CAClF,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAIxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EACtD,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,cAAc,EAAE,CAAC,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,GACjC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAI7B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GACxB,CAAC,MAAM,CAAC,GACR;IACE,4EAA4E;CAC7E,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAInC;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,MAAM,CAIzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,MAAM,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/functions/enums.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,
|
|
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"}
|
package/dist/functions/map.d.cts
CHANGED
|
@@ -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
|
package/dist/functions/map.d.mts
CHANGED
|
@@ -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
|
package/dist/functions/map.d.ts
CHANGED
|
@@ -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;
|
|
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>):
|
|
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
|
|
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>):
|
|
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
|
|
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>):
|
|
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
|
|
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;
|
|
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;AACH,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,SAAS,CAAC,EAAE,CAad;AAED;;;;;;;;;;GAUG;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"}
|
package/dist/functions/set.d.cts
CHANGED
|
@@ -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>>):
|
|
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>):
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
package/dist/functions/set.d.mts
CHANGED
|
@@ -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>>):
|
|
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>):
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
package/dist/functions/set.d.ts
CHANGED
|
@@ -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>>):
|
|
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>):
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/functions/set.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAE5B,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC1C,IAAI,CAMN;AAED;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/functions/set.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAE5B,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC1C,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrC,WAAW,CAAC,CAAC,CAAC,CAShB;AAED,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAOjE;AAED,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACnE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,WAAW,CAAC,CAAC,CAAC,CAQhB;AAED,mEAAmE;AACnE,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACrE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,WAAW,CAAC,CAAC,CAAC,CAQhB;AAED;;;;;GAKG;AAEH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAItE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,GAAG,QAAQ,EAAE,SAAS,CAAC,EAAE,GACxB,OAAO,CAET"}
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* From:
|
|
11
11
|
* https://stackoverflow.com/questions/8996963/how-to-perform-case-insensitive-sorting-array-of-string-in-javascript
|
|
12
12
|
*/
|
|
13
|
-
export declare function sortCaseInsensitive(array: readonly string[]): string[];
|
|
13
|
+
export declare function sortCaseInsensitive(array: readonly string[]): readonly string[];
|
|
14
14
|
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* From:
|
|
11
11
|
* https://stackoverflow.com/questions/8996963/how-to-perform-case-insensitive-sorting-array-of-string-in-javascript
|
|
12
12
|
*/
|
|
13
|
-
export declare function sortCaseInsensitive(array: readonly string[]): string[];
|
|
13
|
+
export declare function sortCaseInsensitive(array: readonly string[]): readonly string[];
|
|
14
14
|
//# sourceMappingURL=sort.d.ts.map
|
package/dist/functions/sort.d.ts
CHANGED
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* From:
|
|
11
11
|
* https://stackoverflow.com/questions/8996963/how-to-perform-case-insensitive-sorting-array-of-string-in-javascript
|
|
12
12
|
*/
|
|
13
|
-
export declare function sortCaseInsensitive(array: readonly string[]): string[];
|
|
13
|
+
export declare function sortCaseInsensitive(array: readonly string[]): readonly string[];
|
|
14
14
|
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/functions/sort.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/functions/sort.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,SAAS,MAAM,EAAE,CASnB"}
|
package/dist/index.cjs
CHANGED
|
@@ -192,8 +192,8 @@ function mapFilter(map, predicate) {
|
|
|
192
192
|
return array;
|
|
193
193
|
}
|
|
194
194
|
function mapFind(map, predicate) {
|
|
195
|
-
for (const value of map
|
|
196
|
-
const match = predicate(value);
|
|
195
|
+
for (const [key, value] of map) {
|
|
196
|
+
const match = predicate(value, key, map);
|
|
197
197
|
if (match) {
|
|
198
198
|
return value;
|
|
199
199
|
}
|
|
@@ -223,9 +223,6 @@ function objectToMap(object) {
|
|
|
223
223
|
}
|
|
224
224
|
return map;
|
|
225
225
|
}
|
|
226
|
-
function objectToReadonlyMap(object) {
|
|
227
|
-
return objectToMap(object);
|
|
228
|
-
}
|
|
229
226
|
function objectToReverseMap(object) {
|
|
230
227
|
const map = /* @__PURE__ */ new Map();
|
|
231
228
|
for (const [key, value] of Object.entries(object)) {
|
|
@@ -233,9 +230,6 @@ function objectToReverseMap(object) {
|
|
|
233
230
|
}
|
|
234
231
|
return map;
|
|
235
232
|
}
|
|
236
|
-
function objectToReverseReadonlyMap(object) {
|
|
237
|
-
return objectToReverseMap(object);
|
|
238
|
-
}
|
|
239
233
|
|
|
240
234
|
function addSetsToSet(mainSet, ...setsToAdd) {
|
|
241
235
|
for (const set of setsToAdd) {
|
|
@@ -260,9 +254,6 @@ function copySet(oldSet) {
|
|
|
260
254
|
}
|
|
261
255
|
return newSet;
|
|
262
256
|
}
|
|
263
|
-
function objectKeysToReadonlySet(object) {
|
|
264
|
-
return objectKeysToSet(object);
|
|
265
|
-
}
|
|
266
257
|
function objectKeysToSet(object) {
|
|
267
258
|
const set = /* @__PURE__ */ new Set();
|
|
268
259
|
for (const key of Object.keys(object)) {
|
|
@@ -270,9 +261,6 @@ function objectKeysToSet(object) {
|
|
|
270
261
|
}
|
|
271
262
|
return set;
|
|
272
263
|
}
|
|
273
|
-
function objectValuesToReadonlySet(object) {
|
|
274
|
-
return objectValuesToSet(object);
|
|
275
|
-
}
|
|
276
264
|
function objectValuesToSet(object) {
|
|
277
265
|
const set = /* @__PURE__ */ new Set();
|
|
278
266
|
for (const key of Object.values(object)) {
|
|
@@ -564,13 +552,9 @@ exports.newArray = newArray;
|
|
|
564
552
|
exports.noop = noop;
|
|
565
553
|
exports.normalizeString = normalizeString;
|
|
566
554
|
exports.objectFilter = objectFilter;
|
|
567
|
-
exports.objectKeysToReadonlySet = objectKeysToReadonlySet;
|
|
568
555
|
exports.objectKeysToSet = objectKeysToSet;
|
|
569
556
|
exports.objectToMap = objectToMap;
|
|
570
|
-
exports.objectToReadonlyMap = objectToReadonlyMap;
|
|
571
557
|
exports.objectToReverseMap = objectToReverseMap;
|
|
572
|
-
exports.objectToReverseReadonlyMap = objectToReverseReadonlyMap;
|
|
573
|
-
exports.objectValuesToReadonlySet = objectValuesToReadonlySet;
|
|
574
558
|
exports.objectValuesToSet = objectValuesToSet;
|
|
575
559
|
exports.parseFloatSafe = parseFloatSafe;
|
|
576
560
|
exports.parseIntSafe = parseIntSafe;
|
package/dist/index.d.cts
CHANGED
|
@@ -24,6 +24,7 @@ export type * from "./types/ObjectValues.js";
|
|
|
24
24
|
export * from "./types/ReadonlyMap.js";
|
|
25
25
|
export type * from "./types/ReadonlyRecord.js";
|
|
26
26
|
export * from "./types/ReadonlySet.js";
|
|
27
|
+
export type * from "./types/TranspiledEnum.js";
|
|
27
28
|
export type * from "./types/Tuple.js";
|
|
28
29
|
export type * from "./types/WidenLiteral.js";
|
|
29
30
|
export type * from "./types/Writeable.js";
|
package/dist/index.d.mts
CHANGED
|
@@ -24,6 +24,7 @@ export type * from "./types/ObjectValues.js";
|
|
|
24
24
|
export * from "./types/ReadonlyMap.js";
|
|
25
25
|
export type * from "./types/ReadonlyRecord.js";
|
|
26
26
|
export * from "./types/ReadonlySet.js";
|
|
27
|
+
export type * from "./types/TranspiledEnum.js";
|
|
27
28
|
export type * from "./types/Tuple.js";
|
|
28
29
|
export type * from "./types/WidenLiteral.js";
|
|
29
30
|
export type * from "./types/Writeable.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type * from "./types/ObjectValues.js";
|
|
|
24
24
|
export * from "./types/ReadonlyMap.js";
|
|
25
25
|
export type * from "./types/ReadonlyRecord.js";
|
|
26
26
|
export * from "./types/ReadonlySet.js";
|
|
27
|
+
export type * from "./types/TranspiledEnum.js";
|
|
27
28
|
export type * from "./types/Tuple.js";
|
|
28
29
|
export type * from "./types/WidenLiteral.js";
|
|
29
30
|
export type * from "./types/Writeable.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,yBAAyB,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,yBAAyB,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,sBAAsB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -190,8 +190,8 @@ function mapFilter(map, predicate) {
|
|
|
190
190
|
return array;
|
|
191
191
|
}
|
|
192
192
|
function mapFind(map, predicate) {
|
|
193
|
-
for (const value of map
|
|
194
|
-
const match = predicate(value);
|
|
193
|
+
for (const [key, value] of map) {
|
|
194
|
+
const match = predicate(value, key, map);
|
|
195
195
|
if (match) {
|
|
196
196
|
return value;
|
|
197
197
|
}
|
|
@@ -221,9 +221,6 @@ function objectToMap(object) {
|
|
|
221
221
|
}
|
|
222
222
|
return map;
|
|
223
223
|
}
|
|
224
|
-
function objectToReadonlyMap(object) {
|
|
225
|
-
return objectToMap(object);
|
|
226
|
-
}
|
|
227
224
|
function objectToReverseMap(object) {
|
|
228
225
|
const map = /* @__PURE__ */ new Map();
|
|
229
226
|
for (const [key, value] of Object.entries(object)) {
|
|
@@ -231,9 +228,6 @@ function objectToReverseMap(object) {
|
|
|
231
228
|
}
|
|
232
229
|
return map;
|
|
233
230
|
}
|
|
234
|
-
function objectToReverseReadonlyMap(object) {
|
|
235
|
-
return objectToReverseMap(object);
|
|
236
|
-
}
|
|
237
231
|
|
|
238
232
|
function addSetsToSet(mainSet, ...setsToAdd) {
|
|
239
233
|
for (const set of setsToAdd) {
|
|
@@ -258,9 +252,6 @@ function copySet(oldSet) {
|
|
|
258
252
|
}
|
|
259
253
|
return newSet;
|
|
260
254
|
}
|
|
261
|
-
function objectKeysToReadonlySet(object) {
|
|
262
|
-
return objectKeysToSet(object);
|
|
263
|
-
}
|
|
264
255
|
function objectKeysToSet(object) {
|
|
265
256
|
const set = /* @__PURE__ */ new Set();
|
|
266
257
|
for (const key of Object.keys(object)) {
|
|
@@ -268,9 +259,6 @@ function objectKeysToSet(object) {
|
|
|
268
259
|
}
|
|
269
260
|
return set;
|
|
270
261
|
}
|
|
271
|
-
function objectValuesToReadonlySet(object) {
|
|
272
|
-
return objectValuesToSet(object);
|
|
273
|
-
}
|
|
274
262
|
function objectValuesToSet(object) {
|
|
275
263
|
const set = /* @__PURE__ */ new Set();
|
|
276
264
|
for (const key of Object.values(object)) {
|
|
@@ -508,4 +496,4 @@ function* tupleKeys(tuple) {
|
|
|
508
496
|
|
|
509
497
|
const ReadonlyMap = Map;
|
|
510
498
|
|
|
511
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveInPlace, assertArray, assertBoolean, assertDefined, assertEnumValue, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, kebabCaseToCamelCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter,
|
|
499
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveInPlace, assertArray, assertBoolean, assertDefined, assertEnumValue, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, kebabCaseToCamelCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranspiledEnum.d.ts","sourceRoot":"","sources":["../../src/types/TranspiledEnum.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://complete-ts.github.io/",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "glob \"./src/**/*.test.ts\" --cmd=\"node --import tsx --test --test-reporter spec\""
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "22.13.
|
|
38
|
+
"@types/node": "22.13.10",
|
|
39
39
|
"complete-node": "5.1.1",
|
|
40
40
|
"eslint-plugin-sort-exports": "0.9.1",
|
|
41
41
|
"glob": "11.0.1",
|
package/src/functions/array.ts
CHANGED
|
@@ -13,10 +13,9 @@ import { getRandomInt } from "./random.js";
|
|
|
13
13
|
* Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
|
|
14
14
|
* copied (using the spread operator).
|
|
15
15
|
*/
|
|
16
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
17
16
|
export function arrayCopyTwoDimensional<T>(
|
|
18
17
|
array: ReadonlyArray<readonly T[]>,
|
|
19
|
-
): T[][] {
|
|
18
|
+
): readonly T[][] {
|
|
20
19
|
const copiedArray: T[][] = [];
|
|
21
20
|
|
|
22
21
|
for (const subArray of array) {
|
|
@@ -51,11 +50,10 @@ export function arrayEquals<T>(
|
|
|
51
50
|
*
|
|
52
51
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
53
52
|
*/
|
|
54
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
55
53
|
export function arrayRemove<T>(
|
|
56
54
|
originalArray: readonly T[],
|
|
57
55
|
...elementsToRemove: readonly T[]
|
|
58
|
-
): T[] {
|
|
56
|
+
): readonly T[] {
|
|
59
57
|
const elementsToRemoveSet = new ReadonlySet(elementsToRemove);
|
|
60
58
|
|
|
61
59
|
const array: T[] = [];
|
|
@@ -80,12 +78,11 @@ export function arrayRemove<T>(
|
|
|
80
78
|
*
|
|
81
79
|
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
82
80
|
*/
|
|
83
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
84
81
|
export function arrayRemoveInPlace<T>(
|
|
85
82
|
// eslint-disable-next-line complete/prefer-readonly-parameter-types
|
|
86
83
|
array: T[],
|
|
87
84
|
...elementsToRemove: readonly T[]
|
|
88
|
-
): T[] {
|
|
85
|
+
): readonly T[] {
|
|
89
86
|
const removedElements: T[] = [];
|
|
90
87
|
|
|
91
88
|
for (const element of elementsToRemove) {
|
|
@@ -116,11 +113,10 @@ export function emptyArray(array: unknown[]): void {
|
|
|
116
113
|
* This is named `filterMap` after the Rust function:
|
|
117
114
|
* https://doc.rust-lang.org/std/iter/struct.FilterMap.html
|
|
118
115
|
*/
|
|
119
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
120
116
|
export function filterMap<OldT, NewT>(
|
|
121
117
|
array: readonly OldT[],
|
|
122
118
|
func: (element: OldT) => NewT | undefined,
|
|
123
|
-
): NewT[] {
|
|
119
|
+
): readonly NewT[] {
|
|
124
120
|
const filteredArray: NewT[] = [];
|
|
125
121
|
|
|
126
122
|
for (const element of array) {
|
|
@@ -204,8 +200,7 @@ export function isArray(arg: unknown): arg is unknown[] {
|
|
|
204
200
|
}
|
|
205
201
|
|
|
206
202
|
/** Initializes an array with all elements containing the specified default value. */
|
|
207
|
-
|
|
208
|
-
export function newArray<T>(length: number, value: T): T[] {
|
|
203
|
+
export function newArray<T>(length: number, value: T): readonly T[] {
|
|
209
204
|
return Array.from({ length }, () => value);
|
|
210
205
|
}
|
|
211
206
|
|
package/src/functions/assert.ts
CHANGED
package/src/functions/enums.ts
CHANGED
package/src/functions/map.ts
CHANGED
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
* If you want to perform a filter and a map at the same time on an array, use the `filterMap`
|
|
15
15
|
* helper function instead.
|
|
16
16
|
*/
|
|
17
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
18
17
|
export function mapFilter<K, V>(
|
|
19
18
|
map: ReadonlyMap<K, V>,
|
|
20
19
|
predicate: (value: V) => boolean,
|
|
21
|
-
): V[] {
|
|
20
|
+
): readonly V[] {
|
|
22
21
|
const array: V[] = [];
|
|
23
22
|
|
|
24
23
|
for (const value of map.values()) {
|
|
@@ -36,13 +35,17 @@ export function mapFilter<K, V>(
|
|
|
36
35
|
* maps.
|
|
37
36
|
*
|
|
38
37
|
* This is efficient such that it avoids converting the map values into an array.
|
|
38
|
+
*
|
|
39
|
+
* @param map The map to search through.
|
|
40
|
+
* @param predicate Function that tests each value for a condition.
|
|
41
|
+
* @returns The first value that satisfies the predicate, or undefined if no values satisfy.
|
|
39
42
|
*/
|
|
40
43
|
export function mapFind<K, V>(
|
|
41
44
|
map: ReadonlyMap<K, V>,
|
|
42
|
-
predicate: (value: V) => boolean,
|
|
45
|
+
predicate: (value: V, key: K, map: ReadonlyMap<K, V>) => boolean,
|
|
43
46
|
): V | undefined {
|
|
44
|
-
for (const value of map
|
|
45
|
-
const match = predicate(value);
|
|
47
|
+
for (const [key, value] of map) {
|
|
48
|
+
const match = predicate(value, key, map);
|
|
46
49
|
if (match) {
|
|
47
50
|
return value;
|
|
48
51
|
}
|
package/src/functions/object.ts
CHANGED
|
@@ -12,11 +12,10 @@ import type { ReadonlyRecord } from "../types/ReadonlyRecord.js";
|
|
|
12
12
|
*
|
|
13
13
|
* This is efficient such that it avoids converting the object values into an array.
|
|
14
14
|
*/
|
|
15
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
16
15
|
export function objectFilter<K extends string | number | symbol, V>(
|
|
17
16
|
object: ReadonlyRecord<K, V>,
|
|
18
17
|
predicate: (value: V) => boolean,
|
|
19
|
-
): V[] {
|
|
18
|
+
): readonly V[] {
|
|
20
19
|
const array: V[] = [];
|
|
21
20
|
|
|
22
21
|
// eslint-disable-next-line complete/no-for-in
|
|
@@ -41,13 +40,10 @@ export function objectFilter<K extends string | number | symbol, V>(
|
|
|
41
40
|
*
|
|
42
41
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
43
42
|
* only having string keys under the hood.
|
|
44
|
-
*
|
|
45
|
-
* Also see the `objectToReadonlyMap` function.
|
|
46
43
|
*/
|
|
47
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
48
44
|
export function objectToMap<K extends string | number | symbol, V>(
|
|
49
45
|
object: Record<K, V>,
|
|
50
|
-
):
|
|
46
|
+
): ReadonlyMap<K, V> {
|
|
51
47
|
const map = new Map<K, V>();
|
|
52
48
|
|
|
53
49
|
for (const [key, value] of Object.entries(object)) {
|
|
@@ -57,38 +53,16 @@ export function objectToMap<K extends string | number | symbol, V>(
|
|
|
57
53
|
return map;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
/**
|
|
61
|
-
* Helper function to convert an object to a read-only map.
|
|
62
|
-
*
|
|
63
|
-
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
64
|
-
* then later on you need to query it in a way where you expect the return value to be T or
|
|
65
|
-
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
66
|
-
* assertions.
|
|
67
|
-
*
|
|
68
|
-
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
69
|
-
* only having string keys under the hood.
|
|
70
|
-
*
|
|
71
|
-
* Also see the `objectToMap` function.
|
|
72
|
-
*/
|
|
73
|
-
export function objectToReadonlyMap<K extends string | number | symbol, V>(
|
|
74
|
-
object: Record<K, V>,
|
|
75
|
-
): ReadonlyMap<K, V> {
|
|
76
|
-
return objectToMap(object);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
56
|
/**
|
|
80
57
|
* Helper function to convert an object to a reverse map.
|
|
81
58
|
*
|
|
82
59
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
83
60
|
* only having string keys under the hood.
|
|
84
|
-
*
|
|
85
|
-
* Also see the `objectToReverseReadonlyMap` function.
|
|
86
61
|
*/
|
|
87
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
88
62
|
export function objectToReverseMap<
|
|
89
63
|
K extends string | number | symbol,
|
|
90
64
|
V extends string | number | symbol,
|
|
91
|
-
>(object: Record<K, V>):
|
|
65
|
+
>(object: Record<K, V>): ReadonlyMap<V, K> {
|
|
92
66
|
const map = new Map<V, K>();
|
|
93
67
|
|
|
94
68
|
for (const [key, value] of Object.entries(object)) {
|
|
@@ -97,18 +71,3 @@ export function objectToReverseMap<
|
|
|
97
71
|
|
|
98
72
|
return map;
|
|
99
73
|
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Helper function to convert an object to a reverse read-only map.
|
|
103
|
-
*
|
|
104
|
-
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
105
|
-
* only having string keys under the hood.
|
|
106
|
-
*
|
|
107
|
-
* Also see the `objectToReverseMap` function.
|
|
108
|
-
*/
|
|
109
|
-
export function objectToReverseReadonlyMap<
|
|
110
|
-
K extends string | number | symbol,
|
|
111
|
-
V extends string | number | symbol,
|
|
112
|
-
>(object: Record<K, V>): ReadonlyMap<V, K> {
|
|
113
|
-
return objectToReverseMap(object);
|
|
114
|
-
}
|
package/src/functions/set.ts
CHANGED
|
@@ -28,8 +28,9 @@ export function addSetsToSet<T>(
|
|
|
28
28
|
*
|
|
29
29
|
* This function is variadic, meaning that you can specify N sets.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
export function combineSets<T>(
|
|
32
|
+
...sets: ReadonlyArray<ReadonlySet<T>>
|
|
33
|
+
): ReadonlySet<T> {
|
|
33
34
|
const newSet = new Set<T>();
|
|
34
35
|
for (const set of sets) {
|
|
35
36
|
for (const value of set) {
|
|
@@ -41,8 +42,7 @@ export function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>): Set<T> {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
44
|
-
|
|
45
|
-
export function copySet<T>(oldSet: ReadonlySet<T>): Set<T> {
|
|
45
|
+
export function copySet<T>(oldSet: ReadonlySet<T>): ReadonlySet<T> {
|
|
46
46
|
const newSet = new Set<T>();
|
|
47
47
|
for (const value of oldSet) {
|
|
48
48
|
newSet.add(value);
|
|
@@ -51,26 +51,10 @@ export function copySet<T>(oldSet: ReadonlySet<T>): Set<T> {
|
|
|
51
51
|
return newSet;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Helper function to convert the keys of an object to a read-only set.
|
|
56
|
-
*
|
|
57
|
-
* Also see the `objectKeysToSet` function.
|
|
58
|
-
*/
|
|
59
|
-
export function objectKeysToReadonlySet<K extends string | number | symbol, V>(
|
|
60
|
-
object: Record<K, V>,
|
|
61
|
-
): ReadonlySet<K> {
|
|
62
|
-
return objectKeysToSet(object);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Helper function to convert the keys of an object to a set.
|
|
67
|
-
*
|
|
68
|
-
* Also see the `objectKeysToReadonlySet` function.
|
|
69
|
-
*/
|
|
70
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
54
|
+
/** Helper function to convert the keys of an object to a set. */
|
|
71
55
|
export function objectKeysToSet<K extends string | number | symbol, V>(
|
|
72
56
|
object: Record<K, V>,
|
|
73
|
-
):
|
|
57
|
+
): ReadonlySet<K> {
|
|
74
58
|
const set = new Set<K>();
|
|
75
59
|
|
|
76
60
|
for (const key of Object.keys(object)) {
|
|
@@ -80,27 +64,10 @@ export function objectKeysToSet<K extends string | number | symbol, V>(
|
|
|
80
64
|
return set;
|
|
81
65
|
}
|
|
82
66
|
|
|
83
|
-
/**
|
|
84
|
-
* Helper function to convert the values of an object to a read-only set.
|
|
85
|
-
*
|
|
86
|
-
* Also see the `objectValuesToSet` function.
|
|
87
|
-
*/
|
|
88
|
-
export function objectValuesToReadonlySet<
|
|
89
|
-
K extends string | number | symbol,
|
|
90
|
-
V,
|
|
91
|
-
>(object: Record<K, V>): ReadonlySet<V> {
|
|
92
|
-
return objectValuesToSet(object);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Helper function to convert the values of an object to a set.
|
|
97
|
-
*
|
|
98
|
-
* Also see the `objectValuesToReadonlySet` function.
|
|
99
|
-
*/
|
|
100
|
-
// eslint-disable-next-line complete/no-mutable-return
|
|
67
|
+
/** Helper function to convert the values of an object to a set. */
|
|
101
68
|
export function objectValuesToSet<K extends string | number | symbol, V>(
|
|
102
69
|
object: Record<K, V>,
|
|
103
|
-
):
|
|
70
|
+
): ReadonlySet<V> {
|
|
104
71
|
const set = new Set<V>();
|
|
105
72
|
|
|
106
73
|
for (const key of Object.values(object)) {
|
package/src/functions/sort.ts
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* From:
|
|
12
12
|
* https://stackoverflow.com/questions/8996963/how-to-perform-case-insensitive-sorting-array-of-string-in-javascript
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
export function sortCaseInsensitive(
|
|
15
|
+
array: readonly string[],
|
|
16
|
+
): readonly string[] {
|
|
16
17
|
const newArray = [...array];
|
|
17
18
|
newArray.sort((a, b) =>
|
|
18
19
|
a.localeCompare(b, undefined, {
|
package/src/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type * from "./types/ObjectValues.js";
|
|
|
24
24
|
export * from "./types/ReadonlyMap.js";
|
|
25
25
|
export type * from "./types/ReadonlyRecord.js";
|
|
26
26
|
export * from "./types/ReadonlySet.js";
|
|
27
|
+
export type * from "./types/TranspiledEnum.js";
|
|
27
28
|
export type * from "./types/Tuple.js";
|
|
28
29
|
export type * from "./types/WidenLiteral.js";
|
|
29
30
|
export type * from "./types/Writeable.js";
|