complete-common 2.5.0 → 2.7.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.
@@ -19,6 +19,8 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
19
19
  * array. If the specified element(s) are not found in the array, it will simply return a shallow
20
20
  * copy of the array.
21
21
  *
22
+ * If there is more than one matching element in the array, this function will remove all of them.
23
+ *
22
24
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
23
25
  */
24
26
  export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
@@ -42,8 +44,7 @@ export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove
42
44
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
43
45
  *
44
46
  * If there is more than one matching element in the array, this function will only remove the first
45
- * matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
46
- * function instead.
47
+ * one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
47
48
  *
48
49
  * @returns The removed elements. This will be an empty array if no elements were removed.
49
50
  */
@@ -94,7 +95,13 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
94
95
  */
95
96
  export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
96
97
  /** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
97
- export declare function isArray(arg: unknown): arg is unknown[];
98
+ export declare function isArray(variable: unknown): variable is unknown[];
99
+ /** Helper function to check every value of an array to see if it is a boolean. */
100
+ export declare function isArrayBoolean(variable: unknown): variable is boolean[];
101
+ /** Helper function to check every value of an array to see if it is a number. */
102
+ export declare function isArrayNumber(variable: unknown): variable is number[];
103
+ /** Helper function to check every value of an array to see if it is a string. */
104
+ export declare function isArrayString(variable: unknown): variable is string[];
98
105
  /** Initializes an array with all elements containing the specified default value. */
99
106
  export declare function newArray<T>(length: number, value: T): readonly T[];
100
107
  /** Helper function to sum every value in an array together. */
@@ -19,6 +19,8 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
19
19
  * array. If the specified element(s) are not found in the array, it will simply return a shallow
20
20
  * copy of the array.
21
21
  *
22
+ * If there is more than one matching element in the array, this function will remove all of them.
23
+ *
22
24
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
23
25
  */
24
26
  export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
@@ -42,8 +44,7 @@ export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove
42
44
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
43
45
  *
44
46
  * If there is more than one matching element in the array, this function will only remove the first
45
- * matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
46
- * function instead.
47
+ * one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
47
48
  *
48
49
  * @returns The removed elements. This will be an empty array if no elements were removed.
49
50
  */
@@ -94,7 +95,13 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
94
95
  */
95
96
  export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
96
97
  /** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
97
- export declare function isArray(arg: unknown): arg is unknown[];
98
+ export declare function isArray(variable: unknown): variable is unknown[];
99
+ /** Helper function to check every value of an array to see if it is a boolean. */
100
+ export declare function isArrayBoolean(variable: unknown): variable is boolean[];
101
+ /** Helper function to check every value of an array to see if it is a number. */
102
+ export declare function isArrayNumber(variable: unknown): variable is number[];
103
+ /** Helper function to check every value of an array to see if it is a string. */
104
+ export declare function isArrayString(variable: unknown): variable is string[];
98
105
  /** Initializes an array with all elements containing the specified default value. */
99
106
  export declare function newArray<T>(length: number, value: T): readonly T[];
100
107
  /** Helper function to sum every value in an array together. */
