complete-common 2.0.0 → 2.2.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 +2 -2
- package/dist/functions/array.d.mts +2 -2
- package/dist/functions/array.d.ts +2 -2
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/string.d.cts +3 -1
- package/dist/functions/string.d.mts +3 -1
- package/dist/functions/string.d.ts +3 -1
- package/dist/functions/string.d.ts.map +1 -1
- package/dist/index.cjs +6 -1
- package/dist/index.mjs +6 -2
- package/package.json +5 -5
- package/src/functions/array.ts +2 -2
- package/src/functions/string.ts +8 -6
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { WidenLiteral } from "../
|
|
6
|
+
import type { WidenLiteral } from "../types/WidenLiteral.js";
|
|
7
7
|
/**
|
|
8
8
|
* Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
|
|
9
9
|
* copied (using the spread operator).
|
|
10
10
|
*/
|
|
11
|
-
export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): readonly T[]
|
|
11
|
+
export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): ReadonlyArray<readonly T[]>;
|
|
12
12
|
/**
|
|
13
13
|
* Helper function for determining if two arrays contain the exact same elements. Note that this
|
|
14
14
|
* only performs a shallow comparison.
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { WidenLiteral } from "../
|
|
6
|
+
import type { WidenLiteral } from "../types/WidenLiteral.js";
|
|
7
7
|
/**
|
|
8
8
|
* Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
|
|
9
9
|
* copied (using the spread operator).
|
|
10
10
|
*/
|
|
11
|
-
export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): readonly T[]
|
|
11
|
+
export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): ReadonlyArray<readonly T[]>;
|
|
12
12
|
/**
|
|
13
13
|
* Helper function for determining if two arrays contain the exact same elements. Note that this
|
|
14
14
|
* only performs a shallow comparison.
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { WidenLiteral } from "../
|
|
6
|
+
import type { WidenLiteral } from "../types/WidenLiteral.js";
|
|
7
7
|
/**
|
|
8
8
|
* Helper function to copy a two-dimensional array. Note that the sub-arrays will only be shallow
|
|
9
9
|
* copied (using the spread operator).
|
|
10
10
|
*/
|
|
11
|
-
export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): readonly T[]
|
|
11
|
+
export declare function arrayCopyTwoDimensional<T>(array: ReadonlyArray<readonly T[]>): ReadonlyArray<readonly T[]>;
|
|
12
12
|
/**
|
|
13
13
|
* Helper function for determining if two arrays contain the exact same elements. Note that this
|
|
14
14
|
* only performs a shallow comparison.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
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,kBAAkB,CAAC,CAAC,EAElC,KAAK,EAAE,CAAC,EAAE,EACV,GAAG,gBAAgB,EAAE,SAAS,CAAC,EAAE,GAChC,SAAS,CAAC,EAAE,CAYd;AAED,0EAA0E;AAE1E,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAEjD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAClC,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,GAAG,SAAS,GACxC,SAAS,IAAI,EAAE,CAWjB;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,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,EAAE,CAEtD;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"}
|
|
@@ -41,8 +41,10 @@ export declare function isKebabCase(string: string): boolean;
|
|
|
41
41
|
* @see https://semver.org/
|
|
42
42
|
*/
|
|
43
43
|
export declare function isSemanticVersion(versionString: string): boolean;
|
|
44
|
-
/** Helper function to convert a string from kebab-case to
|
|
44
|
+
/** Helper function to convert a string from kebab-case to camelCase. */
|
|
45
45
|
export declare function kebabCaseToCamelCase(string: string): string;
|
|
46
|
+
/** Helper function to convert a string from kebab-case to PascalCase. */
|
|
47
|
+
export declare function kebabCaseToPascalCase(string: string): string;
|
|
46
48
|
/**
|
|
47
49
|
* Helper function to normalize a string. Specifically, this performs the following steps:
|
|
48
50
|
*
|
|
@@ -41,8 +41,10 @@ export declare function isKebabCase(string: string): boolean;
|
|
|
41
41
|
* @see https://semver.org/
|
|
42
42
|
*/
|
|
43
43
|
export declare function isSemanticVersion(versionString: string): boolean;
|
|
44
|
-
/** Helper function to convert a string from kebab-case to
|
|
44
|
+
/** Helper function to convert a string from kebab-case to camelCase. */
|
|
45
45
|
export declare function kebabCaseToCamelCase(string: string): string;
|
|
46
|
+
/** Helper function to convert a string from kebab-case to PascalCase. */
|
|
47
|
+
export declare function kebabCaseToPascalCase(string: string): string;
|
|
46
48
|
/**
|
|
47
49
|
* Helper function to normalize a string. Specifically, this performs the following steps:
|
|
48
50
|
*
|
|
@@ -41,8 +41,10 @@ export declare function isKebabCase(string: string): boolean;
|
|
|
41
41
|
* @see https://semver.org/
|
|
42
42
|
*/
|
|
43
43
|
export declare function isSemanticVersion(versionString: string): boolean;
|
|
44
|
-
/** Helper function to convert a string from kebab-case to
|
|
44
|
+
/** Helper function to convert a string from kebab-case to camelCase. */
|
|
45
45
|
export declare function kebabCaseToCamelCase(string: string): string;
|
|
46
|
+
/** Helper function to convert a string from kebab-case to PascalCase. */
|
|
47
|
+
export declare function kebabCaseToPascalCase(string: string): string;
|
|
46
48
|
/**
|
|
47
49
|
* Helper function to normalize a string. Specifically, this performs the following steps:
|
|
48
50
|
*
|
|
@@ -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;AAiBH,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,CAqBlE;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED,wEAAwE;AACxE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED,yEAAyE;AACzE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAiBtD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GACtD;IACE,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IAErB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IAErB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;CACtB,GACD,SAAS,CAwBZ;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAuBR;AAED,gGAAgG;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
|
@@ -344,7 +344,7 @@ function todo(...args) {
|
|
|
344
344
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
345
345
|
const EMOJI_REGEX = /(\p{Extended_Pictographic}|\p{Emoji_Component})/u;
|
|
346
346
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
347
|
-
const KEBAB_CASE_REGEX = /^
|
|
347
|
+
const KEBAB_CASE_REGEX = /^[\da-z]+(?:-[\da-z]+)*$|^$/;
|
|
348
348
|
const SEMANTIC_VERSION_REGEX = /^v*(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
|
|
349
349
|
const WHITESPACE_REGEX = /\s/g;
|
|
350
350
|
function capitalizeFirstLetter(string) {
|
|
@@ -401,6 +401,10 @@ function kebabCaseToCamelCase(string) {
|
|
|
401
401
|
return firstLetterOfWord === void 0 ? "" : firstLetterOfWord.toUpperCase();
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
+
function kebabCaseToPascalCase(string) {
|
|
405
|
+
const camelCase = kebabCaseToCamelCase(string);
|
|
406
|
+
return capitalizeFirstLetter(camelCase);
|
|
407
|
+
}
|
|
404
408
|
function normalizeString(string) {
|
|
405
409
|
let sanitizedString = string;
|
|
406
410
|
sanitizedString = removeNonPrintableCharacters(sanitizedString);
|
|
@@ -546,6 +550,7 @@ exports.isKeyOf = isKeyOf;
|
|
|
546
550
|
exports.isObject = isObject;
|
|
547
551
|
exports.isSemanticVersion = isSemanticVersion;
|
|
548
552
|
exports.kebabCaseToCamelCase = kebabCaseToCamelCase;
|
|
553
|
+
exports.kebabCaseToPascalCase = kebabCaseToPascalCase;
|
|
549
554
|
exports.mapFilter = mapFilter;
|
|
550
555
|
exports.mapFind = mapFind;
|
|
551
556
|
exports.newArray = newArray;
|
package/dist/index.mjs
CHANGED
|
@@ -342,7 +342,7 @@ function todo(...args) {
|
|
|
342
342
|
const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
343
343
|
const EMOJI_REGEX = /(\p{Extended_Pictographic}|\p{Emoji_Component})/u;
|
|
344
344
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
345
|
-
const KEBAB_CASE_REGEX = /^
|
|
345
|
+
const KEBAB_CASE_REGEX = /^[\da-z]+(?:-[\da-z]+)*$|^$/;
|
|
346
346
|
const SEMANTIC_VERSION_REGEX = /^v*(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
|
|
347
347
|
const WHITESPACE_REGEX = /\s/g;
|
|
348
348
|
function capitalizeFirstLetter(string) {
|
|
@@ -399,6 +399,10 @@ function kebabCaseToCamelCase(string) {
|
|
|
399
399
|
return firstLetterOfWord === void 0 ? "" : firstLetterOfWord.toUpperCase();
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
|
+
function kebabCaseToPascalCase(string) {
|
|
403
|
+
const camelCase = kebabCaseToCamelCase(string);
|
|
404
|
+
return capitalizeFirstLetter(camelCase);
|
|
405
|
+
}
|
|
402
406
|
function normalizeString(string) {
|
|
403
407
|
let sanitizedString = string;
|
|
404
408
|
sanitizedString = removeNonPrintableCharacters(sanitizedString);
|
|
@@ -496,4 +500,4 @@ function* tupleKeys(tuple) {
|
|
|
496
500
|
|
|
497
501
|
const ReadonlyMap = Map;
|
|
498
502
|
|
|
499
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, 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, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, kebabCaseToCamelCase, 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 };
|
|
503
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, 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, interfaceSatisfiesEnum, isArray, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isObject, isSemanticVersion, 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.2.0",
|
|
4
4
|
"description": "Helper functions for TypeScript projects.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://complete-ts.github.io/",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"test": "glob \"./src/**/*.test.ts\" --cmd=\"node --import tsx --test --test-reporter spec\""
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "22.
|
|
39
|
-
"complete-node": "5.1.
|
|
38
|
+
"@types/node": "22.14.1",
|
|
39
|
+
"complete-node": "5.1.3",
|
|
40
40
|
"eslint-plugin-sort-exports": "0.9.1",
|
|
41
41
|
"glob": "11.0.1",
|
|
42
|
-
"typescript": "5.8.
|
|
43
|
-
"typescript-eslint": "8.
|
|
42
|
+
"typescript": "5.8.3",
|
|
43
|
+
"typescript-eslint": "8.31.0",
|
|
44
44
|
"unbuild": "3.5.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/functions/array.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { WidenLiteral } from "../index.js";
|
|
8
7
|
import { ReadonlySet } from "../types/ReadonlySet.js";
|
|
8
|
+
import type { WidenLiteral } from "../types/WidenLiteral.js";
|
|
9
9
|
import { assertDefined } from "./assert.js";
|
|
10
10
|
import { getRandomInt } from "./random.js";
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ import { getRandomInt } from "./random.js";
|
|
|
15
15
|
*/
|
|
16
16
|
export function arrayCopyTwoDimensional<T>(
|
|
17
17
|
array: ReadonlyArray<readonly T[]>,
|
|
18
|
-
): readonly T[]
|
|
18
|
+
): ReadonlyArray<readonly T[]> {
|
|
19
19
|
const copiedArray: T[][] = [];
|
|
20
20
|
|
|
21
21
|
for (const subArray of array) {
|
package/src/functions/string.ts
CHANGED
|
@@ -15,11 +15,7 @@ const DIACRITIC_REGEX = /\p{Diacritic}/u;
|
|
|
15
15
|
const EMOJI_REGEX = /(\p{Extended_Pictographic}|\p{Emoji_Component})/u;
|
|
16
16
|
|
|
17
17
|
const FIRST_LETTER_CAPITALIZED_REGEX = /^\p{Lu}/u;
|
|
18
|
-
|
|
19
|
-
/** From: https://github.com/expandjs/expandjs/blob/master/lib/kebabCaseRegex.js */
|
|
20
|
-
const KEBAB_CASE_REGEX =
|
|
21
|
-
/^([a-z](?!\d)|\d(?![a-z]))+(-?([a-z](?!\d)|\d(?![a-z])))*$|^$/;
|
|
22
|
-
|
|
18
|
+
const KEBAB_CASE_REGEX = /^[\da-z]+(?:-[\da-z]+)*$|^$/;
|
|
23
19
|
const SEMANTIC_VERSION_REGEX = /^v*(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
|
|
24
20
|
const WHITESPACE_REGEX = /\s/g;
|
|
25
21
|
|
|
@@ -126,7 +122,7 @@ export function isSemanticVersion(versionString: string): boolean {
|
|
|
126
122
|
return match !== null;
|
|
127
123
|
}
|
|
128
124
|
|
|
129
|
-
/** Helper function to convert a string from kebab-case to
|
|
125
|
+
/** Helper function to convert a string from kebab-case to camelCase. */
|
|
130
126
|
export function kebabCaseToCamelCase(string: string): string {
|
|
131
127
|
return string.replaceAll(/-./g, (match) => {
|
|
132
128
|
const firstLetterOfWord = match[1];
|
|
@@ -136,6 +132,12 @@ export function kebabCaseToCamelCase(string: string): string {
|
|
|
136
132
|
});
|
|
137
133
|
}
|
|
138
134
|
|
|
135
|
+
/** Helper function to convert a string from kebab-case to PascalCase. */
|
|
136
|
+
export function kebabCaseToPascalCase(string: string): string {
|
|
137
|
+
const camelCase = kebabCaseToCamelCase(string);
|
|
138
|
+
return capitalizeFirstLetter(camelCase);
|
|
139
|
+
}
|
|
140
|
+
|
|
139
141
|
/**
|
|
140
142
|
* Helper function to normalize a string. Specifically, this performs the following steps:
|
|
141
143
|
*
|