complete-common 2.6.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.
- package/dist/functions/array.d.cts +6 -0
- package/dist/functions/array.d.mts +6 -0
- package/dist/functions/array.d.ts +6 -0
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/assert.d.cts +15 -0
- package/dist/functions/assert.d.mts +15 -0
- package/dist/functions/assert.d.ts +15 -0
- package/dist/functions/assert.d.ts.map +1 -1
- package/dist/index.cjs +42 -0
- package/dist/index.mjs +37 -1
- package/package.json +1 -1
- package/src/functions/array.ts +27 -0
- package/src/functions/assert.ts +45 -0
|
@@ -96,6 +96,12 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
|
|
|
96
96
|
export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
|
|
97
97
|
/** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
|
|
98
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[];
|
|
99
105
|
/** Initializes an array with all elements containing the specified default value. */
|
|
100
106
|
export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
101
107
|
/** Helper function to sum every value in an array together. */
|
|
@@ -96,6 +96,12 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
|
|
|
96
96
|
export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
|
|
97
97
|
/** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
|
|
98
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[];
|
|
99
105
|
/** Initializes an array with all elements containing the specified default value. */
|
|
100
106
|
export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
101
107
|
/** Helper function to sum every value in an array together. */
|
|
@@ -96,6 +96,12 @@ export declare function includes<T, TupleElement extends WidenLiteral<T>>(array:
|
|
|
96
96
|
export declare function includesAny<T>(array: readonly T[], ...searchElements: readonly T[]): boolean;
|
|
97
97
|
/** A wrapper around `Array.isArray` that narrows to `unknown[]` instead of `any[]`. */
|
|
98
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[];
|
|
99
105
|
/** Initializes an array with all elements containing the specified default value. */
|
|
100
106
|
export declare function newArray<T>(length: number, value: T): readonly T[];
|
|
101
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,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GAC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F;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
|
/**
|
|
@@ -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
|
/**
|
|
@@ -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
|
/**
|
|
@@ -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,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE,CAI5B;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,CAI1B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAC7B,CAAC,MAAM,CAAC,GACR;IACE,iFAAiF;CAClF,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAIxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EACtD,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,cAAc,EAAE,CAAC,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,GACjC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAI7B;AAED;;;;G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AAY,CAAC,CAAC,CAAC,CAIlC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GACxB,CAAC,MAAM,CAAC,GACR;IACE,4EAA4E;CAC7E,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAInC;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,MAAM,CAIzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI1C;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,MAAM,CAIzB"}
|
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);
|
|
@@ -196,6 +214,24 @@ function includesAny(array, ...searchElements) {
|
|
|
196
214
|
function isArray(variable) {
|
|
197
215
|
return Array.isArray(variable);
|
|
198
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");
|
|
234
|
+
}
|
|
199
235
|
function newArray(length, value) {
|
|
200
236
|
return Array.from({ length }, () => value);
|
|
201
237
|
}
|
|
@@ -544,6 +580,9 @@ exports.arrayRemove = arrayRemove;
|
|
|
544
580
|
exports.arrayRemoveAllInPlace = arrayRemoveAllInPlace;
|
|
545
581
|
exports.arrayRemoveInPlace = arrayRemoveInPlace;
|
|
546
582
|
exports.assertArray = assertArray;
|
|
583
|
+
exports.assertArrayBoolean = assertArrayBoolean;
|
|
584
|
+
exports.assertArrayNumber = assertArrayNumber;
|
|
585
|
+
exports.assertArrayString = assertArrayString;
|
|
547
586
|
exports.assertBoolean = assertBoolean;
|
|
548
587
|
exports.assertDefined = assertDefined;
|
|
549
588
|
exports.assertEnumValue = assertEnumValue;
|
|
@@ -576,6 +615,9 @@ exports.includes = includes;
|
|
|
576
615
|
exports.includesAny = includesAny;
|
|
577
616
|
exports.interfaceSatisfiesEnum = interfaceSatisfiesEnum;
|
|
578
617
|
exports.isArray = isArray;
|
|
618
|
+
exports.isArrayBoolean = isArrayBoolean;
|
|
619
|
+
exports.isArrayNumber = isArrayNumber;
|
|
620
|
+
exports.isArrayString = isArrayString;
|
|
579
621
|
exports.isEnumValue = isEnumValue;
|
|
580
622
|
exports.isFirstLetterCapitalized = isFirstLetterCapitalized;
|
|
581
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);
|
|
@@ -194,6 +212,24 @@ function includesAny(array, ...searchElements) {
|
|
|
194
212
|
function isArray(variable) {
|
|
195
213
|
return Array.isArray(variable);
|
|
196
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");
|
|
232
|
+
}
|
|
197
233
|
function newArray(length, value) {
|
|
198
234
|
return Array.from({ length }, () => value);
|
|
199
235
|
}
|
|
@@ -530,4 +566,4 @@ function* tupleKeys(tuple) {
|
|
|
530
566
|
|
|
531
567
|
const ReadonlyMap = Map;
|
|
532
568
|
|
|
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 };
|
|
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
package/src/functions/array.ts
CHANGED
|
@@ -245,6 +245,33 @@ export function isArray(variable: unknown): variable is unknown[] {
|
|
|
245
245
|
return Array.isArray(variable);
|
|
246
246
|
}
|
|
247
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");
|
|
273
|
+
}
|
|
274
|
+
|
|
248
275
|
/** Initializes an array with all elements containing the specified default value. */
|
|
249
276
|
export function newArray<T>(length: number, value: T): readonly T[] {
|
|
250
277
|
return Array.from({ length }, () => value);
|
package/src/functions/assert.ts
CHANGED
|
@@ -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,
|