complete-common 2.18.0 → 2.19.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 +2 -0
- package/dist/functions/array.d.mts +2 -0
- package/dist/functions/array.d.ts +2 -0
- 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/enums.d.cts +2 -2
- package/dist/functions/enums.d.mts +2 -2
- package/dist/functions/enums.d.ts +2 -2
- package/dist/functions/object.d.cts +4 -4
- package/dist/functions/object.d.mts +4 -4
- package/dist/functions/object.d.ts +4 -4
- package/dist/functions/set.d.cts +2 -2
- package/dist/functions/set.d.mts +2 -2
- package/dist/functions/set.d.ts +2 -2
- package/dist/functions/string.d.cts +2 -2
- package/dist/functions/string.d.mts +2 -2
- package/dist/functions/string.d.ts +2 -2
- package/dist/index.cjs +7 -0
- package/dist/index.mjs +7 -1
- package/dist/types/Immutable.d.cts +1 -1
- package/dist/types/Immutable.d.mts +1 -1
- package/dist/types/Immutable.d.ts +1 -1
- package/dist/types/Immutable.d.ts.map +1 -1
- package/dist/types/ReadonlyRecord.d.cts +1 -1
- package/dist/types/ReadonlyRecord.d.mts +1 -1
- package/dist/types/ReadonlyRecord.d.ts +1 -1
- package/dist/types/TranspiledEnum.d.cts +1 -1
- package/dist/types/TranspiledEnum.d.mts +1 -1
- package/dist/types/TranspiledEnum.d.ts +1 -1
- package/package.json +4 -4
- package/src/functions/array.ts +10 -0
- package/src/functions/assert.ts +1 -1
- package/src/functions/enums.ts +2 -2
- package/src/functions/object.ts +5 -5
- package/src/functions/set.ts +2 -2
- package/src/functions/string.ts +2 -2
- package/src/types/Immutable.ts +4 -4
- package/src/types/ReadonlyRecord.ts +1 -1
- package/src/types/TranspiledEnum.ts +1 -1
|
@@ -134,6 +134,8 @@ export declare function isArray(variable: unknown): variable is unknown[];
|
|
|
134
134
|
export declare function isArrayBoolean(variable: unknown): variable is boolean[];
|
|
135
135
|
/** Helper function to check every value of an array to see if it is a number. */
|
|
136
136
|
export declare function isArrayNumber(variable: unknown): variable is number[];
|
|
137
|
+
/** Helper function to check every value of an array to see if it is an object. */
|
|
138
|
+
export declare function isArrayObject(variable: unknown): variable is string[];
|
|
137
139
|
/** Helper function to check every value of an array to see if it is a string. */
|
|
138
140
|
export declare function isArrayString(variable: unknown): variable is string[];
|
|
139
141
|
/**
|
|
@@ -134,6 +134,8 @@ export declare function isArray(variable: unknown): variable is unknown[];
|
|
|
134
134
|
export declare function isArrayBoolean(variable: unknown): variable is boolean[];
|
|
135
135
|
/** Helper function to check every value of an array to see if it is a number. */
|
|
136
136
|
export declare function isArrayNumber(variable: unknown): variable is number[];
|
|
137
|
+
/** Helper function to check every value of an array to see if it is an object. */
|
|
138
|
+
export declare function isArrayObject(variable: unknown): variable is string[];
|
|
137
139
|
/** Helper function to check every value of an array to see if it is a string. */
|
|
138
140
|
export declare function isArrayString(variable: unknown): variable is string[];
|
|
139
141
|
/**
|
|
@@ -134,6 +134,8 @@ export declare function isArray(variable: unknown): variable is unknown[];
|
|
|
134
134
|
export declare function isArrayBoolean(variable: unknown): variable is boolean[];
|
|
135
135
|
/** Helper function to check every value of an array to see if it is a number. */
|
|
136
136
|
export declare function isArrayNumber(variable: unknown): variable is number[];
|
|
137
|
+
/** Helper function to check every value of an array to see if it is an object. */
|
|
138
|
+
export declare function isArrayObject(variable: unknown): variable is string[];
|
|
137
139
|
/** Helper function to check every value of an array to see if it is a string. */
|
|
138
140
|
export declare function isArrayString(variable: unknown): variable is string[];
|
|
139
141
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"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"}
|
|
@@ -58,7 +58,7 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
|
|
|
58
58
|
* will check for existence using the set (instead of the enum itself). Using a set
|
|
59
59
|
* should be more performant for enums with around 52 or more elements.
|
|
60
60
|
*/
|
|
61
|
-
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<
|
|
61
|
+
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<number | string>): asserts value is T[keyof T];
|
|
62
62
|
/** Helper function to throw an error if the provided value is not an integer. */
|
|
63
63
|
export declare function assertInteger(value: unknown, msg: string): asserts value is number;
|
|
64
64
|
/**
|
|
@@ -58,7 +58,7 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
|
|
|
58
58
|
* will check for existence using the set (instead of the enum itself). Using a set
|
|
59
59
|
* should be more performant for enums with around 52 or more elements.
|
|
60
60
|
*/
|
|
61
|
-
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<
|
|
61
|
+
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<number | string>): asserts value is T[keyof T];
|
|
62
62
|
/** Helper function to throw an error if the provided value is not an integer. */
|
|
63
63
|
export declare function assertInteger(value: unknown, msg: string): asserts value is number;
|
|
64
64
|
/**
|
|
@@ -58,7 +58,7 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
|
|
|
58
58
|
* will check for existence using the set (instead of the enum itself). Using a set
|
|
59
59
|
* should be more performant for enums with around 52 or more elements.
|
|
60
60
|
*/
|
|
61
|
-
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<
|
|
61
|
+
export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<number | string>): asserts value is T[keyof T];
|
|
62
62
|
/** Helper function to throw an error if the provided value is not an integer. */
|
|
63
63
|
export declare function assertInteger(value: unknown, msg: string): asserts value is number;
|
|
64
64
|
/**
|
|
@@ -58,7 +58,7 @@ export declare function getEnumValues<T extends TranspiledEnum>(transpiledEnum:
|
|
|
58
58
|
* run-time). If you are generating an object that will contain all of the keys of an enum, use the
|
|
59
59
|
* `satisfies` operator with the `Record` type instead.
|
|
60
60
|
*/
|
|
61
|
-
export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends
|
|
61
|
+
export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends number | string>(): void;
|
|
62
62
|
/**
|
|
63
63
|
* Helper function to validate that a particular value exists inside of an enum.
|
|
64
64
|
*
|
|
@@ -68,5 +68,5 @@ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>,
|
|
|
68
68
|
* will check for existence using the set (instead of the enum itself). Using a set
|
|
69
69
|
* should be more performant for enums with around 52 or more elements.
|
|
70
70
|
*/
|
|
71
|
-
export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<
|
|
71
|
+
export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<number | string>): value is T[keyof T];
|
|
72
72
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -58,7 +58,7 @@ export declare function getEnumValues<T extends TranspiledEnum>(transpiledEnum:
|
|
|
58
58
|
* run-time). If you are generating an object that will contain all of the keys of an enum, use the
|
|
59
59
|
* `satisfies` operator with the `Record` type instead.
|
|
60
60
|
*/
|
|
61
|
-
export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends
|
|
61
|
+
export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends number | string>(): void;
|
|
62
62
|
/**
|
|
63
63
|
* Helper function to validate that a particular value exists inside of an enum.
|
|
64
64
|
*
|
|
@@ -68,5 +68,5 @@ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>,
|
|
|
68
68
|
* will check for existence using the set (instead of the enum itself). Using a set
|
|
69
69
|
* should be more performant for enums with around 52 or more elements.
|
|
70
70
|
*/
|
|
71
|
-
export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<
|
|
71
|
+
export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<number | string>): value is T[keyof T];
|
|
72
72
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -58,7 +58,7 @@ export declare function getEnumValues<T extends TranspiledEnum>(transpiledEnum:
|
|
|
58
58
|
* run-time). If you are generating an object that will contain all of the keys of an enum, use the
|
|
59
59
|
* `satisfies` operator with the `Record` type instead.
|
|
60
60
|
*/
|
|
61
|
-
export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends
|
|
61
|
+
export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends number | string>(): void;
|
|
62
62
|
/**
|
|
63
63
|
* Helper function to validate that a particular value exists inside of an enum.
|
|
64
64
|
*
|
|
@@ -68,5 +68,5 @@ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>,
|
|
|
68
68
|
* will check for existence using the set (instead of the enum itself). Using a set
|
|
69
69
|
* should be more performant for enums with around 52 or more elements.
|
|
70
70
|
*/
|
|
71
|
-
export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<
|
|
71
|
+
export declare function isEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, set?: ReadonlySet<number | string>): value is T[keyof T];
|
|
72
72
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -18,12 +18,12 @@ export declare function getWidenedObjectValue<T extends Record<string, unknown>>
|
|
|
18
18
|
*
|
|
19
19
|
* This is efficient such that it avoids converting the object values into an array.
|
|
20
20
|
*/
|
|
21
|
-
export declare function objectFilter<K extends
|
|
21
|
+
export declare function objectFilter<K extends number | string | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): readonly V[];
|
|
22
22
|
/**
|
|
23
23
|
* Helper function to map the values in an object to another object with new values. Similar to the
|
|
24
24
|
* `Array.map` method, but works for objects.
|
|
25
25
|
*/
|
|
26
|
-
export declare function objectMap<K extends
|
|
26
|
+
export declare function objectMap<K extends number | string | symbol, V, U>(object: Record<K, V>, callback: (key: K, value: V) => U): ReadonlyRecord<K, U>;
|
|
27
27
|
/**
|
|
28
28
|
* Helper function to convert an object to a `Map`.
|
|
29
29
|
*
|
|
@@ -35,12 +35,12 @@ export declare function objectMap<K extends string | number | symbol, V, U>(obje
|
|
|
35
35
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
36
36
|
* only having string keys under the hood.
|
|
37
37
|
*/
|
|
38
|
-
export declare function objectToMap<K extends
|
|
38
|
+
export declare function objectToMap<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
|
|
39
39
|
/**
|
|
40
40
|
* Helper function to convert an object to a reverse map.
|
|
41
41
|
*
|
|
42
42
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
43
43
|
* only having string keys under the hood.
|
|
44
44
|
*/
|
|
45
|
-
export declare function objectToReverseMap<K extends
|
|
45
|
+
export declare function objectToReverseMap<K extends number | string | symbol, V extends number | string | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
|
|
46
46
|
//# sourceMappingURL=object.d.ts.map
|
|
@@ -18,12 +18,12 @@ export declare function getWidenedObjectValue<T extends Record<string, unknown>>
|
|
|
18
18
|
*
|
|
19
19
|
* This is efficient such that it avoids converting the object values into an array.
|
|
20
20
|
*/
|
|
21
|
-
export declare function objectFilter<K extends
|
|
21
|
+
export declare function objectFilter<K extends number | string | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): readonly V[];
|
|
22
22
|
/**
|
|
23
23
|
* Helper function to map the values in an object to another object with new values. Similar to the
|
|
24
24
|
* `Array.map` method, but works for objects.
|
|
25
25
|
*/
|
|
26
|
-
export declare function objectMap<K extends
|
|
26
|
+
export declare function objectMap<K extends number | string | symbol, V, U>(object: Record<K, V>, callback: (key: K, value: V) => U): ReadonlyRecord<K, U>;
|
|
27
27
|
/**
|
|
28
28
|
* Helper function to convert an object to a `Map`.
|
|
29
29
|
*
|
|
@@ -35,12 +35,12 @@ export declare function objectMap<K extends string | number | symbol, V, U>(obje
|
|
|
35
35
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
36
36
|
* only having string keys under the hood.
|
|
37
37
|
*/
|
|
38
|
-
export declare function objectToMap<K extends
|
|
38
|
+
export declare function objectToMap<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
|
|
39
39
|
/**
|
|
40
40
|
* Helper function to convert an object to a reverse map.
|
|
41
41
|
*
|
|
42
42
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
43
43
|
* only having string keys under the hood.
|
|
44
44
|
*/
|
|
45
|
-
export declare function objectToReverseMap<K extends
|
|
45
|
+
export declare function objectToReverseMap<K extends number | string | symbol, V extends number | string | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
|
|
46
46
|
//# sourceMappingURL=object.d.ts.map
|
|
@@ -18,12 +18,12 @@ export declare function getWidenedObjectValue<T extends Record<string, unknown>>
|
|
|
18
18
|
*
|
|
19
19
|
* This is efficient such that it avoids converting the object values into an array.
|
|
20
20
|
*/
|
|
21
|
-
export declare function objectFilter<K extends
|
|
21
|
+
export declare function objectFilter<K extends number | string | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): readonly V[];
|
|
22
22
|
/**
|
|
23
23
|
* Helper function to map the values in an object to another object with new values. Similar to the
|
|
24
24
|
* `Array.map` method, but works for objects.
|
|
25
25
|
*/
|
|
26
|
-
export declare function objectMap<K extends
|
|
26
|
+
export declare function objectMap<K extends number | string | symbol, V, U>(object: Record<K, V>, callback: (key: K, value: V) => U): ReadonlyRecord<K, U>;
|
|
27
27
|
/**
|
|
28
28
|
* Helper function to convert an object to a `Map`.
|
|
29
29
|
*
|
|
@@ -35,12 +35,12 @@ export declare function objectMap<K extends string | number | symbol, V, U>(obje
|
|
|
35
35
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
36
36
|
* only having string keys under the hood.
|
|
37
37
|
*/
|
|
38
|
-
export declare function objectToMap<K extends
|
|
38
|
+
export declare function objectToMap<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
|
|
39
39
|
/**
|
|
40
40
|
* Helper function to convert an object to a reverse map.
|
|
41
41
|
*
|
|
42
42
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
43
43
|
* only having string keys under the hood.
|
|
44
44
|
*/
|
|
45
|
-
export declare function objectToReverseMap<K extends
|
|
45
|
+
export declare function objectToReverseMap<K extends number | string | symbol, V extends number | string | symbol>(object: Record<K, V>): ReadonlyMap<V, K>;
|
|
46
46
|
//# sourceMappingURL=object.d.ts.map
|
package/dist/functions/set.d.cts
CHANGED
|
@@ -20,9 +20,9 @@ export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>):
|
|
|
20
20
|
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
21
21
|
export declare function copySet<T>(oldSet: ReadonlySet<T>): ReadonlySet<T>;
|
|
22
22
|
/** Helper function to convert the keys of an object to a set. */
|
|
23
|
-
export declare function objectKeysToSet<K extends
|
|
23
|
+
export declare function objectKeysToSet<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
|
|
24
24
|
/** Helper function to convert the values of an object to a set. */
|
|
25
|
-
export declare function objectValuesToSet<K extends
|
|
25
|
+
export declare function objectValuesToSet<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
|
|
26
26
|
/**
|
|
27
27
|
* Helper function to add one or more elements to a set at once without having to repeatedly call
|
|
28
28
|
* the `Set.add` method.
|
package/dist/functions/set.d.mts
CHANGED
|
@@ -20,9 +20,9 @@ export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>):
|
|
|
20
20
|
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
21
21
|
export declare function copySet<T>(oldSet: ReadonlySet<T>): ReadonlySet<T>;
|
|
22
22
|
/** Helper function to convert the keys of an object to a set. */
|
|
23
|
-
export declare function objectKeysToSet<K extends
|
|
23
|
+
export declare function objectKeysToSet<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
|
|
24
24
|
/** Helper function to convert the values of an object to a set. */
|
|
25
|
-
export declare function objectValuesToSet<K extends
|
|
25
|
+
export declare function objectValuesToSet<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
|
|
26
26
|
/**
|
|
27
27
|
* Helper function to add one or more elements to a set at once without having to repeatedly call
|
|
28
28
|
* the `Set.add` method.
|
package/dist/functions/set.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>):
|
|
|
20
20
|
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
21
21
|
export declare function copySet<T>(oldSet: ReadonlySet<T>): ReadonlySet<T>;
|
|
22
22
|
/** Helper function to convert the keys of an object to a set. */
|
|
23
|
-
export declare function objectKeysToSet<K extends
|
|
23
|
+
export declare function objectKeysToSet<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
|
|
24
24
|
/** Helper function to convert the values of an object to a set. */
|
|
25
|
-
export declare function objectValuesToSet<K extends
|
|
25
|
+
export declare function objectValuesToSet<K extends number | string | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
|
|
26
26
|
/**
|
|
27
27
|
* Helper function to add one or more elements to a set at once without having to repeatedly call
|
|
28
28
|
* the `Set.add` method.
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Helper function to replace all of the ampersands, less than signs, greater than signs, double
|
|
10
|
-
* quotes, and single quotes in a string with the escaped counterparts. For example,
|
|
11
|
-
* replaced with
|
|
10
|
+
* quotes, and single quotes in a string with the escaped counterparts. For example, `<` will be
|
|
11
|
+
* replaced with `<`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function escapeHTMLCharacters(string: string): string;
|
|
14
14
|
/**
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Helper function to replace all of the ampersands, less than signs, greater than signs, double
|
|
10
|
-
* quotes, and single quotes in a string with the escaped counterparts. For example,
|
|
11
|
-
* replaced with
|
|
10
|
+
* quotes, and single quotes in a string with the escaped counterparts. For example, `<` will be
|
|
11
|
+
* replaced with `<`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function escapeHTMLCharacters(string: string): string;
|
|
14
14
|
/**
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Helper function to replace all of the ampersands, less than signs, greater than signs, double
|
|
10
|
-
* quotes, and single quotes in a string with the escaped counterparts. For example,
|
|
11
|
-
* replaced with
|
|
10
|
+
* quotes, and single quotes in a string with the escaped counterparts. For example, `<` will be
|
|
11
|
+
* replaced with `<`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function escapeHTMLCharacters(string: string): string;
|
|
14
14
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -264,6 +264,12 @@ function isArrayNumber(variable) {
|
|
|
264
264
|
}
|
|
265
265
|
return variable.every((element) => typeof element === "string");
|
|
266
266
|
}
|
|
267
|
+
function isArrayObject(variable) {
|
|
268
|
+
if (!isArray(variable)) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
return variable.every((element) => isObject(element));
|
|
272
|
+
}
|
|
267
273
|
function isArrayString(variable) {
|
|
268
274
|
if (!isArray(variable)) {
|
|
269
275
|
return false;
|
|
@@ -688,6 +694,7 @@ exports.isASCII = isASCII;
|
|
|
688
694
|
exports.isArray = isArray;
|
|
689
695
|
exports.isArrayBoolean = isArrayBoolean;
|
|
690
696
|
exports.isArrayNumber = isArrayNumber;
|
|
697
|
+
exports.isArrayObject = isArrayObject;
|
|
691
698
|
exports.isArrayString = isArrayString;
|
|
692
699
|
exports.isEnumValue = isEnumValue;
|
|
693
700
|
exports.isFirstLetterCapitalized = isFirstLetterCapitalized;
|
package/dist/index.mjs
CHANGED
|
@@ -262,6 +262,12 @@ function isArrayNumber(variable) {
|
|
|
262
262
|
}
|
|
263
263
|
return variable.every((element) => typeof element === "string");
|
|
264
264
|
}
|
|
265
|
+
function isArrayObject(variable) {
|
|
266
|
+
if (!isArray(variable)) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
return variable.every((element) => isObject(element));
|
|
270
|
+
}
|
|
265
271
|
function isArrayString(variable) {
|
|
266
272
|
if (!isArray(variable)) {
|
|
267
273
|
return false;
|
|
@@ -630,4 +636,4 @@ function* tupleKeys(tuple) {
|
|
|
630
636
|
|
|
631
637
|
const ReadonlyMap = Map;
|
|
632
638
|
|
|
633
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertArrayBoolean, assertArrayNumber, assertArrayObject, assertArrayString, assertBoolean, assertDefined, assertEnumValue, assertInteger, assertIs, assertNotNull, assertNumber, assertObject, assertString, assertStringNotEmpty, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterAsync, filterMap, filterMapAsync, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, getWidenedObjectValue, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isASCII, isArray, isArrayBoolean, isArrayNumber, isArrayString, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapAsync, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectMap, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, titleCaseToKebabCase, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
639
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertArrayBoolean, assertArrayNumber, assertArrayObject, assertArrayString, assertBoolean, assertDefined, assertEnumValue, assertInteger, assertIs, assertNotNull, assertNumber, assertObject, assertString, assertStringNotEmpty, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterAsync, filterMap, filterMapAsync, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, getWidenedObjectValue, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isASCII, isArray, isArrayBoolean, isArrayNumber, isArrayObject, isArrayString, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapAsync, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectMap, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, titleCaseToKebabCase, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* From: https://stackoverflow.com/questions/41879327/deepreadonly-object-typescript
|
|
7
7
|
*/
|
|
8
8
|
export type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
9
|
-
type ImmutablePrimitive =
|
|
9
|
+
type ImmutablePrimitive = boolean | number | string | Function | null | undefined;
|
|
10
10
|
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
11
11
|
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
12
12
|
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* From: https://stackoverflow.com/questions/41879327/deepreadonly-object-typescript
|
|
7
7
|
*/
|
|
8
8
|
export type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
9
|
-
type ImmutablePrimitive =
|
|
9
|
+
type ImmutablePrimitive = boolean | number | string | Function | null | undefined;
|
|
10
10
|
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
11
11
|
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
12
12
|
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* From: https://stackoverflow.com/questions/41879327/deepreadonly-object-typescript
|
|
7
7
|
*/
|
|
8
8
|
export type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
9
|
-
type ImmutablePrimitive =
|
|
9
|
+
type ImmutablePrimitive = boolean | number | string | Function | null | undefined;
|
|
10
10
|
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
11
11
|
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
12
12
|
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Immutable.d.ts","sourceRoot":"","sources":["../../src/types/Immutable.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,kBAAkB,GACnD,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtB,cAAc,CAAC,CAAC,CAAC,GACjB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC7B,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAClB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GACpB,YAAY,CAAC,CAAC,CAAC,GACf,eAAe,CAAC,CAAC,CAAC,CAAC;AAE7B,KAAK,kBAAkB,GACnB,
|
|
1
|
+
{"version":3,"file":"Immutable.d.ts","sourceRoot":"","sources":["../../src/types/Immutable.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,kBAAkB,GACnD,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtB,cAAc,CAAC,CAAC,CAAC,GACjB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC7B,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAClB,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GACpB,YAAY,CAAC,CAAC,CAAC,GACf,eAAe,CAAC,CAAC,CAAC,CAAC;AAE7B,KAAK,kBAAkB,GACnB,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,IAAI,GACJ,SAAS,CAAC;AACd,KAAK,cAAc,CAAC,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,KAAK,YAAY,CAAC,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,KAAK,eAAe,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This is the same thing as `Readonly<Record<K, V>>`.
|
|
5
5
|
*/
|
|
6
|
-
export type ReadonlyRecord<K extends
|
|
6
|
+
export type ReadonlyRecord<K extends number | string | symbol, V> = Readonly<Record<K, V>>;
|
|
7
7
|
//# sourceMappingURL=ReadonlyRecord.d.ts.map
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This is the same thing as `Readonly<Record<K, V>>`.
|
|
5
5
|
*/
|
|
6
|
-
export type ReadonlyRecord<K extends
|
|
6
|
+
export type ReadonlyRecord<K extends number | string | symbol, V> = Readonly<Record<K, V>>;
|
|
7
7
|
//# sourceMappingURL=ReadonlyRecord.d.ts.map
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This is the same thing as `Readonly<Record<K, V>>`.
|
|
5
5
|
*/
|
|
6
|
-
export type ReadonlyRecord<K extends
|
|
6
|
+
export type ReadonlyRecord<K extends number | string | symbol, V> = Readonly<Record<K, V>>;
|
|
7
7
|
//# sourceMappingURL=ReadonlyRecord.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
5
|
"homepage": "https://complete-ts.github.io/",
|
|
6
6
|
"bugs": {
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"test": "bun test"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "25.
|
|
35
|
+
"@types/node": "25.3.2",
|
|
36
36
|
"complete-node": "16.2.0",
|
|
37
37
|
"eslint-plugin-sort-exports": "0.9.1",
|
|
38
|
-
"typedoc": "0.28.
|
|
38
|
+
"typedoc": "0.28.17",
|
|
39
39
|
"typescript": "5.9.3",
|
|
40
|
-
"typescript-eslint": "8.
|
|
40
|
+
"typescript-eslint": "8.56.1",
|
|
41
41
|
"unbuild": "3.6.1"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/functions/array.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ReadonlySet } from "../types/ReadonlySet.js";
|
|
|
8
8
|
import type { WidenLiteral } from "../types/WidenLiteral.js";
|
|
9
9
|
import { assertDefined } from "./assert.js";
|
|
10
10
|
import { getRandomInt } from "./random.js";
|
|
11
|
+
import { isObject } from "./types.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
|
|
@@ -325,6 +326,15 @@ export function isArrayNumber(variable: unknown): variable is number[] {
|
|
|
325
326
|
return variable.every((element) => typeof element === "string");
|
|
326
327
|
}
|
|
327
328
|
|
|
329
|
+
/** Helper function to check every value of an array to see if it is an object. */
|
|
330
|
+
export function isArrayObject(variable: unknown): variable is string[] {
|
|
331
|
+
if (!isArray(variable)) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return variable.every((element) => isObject(element));
|
|
336
|
+
}
|
|
337
|
+
|
|
328
338
|
/** Helper function to check every value of an array to see if it is a string. */
|
|
329
339
|
export function isArrayString(variable: unknown): variable is string[] {
|
|
330
340
|
if (!isArray(variable)) {
|
package/src/functions/assert.ts
CHANGED
|
@@ -152,7 +152,7 @@ export function assertEnumValue<T extends TranspiledEnum>(
|
|
|
152
152
|
value: number | string,
|
|
153
153
|
transpiledEnum: T,
|
|
154
154
|
msg: string,
|
|
155
|
-
set?: ReadonlySet<
|
|
155
|
+
set?: ReadonlySet<number | string>,
|
|
156
156
|
): asserts value is T[keyof T] {
|
|
157
157
|
if (!isEnumValue(value, transpiledEnum, set)) {
|
|
158
158
|
throw new TypeError(msg);
|
package/src/functions/enums.ts
CHANGED
|
@@ -85,7 +85,7 @@ export function getEnumValues<T extends TranspiledEnum>(
|
|
|
85
85
|
export function interfaceSatisfiesEnum<
|
|
86
86
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-unnecessary-type-parameters
|
|
87
87
|
T extends Record<Enum, unknown>,
|
|
88
|
-
Enum extends
|
|
88
|
+
Enum extends number | string,
|
|
89
89
|
>(): void {} // eslint-disable-line @typescript-eslint/no-empty-function
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -100,7 +100,7 @@ export function interfaceSatisfiesEnum<
|
|
|
100
100
|
export function isEnumValue<T extends TranspiledEnum>(
|
|
101
101
|
value: number | string,
|
|
102
102
|
transpiledEnum: T,
|
|
103
|
-
set?: ReadonlySet<
|
|
103
|
+
set?: ReadonlySet<number | string>,
|
|
104
104
|
): value is T[keyof T] {
|
|
105
105
|
if (set !== undefined) {
|
|
106
106
|
return set.has(value);
|
package/src/functions/object.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function getWidenedObjectValue<T extends Record<string, unknown>>(
|
|
|
27
27
|
*
|
|
28
28
|
* This is efficient such that it avoids converting the object values into an array.
|
|
29
29
|
*/
|
|
30
|
-
export function objectFilter<K extends
|
|
30
|
+
export function objectFilter<K extends number | string | symbol, V>(
|
|
31
31
|
object: ReadonlyRecord<K, V>,
|
|
32
32
|
predicate: (value: V) => boolean,
|
|
33
33
|
): readonly V[] {
|
|
@@ -49,7 +49,7 @@ export function objectFilter<K extends string | number | symbol, V>(
|
|
|
49
49
|
* Helper function to map the values in an object to another object with new values. Similar to the
|
|
50
50
|
* `Array.map` method, but works for objects.
|
|
51
51
|
*/
|
|
52
|
-
export function objectMap<K extends
|
|
52
|
+
export function objectMap<K extends number | string | symbol, V, U>(
|
|
53
53
|
object: Record<K, V>,
|
|
54
54
|
callback: (key: K, value: V) => U,
|
|
55
55
|
): ReadonlyRecord<K, U> {
|
|
@@ -72,7 +72,7 @@ export function objectMap<K extends string | number | symbol, V, U>(
|
|
|
72
72
|
* Note that the converted map will only have string keys, due to the nature of JavaScript objects
|
|
73
73
|
* only having string keys under the hood.
|
|
74
74
|
*/
|
|
75
|
-
export function objectToMap<K extends
|
|
75
|
+
export function objectToMap<K extends number | string | symbol, V>(
|
|
76
76
|
object: Record<K, V>,
|
|
77
77
|
): ReadonlyMap<K, V> {
|
|
78
78
|
const map = new Map<K, V>();
|
|
@@ -91,8 +91,8 @@ export function objectToMap<K extends string | number | symbol, V>(
|
|
|
91
91
|
* only having string keys under the hood.
|
|
92
92
|
*/
|
|
93
93
|
export function objectToReverseMap<
|
|
94
|
-
K extends
|
|
95
|
-
V extends
|
|
94
|
+
K extends number | string | symbol,
|
|
95
|
+
V extends number | string | symbol,
|
|
96
96
|
>(object: Record<K, V>): ReadonlyMap<V, K> {
|
|
97
97
|
const map = new Map<V, K>();
|
|
98
98
|
|
package/src/functions/set.ts
CHANGED
|
@@ -52,7 +52,7 @@ export function copySet<T>(oldSet: ReadonlySet<T>): ReadonlySet<T> {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/** Helper function to convert the keys of an object to a set. */
|
|
55
|
-
export function objectKeysToSet<K extends
|
|
55
|
+
export function objectKeysToSet<K extends number | string | symbol, V>(
|
|
56
56
|
object: Record<K, V>,
|
|
57
57
|
): ReadonlySet<K> {
|
|
58
58
|
const set = new Set<K>();
|
|
@@ -65,7 +65,7 @@ export function objectKeysToSet<K extends string | number | symbol, V>(
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/** Helper function to convert the values of an object to a set. */
|
|
68
|
-
export function objectValuesToSet<K extends
|
|
68
|
+
export function objectValuesToSet<K extends number | string | symbol, V>(
|
|
69
69
|
object: Record<K, V>,
|
|
70
70
|
): ReadonlySet<V> {
|
|
71
71
|
const set = new Set<V>();
|
package/src/functions/string.ts
CHANGED
|
@@ -47,8 +47,8 @@ export function capitalizeFirstLetter(string: string): string {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Helper function to replace all of the ampersands, less than signs, greater than signs, double
|
|
50
|
-
* quotes, and single quotes in a string with the escaped counterparts. For example,
|
|
51
|
-
* replaced with
|
|
50
|
+
* quotes, and single quotes in a string with the escaped counterparts. For example, `<` will be
|
|
51
|
+
* replaced with `<`.
|
|
52
52
|
*/
|
|
53
53
|
export function escapeHTMLCharacters(string: string): string {
|
|
54
54
|
return string
|
package/src/types/Immutable.ts
CHANGED
|
@@ -16,12 +16,12 @@ export type Immutable<T> = T extends ImmutablePrimitive
|
|
|
16
16
|
: ImmutableObject<T>;
|
|
17
17
|
|
|
18
18
|
type ImmutablePrimitive =
|
|
19
|
-
| undefined
|
|
20
|
-
| null
|
|
21
19
|
| boolean
|
|
22
|
-
| string
|
|
23
20
|
| number
|
|
24
|
-
|
|
|
21
|
+
| string
|
|
22
|
+
| Function // eslint-disable-line @typescript-eslint/no-unsafe-function-type
|
|
23
|
+
| null
|
|
24
|
+
| undefined;
|
|
25
25
|
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
26
26
|
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
27
27
|
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Helper type to represent a TypeScript `enum` at run-time. */
|
|
2
|
-
export type TranspiledEnum = Record<string,
|
|
2
|
+
export type TranspiledEnum = Record<string, number | string>;
|