complete-common 1.2.0 → 1.3.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.
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
/** Helper function to throw an error if the provided value is not an array. */
|
|
7
|
+
export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
|
|
6
8
|
/** Helper function to throw an error if the provided value is not a boolean. */
|
|
7
9
|
export declare function assertBoolean(value: unknown, msg: string): asserts value is boolean;
|
|
8
10
|
/**
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
/** Helper function to throw an error if the provided value is not an array. */
|
|
7
|
+
export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
|
|
6
8
|
/** Helper function to throw an error if the provided value is not a boolean. */
|
|
7
9
|
export declare function assertBoolean(value: unknown, msg: string): asserts value is boolean;
|
|
8
10
|
/**
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
/** Helper function to throw an error if the provided value is not an array. */
|
|
7
|
+
export declare function assertArray(value: unknown, msg: string): asserts value is unknown[];
|
|
6
8
|
/** Helper function to throw an error if the provided value is not a boolean. */
|
|
7
9
|
export declare function assertBoolean(value: unknown, msg: string): asserts value is boolean;
|
|
8
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/functions/assert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,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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;;;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;;;;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
|
@@ -10,6 +10,11 @@ function isObject(variable) {
|
|
|
10
10
|
return typeof variable === "object" && variable !== null && !Array.isArray(variable);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function assertArray(value, msg) {
|
|
14
|
+
if (!Array.isArray(value)) {
|
|
15
|
+
throw new TypeError(msg);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
13
18
|
function assertBoolean(value, msg) {
|
|
14
19
|
if (typeof value !== "boolean") {
|
|
15
20
|
throw new TypeError(msg);
|
|
@@ -510,6 +515,7 @@ exports.arrayCopyTwoDimensional = arrayCopyTwoDimensional;
|
|
|
510
515
|
exports.arrayEquals = arrayEquals;
|
|
511
516
|
exports.arrayRemove = arrayRemove;
|
|
512
517
|
exports.arrayRemoveInPlace = arrayRemoveInPlace;
|
|
518
|
+
exports.assertArray = assertArray;
|
|
513
519
|
exports.assertBoolean = assertBoolean;
|
|
514
520
|
exports.assertDefined = assertDefined;
|
|
515
521
|
exports.assertNotNull = assertNotNull;
|
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,11 @@ function isObject(variable) {
|
|
|
8
8
|
return typeof variable === "object" && variable !== null && !Array.isArray(variable);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
function assertArray(value, msg) {
|
|
12
|
+
if (!Array.isArray(value)) {
|
|
13
|
+
throw new TypeError(msg);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
function assertBoolean(value, msg) {
|
|
12
17
|
if (typeof value !== "boolean") {
|
|
13
18
|
throw new TypeError(msg);
|
|
@@ -498,4 +503,4 @@ function* tupleKeys(tuple) {
|
|
|
498
503
|
|
|
499
504
|
const ReadonlyMap = Map;
|
|
500
505
|
|
|
501
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveInPlace, assertBoolean, assertDefined, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, kebabCaseToCamelCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToReadonlySet, objectKeysToSet, objectToMap, objectToReadonlyMap, objectToReverseMap, objectToReverseReadonlyMap, objectValuesToReadonlySet, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
506
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveInPlace, assertArray, assertBoolean, assertDefined, assertNotNull, assertNumber, assertObject, assertString, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, kebabCaseToCamelCase, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToReadonlySet, objectKeysToSet, objectToMap, objectToReadonlyMap, objectToReverseMap, objectToReverseReadonlyMap, objectValuesToReadonlySet, 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/assert.ts
CHANGED
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
|
|
7
7
|
import { isObject } from "./types.js";
|
|
8
8
|
|
|
9
|
+
/** Helper function to throw an error if the provided value is not an array. */
|
|
10
|
+
export function assertArray(
|
|
11
|
+
value: unknown,
|
|
12
|
+
msg: string,
|
|
13
|
+
): asserts value is unknown[] {
|
|
14
|
+
if (!Array.isArray(value)) {
|
|
15
|
+
throw new TypeError(msg);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
/** Helper function to throw an error if the provided value is not a boolean. */
|
|
10
20
|
export function assertBoolean(
|
|
11
21
|
value: unknown,
|