complete-common 2.5.0 → 2.6.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,7 @@ 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[];
98
99
  /** Initializes an array with all elements containing the specified default value. */
99
100
  export declare function newArray<T>(length: number, value: T): readonly T[];
100
101
  /** 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,7 @@ 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[];
98
99
  /** Initializes an array with all elements containing the specified default value. */
99
100
  export declare function newArray<T>(length: number, value: T): readonly T[];
100
101
  /** 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,7 @@ 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[];
98
99
  /** Initializes an array with all elements containing the specified default value. */
99
100
  export declare function newArray<T>(length: number, value: T): readonly T[];
100
101
  /** 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,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GACjC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,CAQ7B;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,qBAAqB,CAAC,CAAC,EAErC,KAAK,EAAE,CAAC,EAAE,EACV,GAAG,gBAAgB,EAAE,SAAS,CAAC,EAAE,GAChC,OAAO,CAeT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAElC,KAAK,EAAE,CAAC,EAAE,EACV,GA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jB;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;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,GAAG,cAAc,EAAE,SAAS,CAAC,EAAE,GAC9B,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,OAAO,EAAE,CAEhE;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"}
@@ -27,6 +27,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
27
27
  * should be more performant for enums with around 52 or more elements.
28
28
  */
29
29
  export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
30
+ /**
31
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
32
+ *
33
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
34
+ */
35
+ export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
30
36
  /**
31
37
  * Helper function to throw an error if the provided value is equal to `null`.
32
38
  *
@@ -27,6 +27,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
27
27
  * should be more performant for enums with around 52 or more elements.
28
28
  */
29
29
  export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
30
+ /**
31
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
32
+ *
33
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
34
+ */
35
+ export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
30
36
  /**
31
37
  * Helper function to throw an error if the provided value is equal to `null`.
32
38
  *
@@ -27,6 +27,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
27
27
  * should be more performant for enums with around 52 or more elements.
28
28
  */
29
29
  export declare function assertEnumValue<T extends TranspiledEnum>(value: number | string, transpiledEnum: T, msg: string, set?: ReadonlySet<string | number>): asserts value is T[keyof T];
30
+ /**
31
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
32
+ *
33
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
34
+ */
35
+ export declare function assertIs<T extends abstract new (...args: unknown[]) => unknown>(value: unknown, constructor: T, msg: string): asserts value is InstanceType<T>;
30
36
  /**
31
37
  * Helper function to throw an error if the provided value is equal to `null`.
32
38
  *
@@ -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,4BAA4B,CAAC;AAIjE,+EAA+E;AAC/E,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,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,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
@@ -56,6 +56,11 @@ function assertEnumValue(value, transpiledEnum, msg, set) {
56
56
  throw new TypeError(msg);
57
57
  }
58
58
  }
59
+ function assertIs(value, constructor, msg) {
60
+ if (!(value instanceof constructor)) {
61
+ throw new TypeError(msg);
62
+ }
63
+ }
59
64
  function assertNotNull(value, ...[msg]) {
60
65
  if (value === null) {
61
66
  throw new TypeError(msg);
@@ -188,8 +193,8 @@ function includes(array, searchElement) {
188
193
  function includesAny(array, ...searchElements) {
189
194
  return searchElements.some((element) => array.includes(element));
190
195
  }
191
- function isArray(arg) {
192
- return Array.isArray(arg);
196
+ function isArray(variable) {
197
+ return Array.isArray(variable);
193
198
  }
194
199
  function newArray(length, value) {
195
200
  return Array.from({ length }, () => value);
@@ -542,6 +547,7 @@ exports.assertArray = assertArray;
542
547
  exports.assertBoolean = assertBoolean;
543
548
  exports.assertDefined = assertDefined;
544
549
  exports.assertEnumValue = assertEnumValue;
550
+ exports.assertIs = assertIs;
545
551
  exports.assertNotNull = assertNotNull;
546
552
  exports.assertNumber = assertNumber;
547
553
  exports.assertObject = assertObject;
package/dist/index.mjs CHANGED
@@ -54,6 +54,11 @@ function assertEnumValue(value, transpiledEnum, msg, set) {
54
54
  throw new TypeError(msg);
55
55
  }
56
56
  }
57
+ function assertIs(value, constructor, msg) {
58
+ if (!(value instanceof constructor)) {
59
+ throw new TypeError(msg);
60
+ }
61
+ }
57
62
  function assertNotNull(value, ...[msg]) {
58
63
  if (value === null) {
59
64
  throw new TypeError(msg);
@@ -186,8 +191,8 @@ function includes(array, searchElement) {
186
191
  function includesAny(array, ...searchElements) {
187
192
  return searchElements.some((element) => array.includes(element));
188
193
  }
189
- function isArray(arg) {
190
- return Array.isArray(arg);
194
+ function isArray(variable) {
195
+ return Array.isArray(variable);
191
196
  }
192
197
  function newArray(length, value) {
193
198
  return Array.from({ length }, () => value);
@@ -525,4 +530,4 @@ function* tupleKeys(tuple) {
525
530
 
526
531
  const ReadonlyMap = Map;
527
532
 
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 };
533
+ export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, 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, 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.6.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,8 @@ 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);
245
246
  }
246
247
 
247
248
  /** Initializes an array with all elements containing the specified default value. */
@@ -67,6 +67,23 @@ export function assertEnumValue<T extends TranspiledEnum>(
67
67
  }
68
68
  }
69
69
 
70
+ /**
71
+ * Helper function to throw an error if the provided value is not an instance of the expected class.
72
+ *
73
+ * This is useful to have TypeScript narrow a value to a specific type in a concise way.
74
+ */
75
+ export function assertIs<
76
+ T extends abstract new (...args: unknown[]) => unknown,
77
+ >(
78
+ value: unknown,
79
+ constructor: T,
80
+ msg: string,
81
+ ): asserts value is InstanceType<T> {
82
+ if (!(value instanceof constructor)) {
83
+ throw new TypeError(msg);
84
+ }
85
+ }
86
+
70
87
  /**
71
88
  * Helper function to throw an error if the provided value is equal to `null`.
72
89
  *
@@ -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