@@ -19,6 +19,8 @@ export declare function arrayEquals<T>(array1: readonly T[], array2: readonly T[
19
19
  * array. If the specified element(s) are not found in the array, it will simply return a shallow
20
20
  * copy of the array.
21
21
  *
22
+ * If there is more than one matching element in the array, this function will remove all of them.
23
+ *
22
24
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
23
25
  */
24
26
  export declare function arrayRemove<T>(originalArray: readonly T[], ...elementsToRemove: readonly T[]): readonly T[];
@@ -42,8 +44,7 @@ export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove
42
44
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
43
45
  *
44
46
  * If there is more than one matching element in the array, this function will only remove the first
45
- * matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
46
- * function instead.
47
+ * one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
47
48
  *
48
49
  * @returns The removed elements. This will be an empty array if no elements were removed.
49
50
  */
@@ -94,7 +95,13 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
94
95
  */
95
96
  export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
96
97
  /** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
97
- export declare function isArray(arg: unknown): arg is unknown[];
98
+ export declare function isArray(variable: unknown): variable is unknown[];
99
+ /** Helper function to check every value of an array to see if it is a boolean. */
100
+ export declare function isArrayBoolean(variable: unknown): variable is boolean[];
101
+ /** Helper function to check every value of an array to see if it is a number. */
102
+ export declare function isArrayNumber(variable: unknown): variable is number[];
103
+ /** Helper function to check every value of an array to see if it is a string. */
104
+ export declare function isArrayString(variable: unknown): variable is string[];
98
105
  /** Initializes an array with all elements containing the specified default value. */
99
106
  export declare function newArray<T>(length: number, value: T): readonly T[];
100
107
  /** Helper function to sum every value in an array together. */
@@ -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;AAI7D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,KAAK,EA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E,GAC9B,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,OAAO,EAAE,CAEhE;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,OAAO,EAAE,CAMvE;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,EAAE,CAMrE;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,EAAE,CAMrE;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"}
@@ -6,6 +6,21 @@
6
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
+ /**
10
+ * Helper function to throw an error if the provided value is not an array with every element being
11
+ * a boolean.
12
+ */
13
+ export declare function assertArrayBoolean(value: unknown, msg: string): asserts value is unknown[];
14
+ /**
15
+ * Helper function to throw an error if the provided value is not an array with every element being
16
+ * a number.
17
+ */
18
+ export declare function assertArrayNumber(value: unknown, msg: string): asserts value is unknown[];
19
+ /**
20
+ * Helper function to throw an error if the provided value is not an array with every element being
21
+ * a string.
22
+ */
23
+ export declare function assertArrayString(value: unknown, msg: string): asserts value is unknown[];
9
24
  /** Helper function to throw an error if the provided value is not a boolean. */
10
25
  export declare function assertBoolean(value: unknown, msg: string): asserts value is boolean;
11
26
  /**
@@ -27,6 +42,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
27
42
  * should be more performant for enums with around 52 or more elements.
28
43
  */
29
44
  export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
45
+ /**
46
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
47
+ *
48
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
49
+ */
50
+ export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
30
51
  /**
31
52
  * Helper function to throw an error if the provided value is equal to `null`.
32
53
  *
@@ -6,6 +6,21 @@
6
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
+ /**
10
+ * Helper function to throw an error if the provided value is not an array with every element being
11
+ * a boolean.
12
+ */
13
+ export declare function assertArrayBoolean(value: unknown, msg: string): asserts value is unknown[];
14
+ /**
15
+ * Helper function to throw an error if the provided value is not an array with every element being
16
+ * a number.
17
+ */
18
+ export declare function assertArrayNumber(value: unknown, msg: string): asserts value is unknown[];
19
+ /**
20
+ * Helper function to throw an error if the provided value is not an array with every element being
21
+ * a string.
22
+ */
23
+ export declare function assertArrayString(value: unknown, msg: string): asserts value is unknown[];
9
24
  /** Helper function to throw an error if the provided value is not a boolean. */
10
25
  export declare function assertBoolean(value: unknown, msg: string): asserts value is boolean;
11
26
  /**
@@ -27,6 +42,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
27
42
  * should be more performant for enums with around 52 or more elements.
28
43
  */
29
44
  export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
45
+ /**
46
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
47
+ *
48
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
49
+ */
50
+ export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
30
51
  /**
31
52
  * Helper function to throw an error if the provided value is equal to `null`.
32
53
  *
@@ -6,6 +6,21 @@
6
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
+ /**
10
+ * Helper function to throw an error if the provided value is not an array with every element being
11
+ * a boolean.
12
+ */
13
+ export declare function assertArrayBoolean(value: unknown, msg: string): asserts value is unknown[];
14
+ /**
15
+ * Helper function to throw an error if the provided value is not an array with every element being
16
+ * a number.
17
+ */
18
+ export declare function assertArrayNumber(value: unknown, msg: string): asserts value is unknown[];
19
+ /**
20
+ * Helper function to throw an error if the provided value is not an array with every element being
21
+ * a string.
22
+ */
23
+ export declare function assertArrayString(value: unknown, msg: string): asserts value is unknown[];
9
24
  /** Helper function to throw an error if the provided value is not a boolean. */
10
25
  export declare function assertBoolean(value: unknown, msg: string): asserts value is boolean;
11
26
  /**
@@ -27,6 +42,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
27
42
  * should be more performant for enums with around 52 or more elements.
28
43
  */
29
44
  export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
45
+ /**
46
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
47
+ *
48
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
49
+ */
50
+ export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
30
51
  /**
31
52
  * Helper function to throw an error if the provided value is equal to `null`.
32
53
  *
@@ -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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MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAuBR;AAED,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIzE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,UAAQ,GACd,MAAM,CAWR;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMxE"}
package/dist/index.cjs CHANGED
@@ -41,6 +41,24 @@ function assertArray(value, msg) {
41
41
  throw new TypeError(msg);
42
42
  }
43
43
  }
44
+ function assertArrayBoolean(value, msg) {
45
+ assertArray(value, msg);
46
+ if (value.some((element) => typeof element !== "boolean")) {
47
+ throw new TypeError(msg);
48
+ }
49
+ }
50
+ function assertArrayNumber(value, msg) {
51
+ assertArray(value, msg);
52
+ if (value.some((element) => typeof element !== "number")) {
53
+ throw new TypeError(msg);
54
+ }
55
+ }
56
+ function assertArrayString(value, msg) {
57
+ assertArray(value, msg);
58
+ if (value.some((element) => typeof element !== "string")) {
59
+ throw new TypeError(msg);
60
+ }
61
+ }
44
62
  function assertBoolean(value, msg) {
45
63
  if (typeof value !== "boolean") {
46
64
  throw new TypeError(msg);
@@ -56,6 +74,11 @@ function assertEnumValue(value, transpiledEnum, msg, set) {
56
74
  throw new TypeError(msg);
57
75
  }
58
76
  }
77
+ function assertIs(value, constructor, msg) {
78
+ if (!(value instanceof constructor)) {
79
+ throw new TypeError(msg);
80
+ }
81
+ }
59
82
  function assertNotNull(value, ...[msg]) {
60
83
  if (value === null) {
61
84
  throw new TypeError(msg);
@@ -188,8 +211,26 @@ function includes(array, searchElement) {
188
211
  function includesAny(array, ...searchElements) {
189
212
  return searchElements.some((element) => array.includes(element));
190
213
  }
191
- function isArray(arg) {
192
- return Array.isArray(arg);
214
+ function isArray(variable) {
215
+ return Array.isArray(variable);
216
+ }
217
+ function isArrayBoolean(variable) {
218
+ if (!isArray(variable)) {
219
+ return false;
220
+ }
221
+ return variable.every((element) => typeof element === "boolean");
222
+ }
223
+ function isArrayNumber(variable) {
224
+ if (!isArray(variable)) {
225
+ return false;
226
+ }
227
+ return variable.every((element) => typeof element === "string");
228
+ }
229
+ function isArrayString(variable) {
230
+ if (!isArray(variable)) {
231
+ return false;
232
+ }
233
+ return variable.every((element) => typeof element === "string");
193
234
  }
194
235
  function newArray(length, value) {
195
236
  return Array.from({ length }, () => value);
@@ -539,9 +580,13 @@ exports.arrayRemove = arrayRemove;
539
580
  exports.arrayRemoveAllInPlace = arrayRemoveAllInPlace;
540
581
  exports.arrayRemoveInPlace = arrayRemoveInPlace;
541
582
  exports.assertArray = assertArray;
583
+ exports.assertArrayBoolean = assertArrayBoolean;
584
+ exports.assertArrayNumber = assertArrayNumber;
585
+ exports.assertArrayString = assertArrayString;
542
586
  exports.assertBoolean = assertBoolean;
543
587
  exports.assertDefined = assertDefined;
544
588
  exports.assertEnumValue = assertEnumValue;
589
+ exports.assertIs = assertIs;
545
590
  exports.assertNotNull = assertNotNull;
546
591
  exports.assertNumber = assertNumber;
547
592
  exports.assertObject = assertObject;
@@ -570,6 +615,9 @@ exports.includes = includes;
570
615
  exports.includesAny = includesAny;
571
616
  exports.interfaceSatisfiesEnum = interfaceSatisfiesEnum;
572
617
  exports.isArray = isArray;
618
+ exports.isArrayBoolean = isArrayBoolean;
619
+ exports.isArrayNumber = isArrayNumber;
620
+ exports.isArrayString = isArrayString;
573
621
  exports.isEnumValue = isEnumValue;
574
622
  exports.isFirstLetterCapitalized = isFirstLetterCapitalized;
575
623
  exports.isKebabCase = isKebabCase;
package/dist/index.mjs CHANGED
@@ -39,6 +39,24 @@ function assertArray(value, msg) {
39
39
  throw new TypeError(msg);
40
40
  }
41
41
  }
42
+ function assertArrayBoolean(value, msg) {
43
+ assertArray(value, msg);
44
+ if (value.some((element) => typeof element !== "boolean")) {
45
+ throw new TypeError(msg);
46
+ }
47
+ }
48
+ function assertArrayNumber(value, msg) {
49
+ assertArray(value, msg);
50
+ if (value.some((element) => typeof element !== "number")) {
51
+ throw new TypeError(msg);
52
+ }
53
+ }
54
+ function assertArrayString(value, msg) {
55
+ assertArray(value, msg);
56
+ if (value.some((element) => typeof element !== "string")) {
57
+ throw new TypeError(msg);
58
+ }
59
+ }
42
60
  function assertBoolean(value, msg) {
43
61
  if (typeof value !== "boolean") {
44
62
  throw new TypeError(msg);
@@ -54,6 +72,11 @@ function assertEnumValue(value, transpiledEnum, msg, set) {
54
72
  throw new TypeError(msg);
55
73
  }
56
74
  }
75
+ function assertIs(value, constructor, msg) {
76
+ if (!(value instanceof constructor)) {
77
+ throw new TypeError(msg);
78
+ }
79
+ }
57
80
  function assertNotNull(value, ...[msg]) {
58
81
  if (value === null) {
59
82
  throw new TypeError(msg);
@@ -186,8 +209,26 @@ function includes(array, searchElement) {
186
209
  function includesAny(array, ...searchElements) {
187
210
  return searchElements.some((element) => array.includes(element));
188
211
  }
189
- function isArray(arg) {
190
- return Array.isArray(arg);
212
+ function isArray(variable) {
213
+ return Array.isArray(variable);
214
+ }
215
+ function isArrayBoolean(variable) {
216
+ if (!isArray(variable)) {
217
+ return false;
218
+ }
219
+ return variable.every((element) => typeof element === "boolean");
220
+ }
221
+ function isArrayNumber(variable) {
222
+ if (!isArray(variable)) {
223
+ return false;
224
+ }
225
+ return variable.every((element) => typeof element === "string");
226
+ }
227
+ function isArrayString(variable) {
228
+ if (!isArray(variable)) {
229
+ return false;
230
+ }
231
+ return variable.every((element) => typeof element === "string");
191
232
  }
192
233
  function newArray(length, value) {
193
234
  return Array.from({ length }, () => value);
@@ -525,4 +566,4 @@ function* tupleKeys(tuple) {
525
566
 
526
567
  const ReadonlyMap = Map;
527
568
 
528
- export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, 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, includesAny, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, 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 };
569
+ export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertArrayBoolean, assertArrayNumber, assertArrayString, assertBoolean, assertDefined, assertEnumValue, assertIs, 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, includesAny, interfaceSatisfiesEnum, isArray, isArrayBoolean, isArrayNumber, isArrayString, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, 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 };
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "complete-common",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Helper functions for TypeScript projects.",
5
- "keywords": [],
6
5
  "homepage": "https://complete-ts.github.io/",
7
6
  "bugs": {
8
7
  "url": "https://github.com/complete-ts/complete/issues"
@@ -23,24 +22,20 @@
23
22
  "types": "./dist/index.d.ts",
24
23
  "files": [
25
24
  "dist",
26
- "src",
27
- "LICENSE",
28
- "package.json",
29
- "README.md"
25
+ "src"
30
26
  ],
31
27
  "scripts": {
32
28
  "build": "tsx ./scripts/build.ts",
33
29
  "docs": "typedoc",
34
30
  "lint": "tsx ./scripts/lint.ts",
35
- "test": "glob \"./src/**/*.test.ts\" --cmd=\"node --import tsx --test --test-reporter spec\""
31
+ "test": "tsx --test"
36
32
  },
37
33
  "devDependencies": {
38
- "@types/node": "24.0.15",
39
- "complete-node": "7.4.3",
34
+ "@types/node": "24.7.1",
35
+ "complete-node": "12.2.0",
40
36
  "eslint-plugin-sort-exports": "0.9.1",
41
- "glob": "11.0.3",
42
- "typescript": "5.8.3",
43
- "typescript-eslint": "8.37.0",
44
- "unbuild": "3.5.0"
37
+ "typescript": "5.9.3",
38
+ "typescript-eslint": "8.46.0",
39
+ "unbuild": "3.6.1"
45
40
  }
46
41
  }
