complete-common 2.6.0 → 2.7.1
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/functions/string.d.ts.map +1 -1
- package/dist/index.cjs +43 -1
- package/dist/index.mjs +38 -2
- package/package.json +3 -3
- package/src/functions/array.ts +27 -0
- package/src/functions/assert.ts +45 -0
- package/src/functions/string.test.ts +23 -8
- package/src/functions/string.ts +5 -2
|
@@ -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,uBA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E,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,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,GACj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d,WAAW,EAAE,CAAC,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,KAAK,IAAI,YAAY,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsBH,kEAAkE;AAClE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU5D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAqB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gG;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);
|
|
@@ -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
|
}
|
|
@@ -364,7 +400,7 @@ function todo(...args) {
|
|
|
364
400
|
}
|
|
365
401
|
|
|
366
402
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
367
|
-
const EMOJI_REGEX = /(\p{Extended_Pictographic}
|
|
403
|
+
const EMOJI_REGEX = /(\p{Extended_Pictographic}|[#*0-9]\uFE0F?\u20E3)/u;
|
|
368
404
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
369
405
|
const KEBAB_CASE_REGEX = /^[\da-z]+(?:-[\da-z]+)*$/;
|
|
370
406
|
const SEMANTIC_VERSION_REGEX = /^v*(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
|
|
@@ -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
|
}
|
|
@@ -362,7 +398,7 @@ function todo(...args) {
|
|
|
362
398
|
}
|
|
363
399
|
|
|
364
400
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
365
|
-
const EMOJI_REGEX = /(\p{Extended_Pictographic}
|
|
401
|
+
const EMOJI_REGEX = /(\p{Extended_Pictographic}|[#*0-9]\uFE0F?\u20E3)/u;
|
|
366
402
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
367
403
|
const KEBAB_CASE_REGEX = /^[\da-z]+(?:-[\da-z]+)*$/;
|
|
368
404
|
const SEMANTIC_VERSION_REGEX = /^v*(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
5
|
"homepage": "https://complete-ts.github.io/",
|
|
6
6
|
"bugs": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"test": "tsx --test"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "24.7.
|
|
35
|
-
"complete-node": "12.2.
|
|
34
|
+
"@types/node": "24.7.2",
|
|
35
|
+
"complete-node": "12.2.1",
|
|
36
36
|
"eslint-plugin-sort-exports": "0.9.1",
|
|
37
37
|
"typescript": "5.9.3",
|
|
38
38
|
"typescript-eslint": "8.46.0",
|
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,
|
|
@@ -9,14 +9,27 @@ import {
|
|
|
9
9
|
} from "./string.js";
|
|
10
10
|
|
|
11
11
|
describe("hasEmoji", () => {
|
|
12
|
-
test("should return true for string with emoji", () => {
|
|
12
|
+
test("should return true for string with normal emoji", () => {
|
|
13
13
|
equal(hasEmoji("Hello 😃 World"), true);
|
|
14
|
-
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("should return true for string with keycap emoji", () => {
|
|
17
|
+
equal(hasEmoji("This is a keycap emoji: #️⃣"), true);
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
test("should return false for string without emoji", () => {
|
|
18
21
|
equal(hasEmoji("Hello World"), false);
|
|
19
|
-
equal(
|
|
22
|
+
equal(
|
|
23
|
+
hasEmoji(`
|
|
24
|
+
# Some Markdown Title
|
|
25
|
+
|
|
26
|
+
This page is for people who like [cake](https://en.wikipedia.org/wiki/Cake).
|
|
27
|
+
|
|
28
|
+
- Run \`npm run cake\` to get cake.
|
|
29
|
+
- Run \`npm run pie\` to get pie.
|
|
30
|
+
`),
|
|
31
|
+
false,
|
|
32
|
+
);
|
|
20
33
|
});
|
|
21
34
|
|
|
22
35
|
test("should handle empty string", () => {
|
|
@@ -123,9 +136,11 @@ describe("trimPrefix", () => {
|
|
|
123
136
|
});
|
|
124
137
|
|
|
125
138
|
describe("trimSuffix", () => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
test(() => {
|
|
140
|
+
equal(trimSuffix("foo", ""), "foo");
|
|
141
|
+
equal(trimSuffix("foo", "o"), "fo");
|
|
142
|
+
equal(trimSuffix("foo", "oo"), "f");
|
|
143
|
+
equal(trimSuffix("foo", "foo"), "");
|
|
144
|
+
equal(trimSuffix("foo", "1foo"), "foo");
|
|
145
|
+
});
|
|
131
146
|
});
|
package/src/functions/string.ts
CHANGED
|
@@ -11,8 +11,11 @@ import { parseIntSafe } from "./utils.js";
|
|
|
11
11
|
|
|
12
12
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* - We can't use `/\p{Emoji}/u` because it has a false positive on "#" characters.
|
|
16
|
+
* - We can't use `/\p{Extended_Pictographic}/u` because it has a false negative on keycap emojis.
|
|
17
|
+
*/
|
|
18
|
+
const EMOJI_REGEX = /(\p{Extended_Pictographic}|[#*0-9]\uFE0F?\u20E3)/u;
|
|
16
19
|
|
|
17
20
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
18
21
|
const KEBAB_CASE_REGEX = /^[\da-z]+(?:-[\da-z]+)*$/;
|