complete-common 2.9.0 → 2.10.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/README.md +1 -1
- package/dist/functions/assert.d.cts +2 -0
- package/dist/functions/assert.d.mts +2 -0
- package/dist/functions/assert.d.ts +2 -0
- package/dist/functions/assert.d.ts.map +1 -1
- package/dist/functions/utils.d.cts +2 -2
- package/dist/functions/utils.d.mts +2 -2
- package/dist/functions/utils.d.ts +2 -2
- package/dist/index.cjs +7 -0
- package/dist/index.mjs +7 -1
- package/package.json +4 -4
- package/src/functions/assert.ts +12 -0
- package/src/functions/utils.ts +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/complete-common)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`complete-common` is a library that contains basic helper functions for a typical [TypeScript](https://www.typescriptlang.org/) project, such as [`iRange`](/complete-common/functions/utils#irange).
|
|
6
6
|
|
|
7
7
|
Please see the [docs](https://complete-ts.github.io/complete-common) for more information.
|
|
@@ -72,4 +72,6 @@ export declare function assertNumber(value: unknown, msg: string): asserts value
|
|
|
72
72
|
export declare function assertObject(value: unknown, msg: string): asserts value is Record<string, unknown>;
|
|
73
73
|
/** Helper function to throw an error if the provided value is not a string. */
|
|
74
74
|
export declare function assertString(value: unknown, msg: string): asserts value is string;
|
|
75
|
+
/** Helper function to throw an error if the provided value is not a string or an empty string. */
|
|
76
|
+
export declare function assertStringNotEmpty(value: unknown, msg: string): asserts value is string;
|
|
75
77
|
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -72,4 +72,6 @@ export declare function assertNumber(value: unknown, msg: string): asserts value
|
|
|
72
72
|
export declare function assertObject(value: unknown, msg: string): asserts value is Record<string, unknown>;
|
|
73
73
|
/** Helper function to throw an error if the provided value is not a string. */
|
|
74
74
|
export declare function assertString(value: unknown, msg: string): asserts value is string;
|
|
75
|
+
/** Helper function to throw an error if the provided value is not a string or an empty string. */
|
|
76
|
+
export declare function assertStringNotEmpty(value: unknown, msg: string): asserts value is string;
|
|
75
77
|
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -72,4 +72,6 @@ export declare function assertNumber(value: unknown, msg: string): asserts value
|
|
|
72
72
|
export declare function assertObject(value: unknown, msg: string): asserts value is Record<string, unknown>;
|
|
73
73
|
/** Helper function to throw an error if the provided value is not a string. */
|
|
74
74
|
export declare function assertString(value: unknown, msg: string): asserts value is string;
|
|
75
|
+
/** Helper function to throw an error if the provided value is not a string or an empty string. */
|
|
76
|
+
export declare function assertStringNotEmpty(value: unknown, msg: string): asserts value is string;
|
|
75
77
|
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -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;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE,CAM5B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,OAAO,EAAE,CAM5B;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OA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AC,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;AAED,kGAAkG;AAClG,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,MAAM,CAMzB"}
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function eRange(start: number, end?: number, increment?: number): Generator<number>;
|
|
35
35
|
/**
|
|
36
|
-
* Helper function to get an
|
|
37
|
-
* (The "i" in the function name stands for inclusive.)
|
|
36
|
+
* Helper function to get an iterator of of integers with the specified range, inclusive on both
|
|
37
|
+
* ends. (The "i" in the function name stands for inclusive.)
|
|
38
38
|
*
|
|
39
39
|
* If the end is lower than the start, then an empty range will be returned.
|
|
40
40
|
*
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function eRange(start: number, end?: number, increment?: number): Generator<number>;
|
|
35
35
|
/**
|
|
36
|
-
* Helper function to get an
|
|
37
|
-
* (The "i" in the function name stands for inclusive.)
|
|
36
|
+
* Helper function to get an iterator of of integers with the specified range, inclusive on both
|
|
37
|
+
* ends. (The "i" in the function name stands for inclusive.)
|
|
38
38
|
*
|
|
39
39
|
* If the end is lower than the start, then an empty range will be returned.
|
|
40
40
|
*
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function eRange(start: number, end?: number, increment?: number): Generator<number>;
|
|
35
35
|
/**
|
|
36
|
-
* Helper function to get an
|
|
37
|
-
* (The "i" in the function name stands for inclusive.)
|
|
36
|
+
* Helper function to get an iterator of of integers with the specified range, inclusive on both
|
|
37
|
+
* ends. (The "i" in the function name stands for inclusive.)
|
|
38
38
|
*
|
|
39
39
|
* If the end is lower than the start, then an empty range will be returned.
|
|
40
40
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -104,6 +104,12 @@ function assertString(value, msg) {
|
|
|
104
104
|
throw new TypeError(msg);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
function assertStringNotEmpty(value, msg) {
|
|
108
|
+
assertString(value, msg);
|
|
109
|
+
if (value === "") {
|
|
110
|
+
throw new TypeError(msg);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
107
113
|
|
|
108
114
|
function getRandomInt(min, max, exceptions = []) {
|
|
109
115
|
min = Math.ceil(min);
|
|
@@ -600,6 +606,7 @@ exports.assertNotNull = assertNotNull;
|
|
|
600
606
|
exports.assertNumber = assertNumber;
|
|
601
607
|
exports.assertObject = assertObject;
|
|
602
608
|
exports.assertString = assertString;
|
|
609
|
+
exports.assertStringNotEmpty = assertStringNotEmpty;
|
|
603
610
|
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
604
611
|
exports.clamp = clamp;
|
|
605
612
|
exports.combineSets = combineSets;
|
package/dist/index.mjs
CHANGED
|
@@ -102,6 +102,12 @@ function assertString(value, msg) {
|
|
|
102
102
|
throw new TypeError(msg);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
function assertStringNotEmpty(value, msg) {
|
|
106
|
+
assertString(value, msg);
|
|
107
|
+
if (value === "") {
|
|
108
|
+
throw new TypeError(msg);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
105
111
|
|
|
106
112
|
function getRandomInt(min, max, exceptions = []) {
|
|
107
113
|
min = Math.ceil(min);
|
|
@@ -574,4 +580,4 @@ function* tupleKeys(tuple) {
|
|
|
574
580
|
|
|
575
581
|
const ReadonlyMap = Map;
|
|
576
582
|
|
|
577
|
-
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, assertInteger, 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, isASCII, 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 };
|
|
583
|
+
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, assertInteger, assertIs, assertNotNull, assertNumber, assertObject, assertString, assertStringNotEmpty, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterMap, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isASCII, 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
5
|
"homepage": "https://complete-ts.github.io/",
|
|
6
6
|
"bugs": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"test": "tsx --test"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "24.
|
|
35
|
-
"complete-node": "12.
|
|
34
|
+
"@types/node": "24.10.1",
|
|
35
|
+
"complete-node": "12.3.0",
|
|
36
36
|
"eslint-plugin-sort-exports": "0.9.1",
|
|
37
37
|
"typescript": "5.9.3",
|
|
38
|
-
"typescript-eslint": "8.
|
|
38
|
+
"typescript-eslint": "8.48.0",
|
|
39
39
|
"unbuild": "3.6.1"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/functions/assert.ts
CHANGED
|
@@ -196,3 +196,15 @@ export function assertString(
|
|
|
196
196
|
throw new TypeError(msg);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
+
|
|
200
|
+
/** Helper function to throw an error if the provided value is not a string or an empty string. */
|
|
201
|
+
export function assertStringNotEmpty(
|
|
202
|
+
value: unknown,
|
|
203
|
+
msg: string,
|
|
204
|
+
): asserts value is string {
|
|
205
|
+
assertString(value, msg);
|
|
206
|
+
|
|
207
|
+
if (value === "") {
|
|
208
|
+
throw new TypeError(msg);
|
|
209
|
+
}
|
|
210
|
+
}
|
package/src/functions/utils.ts
CHANGED
|
@@ -54,8 +54,8 @@ export function* eRange(
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Helper function to get an
|
|
58
|
-
* (The "i" in the function name stands for inclusive.)
|
|
57
|
+
* Helper function to get an iterator of of integers with the specified range, inclusive on both
|
|
58
|
+
* ends. (The "i" in the function name stands for inclusive.)
|
|
59
59
|
*
|
|
60
60
|
* If the end is lower than the start, then an empty range will be returned.
|
|
61
61
|
*
|