@@ -48,6 +48,8 @@ export function arrayEquals<T>(
48
48
  * array. If the specified element(s) are not found in the array, it will simply return a shallow
49
49
  * copy of the array.
50
50
  *
51
+ * If there is more than one matching element in the array, this function will remove all of them.
52
+ *
51
53
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
52
54
  */
53
55
  export function arrayRemove<T>(
@@ -106,8 +108,7 @@ export function arrayRemoveAllInPlace<T>(
106
108
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
107
109
  *
108
110
  * If there is more than one matching element in the array, this function will only remove the first
109
- * matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
110
- * function instead.
111
+ * one. If you want to remove all of the elements, use the `arrayRemoveAllInPlace` function instead.
111
112
  *
112
113
  * @returns The removed elements. This will be an empty array if no elements were removed.
113
114
  */
@@ -240,8 +241,35 @@ export function includesAny<T>(
240
241
  }
241
242
 
242
243
  /** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
243
- export function isArray(arg: unknown): arg is unknown[] {
244
- return Array.isArray(arg);
244
+ export function isArray(variable: unknown): variable is unknown[] {
245
+ return Array.isArray(variable);
246
+ }
247
+
248
+ /** Helper function to check every value of an array to see if it is a boolean. */
249
+ export function isArrayBoolean(variable: unknown): variable is boolean[] {
250
+ if (!isArray(variable)) {
251
+ return false;
252
+ }
253
+
254
+ return variable.every((element) => typeof element === "boolean");
255
+ }
256
+
257
+ /** Helper function to check every value of an array to see if it is a number. */
258
+ export function isArrayNumber(variable: unknown): variable is number[] {
259
+ if (!isArray(variable)) {
260
+ return false;
261
+ }
262
+
263
+ return variable.every((element) => typeof element === "string");
264
+ }
265
+
266
+ /** Helper function to check every value of an array to see if it is a string. */
267
+ export function isArrayString(variable: unknown): variable is string[] {
268
+ if (!isArray(variable)) {
269
+ return false;
270
+ }
271
+
272
+ return variable.every((element) => typeof element === "string");
245
273
  }
246
274
 
247
275
  /** Initializes an array with all elements containing the specified default value. */
@@ -18,6 +18,51 @@ export function assertArray(
18
18
  }
19
19
  }
20
20
 
21
+ /**
22
+ * Helper function to throw an error if the provided value is not an array with every element being
23
+ * a boolean.
24
+ */
25
+ export function assertArrayBoolean(
26
+ value: unknown,
27
+ msg: string,
28
+ ): asserts value is unknown[] {
29
+ assertArray(value, msg);
30
+
31
+ if (value.some((element) => typeof element !== "boolean")) {
32
+ throw new TypeError(msg);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Helper function to throw an error if the provided value is not an array with every element being
38
+ * a number.
39
+ */
40
+ export function assertArrayNumber(
41
+ value: unknown,
42
+ msg: string,
43
+ ): asserts value is unknown[] {
44
+ assertArray(value, msg);
45
+
46
+ if (value.some((element) => typeof element !== "number")) {
47
+ throw new TypeError(msg);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Helper function to throw an error if the provided value is not an array with every element being
53
+ * a string.
54
+ */
55
+ export function assertArrayString(
56
+ value: unknown,
57
+ msg: string,
58
+ ): asserts value is unknown[] {
59
+ assertArray(value, msg);
60
+
61
+ if (value.some((element) => typeof element !== "string")) {
62
+ throw new TypeError(msg);
63
+ }
64
+ }
65
+
21
66
  /** Helper function to throw an error if the provided value is not a boolean. */
22
67
  export function assertBoolean(
23
68
  value: unknown,
@@ -67,6 +112,23 @@ export function assertEnumValue<T extends TranspiledEnum>(
67
112
  }
68
113
  }
69
114
 
115
+ /**
116
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
117
+ *
118
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
119
+ */
120
+ export function assertIs<
121
+ T extends abstract new (...args: unknown[]) => unknown,
122
+ >(
123
+ value: unknown,
124
+ constructor: T,
125
+ msg: string,
126
+ ): asserts value is InstanceType<T> {
127
+ if (!(value instanceof constructor)) {
128
+ throw new TypeError(msg);
129
+ }
130
+ }
131
+
70
132
  /**
71
133
  * Helper function to throw an error if the provided value is equal to `null`.
72
134
  *
@@ -1,5 +1,5 @@
1
1
  import { equal } from "node:assert";
2
- import test, { describe } from "node:test";
2
+ import { describe, test } from "node:test";
3
3
  import {
4
4
  hasDiacritic,
5
5
  hasEmoji,
@@ -227,6 +227,7 @@ export function parseSemanticVersion(versionString: string):
227
227
  return { majorVersion, minorVersion, patchVersion };
228
228
  }
229
229
 
230
+ /* eslint-disable jsdoc/escape-inline-tags */
230
231
  /**
231
232
  * Helper function to remove lines from a multi-line string. This function looks for a "-start" and
232
233
  * a "-end" suffix after the marker. Lines with markets will be completely removed from the output.
@@ -249,6 +250,7 @@ export function parseSemanticVersion(versionString: string):
249
250
  * line4
250
251
  * ```
251
252
  */
253
+ /* eslint-enable jsdoc/escape-inline-tags */
252
254
  export function removeLinesBetweenMarkers(
253
255
  string: string,
254
256
  marker: string,
@@ -1,5 +1,5 @@
1
1
  import { deepStrictEqual, strictEqual } from "node:assert";
2
- import test, { describe } from "node:test";
2
+ import { describe, test } from "node:test";
3
3
  import { assertDefined, assertNotNull } from "./assert.js";
4
4
  import { eRange, iRange, parseFloatSafe, parseIntSafe } from "./utils.js";
5
5
 
@@ -372,7 +372,7 @@ describe("parseFloatSafe", () => {
372
372
  });
373
373
 
374
374
  test("bigint", () => {
375
- const result = parseFloatSafe(BigInt(1) as unknown as string);
375
+ const result = parseFloatSafe(1n as unknown as string);
376
376
  strictEqual(result, undefined);
377
377
  });
378
378
 
@@ -693,7 +693,7 @@ describe("parseIntSafe", () => {
693
693
  });
694
694
 
695
695
  test("bigint", () => {
696
- const result = parseIntSafe(BigInt(1) as unknown as string);
696
+ const result = parseIntSafe(1n as unknown as string);
697
697
  strictEqual(result, undefined);
698
698
  });
699
699