complete-common 2.19.1 → 2.20.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/string.d.cts +9 -8
- package/dist/functions/string.d.mts +9 -8
- package/dist/functions/string.d.ts +9 -8
- package/dist/functions/string.d.ts.map +1 -1
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +20 -1
- package/dist/interfaces/SemanticVersion.d.cts +10 -0
- package/dist/interfaces/SemanticVersion.d.mts +10 -0
- package/dist/interfaces/SemanticVersion.d.ts +10 -0
- package/dist/interfaces/SemanticVersion.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/functions/string.ts +45 -12
- package/src/index.ts +1 -0
- package/src/interfaces/SemanticVersion.ts +11 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import type { SemanticVersion } from "../interfaces/SemanticVersion.js";
|
|
6
7
|
/** Helper function to capitalize the first letter of a string. */
|
|
7
8
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
8
9
|
/**
|
|
@@ -73,14 +74,7 @@ export declare function normalizeString(string: string): string;
|
|
|
73
74
|
*
|
|
74
75
|
* @see https://semver.org/
|
|
75
76
|
*/
|
|
76
|
-
export declare function parseSemanticVersion(versionString: string):
|
|
77
|
-
/** The first number inside of the semantic version. */
|
|
78
|
-
majorVersion: number;
|
|
79
|
-
/** The second number inside of the semantic version. */
|
|
80
|
-
minorVersion: number;
|
|
81
|
-
/** The third number inside of the semantic version. */
|
|
82
|
-
patchVersion: number;
|
|
83
|
-
} | undefined;
|
|
77
|
+
export declare function parseSemanticVersion(versionString: string): SemanticVersion | undefined;
|
|
84
78
|
/**
|
|
85
79
|
* Helper function to remove lines from a multi-line string. This function looks for a "-start" and
|
|
86
80
|
* a "-end" suffix after the marker. Lines with markets will be completely removed from the output.
|
|
@@ -115,6 +109,13 @@ export declare function removeLinesMatching(string: string, match: string): stri
|
|
|
115
109
|
export declare function removeNonPrintableCharacters(string: string): string;
|
|
116
110
|
/** Helper function to remove all whitespace characters from a string. */
|
|
117
111
|
export declare function removeWhitespace(string: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Helper function to check if a semantic version is equal to or greater than a second semantic
|
|
114
|
+
* version.
|
|
115
|
+
*
|
|
116
|
+
* @throws If either the version or minimum version are not valid semantic versions.
|
|
117
|
+
*/
|
|
118
|
+
export declare function satisfiesSemanticVersion(version: string, minimumVersion: string): boolean;
|
|
118
119
|
/** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
|
|
119
120
|
export declare function titleCaseToKebabCase(string: string): string;
|
|
120
121
|
/**
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import type { SemanticVersion } from "../interfaces/SemanticVersion.js";
|
|
6
7
|
/** Helper function to capitalize the first letter of a string. */
|
|
7
8
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
8
9
|
/**
|
|
@@ -73,14 +74,7 @@ export declare function normalizeString(string: string): string;
|
|
|
73
74
|
*
|
|
74
75
|
* @see https://semver.org/
|
|
75
76
|
*/
|
|
76
|
-
export declare function parseSemanticVersion(versionString: string):
|
|
77
|
-
/** The first number inside of the semantic version. */
|
|
78
|
-
majorVersion: number;
|
|
79
|
-
/** The second number inside of the semantic version. */
|
|
80
|
-
minorVersion: number;
|
|
81
|
-
/** The third number inside of the semantic version. */
|
|
82
|
-
patchVersion: number;
|
|
83
|
-
} | undefined;
|
|
77
|
+
export declare function parseSemanticVersion(versionString: string): SemanticVersion | undefined;
|
|
84
78
|
/**
|
|
85
79
|
* Helper function to remove lines from a multi-line string. This function looks for a "-start" and
|
|
86
80
|
* a "-end" suffix after the marker. Lines with markets will be completely removed from the output.
|
|
@@ -115,6 +109,13 @@ export declare function removeLinesMatching(string: string, match: string): stri
|
|
|
115
109
|
export declare function removeNonPrintableCharacters(string: string): string;
|
|
116
110
|
/** Helper function to remove all whitespace characters from a string. */
|
|
117
111
|
export declare function removeWhitespace(string: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Helper function to check if a semantic version is equal to or greater than a second semantic
|
|
114
|
+
* version.
|
|
115
|
+
*
|
|
116
|
+
* @throws If either the version or minimum version are not valid semantic versions.
|
|
117
|
+
*/
|
|
118
|
+
export declare function satisfiesSemanticVersion(version: string, minimumVersion: string): boolean;
|
|
118
119
|
/** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
|
|
119
120
|
export declare function titleCaseToKebabCase(string: string): string;
|
|
120
121
|
/**
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import type { SemanticVersion } from "../interfaces/SemanticVersion.js";
|
|
6
7
|
/** Helper function to capitalize the first letter of a string. */
|
|
7
8
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
8
9
|
/**
|
|
@@ -73,14 +74,7 @@ export declare function normalizeString(string: string): string;
|
|
|
73
74
|
*
|
|
74
75
|
* @see https://semver.org/
|
|
75
76
|
*/
|
|
76
|
-
export declare function parseSemanticVersion(versionString: string):
|
|
77
|
-
/** The first number inside of the semantic version. */
|
|
78
|
-
majorVersion: number;
|
|
79
|
-
/** The second number inside of the semantic version. */
|
|
80
|
-
minorVersion: number;
|
|
81
|
-
/** The third number inside of the semantic version. */
|
|
82
|
-
patchVersion: number;
|
|
83
|
-
} | undefined;
|
|
77
|
+
export declare function parseSemanticVersion(versionString: string): SemanticVersion | undefined;
|
|
84
78
|
/**
|
|
85
79
|
* Helper function to remove lines from a multi-line string. This function looks for a "-start" and
|
|
86
80
|
* a "-end" suffix after the marker. Lines with markets will be completely removed from the output.
|
|
@@ -115,6 +109,13 @@ export declare function removeLinesMatching(string: string, match: string): stri
|
|
|
115
109
|
export declare function removeNonPrintableCharacters(string: string): string;
|
|
116
110
|
/** Helper function to remove all whitespace characters from a string. */
|
|
117
111
|
export declare function removeWhitespace(string: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Helper function to check if a semantic version is equal to or greater than a second semantic
|
|
114
|
+
* version.
|
|
115
|
+
*
|
|
116
|
+
* @throws If either the version or minimum version are not valid semantic versions.
|
|
117
|
+
*/
|
|
118
|
+
export declare function satisfiesSemanticVersion(version: string, minimumVersion: string): boolean;
|
|
118
119
|
/** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
|
|
119
120
|
export declare function titleCaseToKebabCase(string: string): string;
|
|
120
121
|
/**
|
|
@@ -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;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AA8BxE,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,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEnD;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,CAClC,aAAa,EAAE,MAAM,GACpB,eAAe,GAAG,SAAS,CAwB7B;AAGD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,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;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,GACrB,OAAO,CA6BT;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK3D;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
|
@@ -595,6 +595,25 @@ function removeNonPrintableCharacters(string) {
|
|
|
595
595
|
function removeWhitespace(string) {
|
|
596
596
|
return string.replaceAll(WHITESPACE_GLOBAL_REGEX, "");
|
|
597
597
|
}
|
|
598
|
+
function satisfiesSemanticVersion(version, minimumVersion) {
|
|
599
|
+
const semanticVersion = parseSemanticVersion(version);
|
|
600
|
+
assertDefined(
|
|
601
|
+
semanticVersion,
|
|
602
|
+
`The following version is not a semantic version: ${version}`
|
|
603
|
+
);
|
|
604
|
+
const { majorVersion, minorVersion, patchVersion } = semanticVersion;
|
|
605
|
+
const minimumSemanticVersion = parseSemanticVersion(minimumVersion);
|
|
606
|
+
assertDefined(
|
|
607
|
+
minimumSemanticVersion,
|
|
608
|
+
`The following minimum version is not a semantic version: ${minimumVersion}`
|
|
609
|
+
);
|
|
610
|
+
const {
|
|
611
|
+
majorVersion: minimumMajorVersion,
|
|
612
|
+
minorVersion: minimumMinorVersion,
|
|
613
|
+
patchVersion: minimumPatchVersion
|
|
614
|
+
} = minimumSemanticVersion;
|
|
615
|
+
return majorVersion > minimumMajorVersion || majorVersion === minimumMajorVersion && minorVersion > minimumMinorVersion || majorVersion === minimumMajorVersion && minorVersion === minimumMinorVersion && patchVersion >= minimumPatchVersion;
|
|
616
|
+
}
|
|
598
617
|
function titleCaseToKebabCase(string) {
|
|
599
618
|
return string.replaceAll(TITLE_CASE_BOUNDARY_REGEX, "-").replaceAll(/ +/g, "-").toLowerCase();
|
|
600
619
|
}
|
|
@@ -726,6 +745,7 @@ exports.removeLinesMatching = removeLinesMatching;
|
|
|
726
745
|
exports.removeNonPrintableCharacters = removeNonPrintableCharacters;
|
|
727
746
|
exports.removeWhitespace = removeWhitespace;
|
|
728
747
|
exports.repeat = repeat;
|
|
748
|
+
exports.satisfiesSemanticVersion = satisfiesSemanticVersion;
|
|
729
749
|
exports.setAdd = setAdd;
|
|
730
750
|
exports.setHas = setHas;
|
|
731
751
|
exports.sortCaseInsensitive = sortCaseInsensitive;
|
package/dist/index.d.cts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./functions/time.js";
|
|
|
13
13
|
export * from "./functions/tuple.js";
|
|
14
14
|
export * from "./functions/types.js";
|
|
15
15
|
export * from "./functions/utils.js";
|
|
16
|
+
export type * from "./interfaces/SemanticVersion.js";
|
|
16
17
|
export type * from "./types/AddSubtract.js";
|
|
17
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
18
19
|
export type * from "./types/ERange.js";
|
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./functions/time.js";
|
|
|
13
13
|
export * from "./functions/tuple.js";
|
|
14
14
|
export * from "./functions/types.js";
|
|
15
15
|
export * from "./functions/utils.js";
|
|
16
|
+
export type * from "./interfaces/SemanticVersion.js";
|
|
16
17
|
export type * from "./types/AddSubtract.js";
|
|
17
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
18
19
|
export type * from "./types/ERange.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./functions/time.js";
|
|
|
13
13
|
export * from "./functions/tuple.js";
|
|
14
14
|
export * from "./functions/types.js";
|
|
15
15
|
export * from "./functions/utils.js";
|
|
16
|
+
export type * from "./interfaces/SemanticVersion.js";
|
|
16
17
|
export type * from "./types/AddSubtract.js";
|
|
17
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
18
19
|
export type * from "./types/ERange.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,yBAAyB,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,mBAAmB,iCAAiC,CAAC;AACrD,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,yBAAyB,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,sBAAsB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -593,6 +593,25 @@ function removeNonPrintableCharacters(string) {
|
|
|
593
593
|
function removeWhitespace(string) {
|
|
594
594
|
return string.replaceAll(WHITESPACE_GLOBAL_REGEX, "");
|
|
595
595
|
}
|
|
596
|
+
function satisfiesSemanticVersion(version, minimumVersion) {
|
|
597
|
+
const semanticVersion = parseSemanticVersion(version);
|
|
598
|
+
assertDefined(
|
|
599
|
+
semanticVersion,
|
|
600
|
+
`The following version is not a semantic version: ${version}`
|
|
601
|
+
);
|
|
602
|
+
const { majorVersion, minorVersion, patchVersion } = semanticVersion;
|
|
603
|
+
const minimumSemanticVersion = parseSemanticVersion(minimumVersion);
|
|
604
|
+
assertDefined(
|
|
605
|
+
minimumSemanticVersion,
|
|
606
|
+
`The following minimum version is not a semantic version: ${minimumVersion}`
|
|
607
|
+
);
|
|
608
|
+
const {
|
|
609
|
+
majorVersion: minimumMajorVersion,
|
|
610
|
+
minorVersion: minimumMinorVersion,
|
|
611
|
+
patchVersion: minimumPatchVersion
|
|
612
|
+
} = minimumSemanticVersion;
|
|
613
|
+
return majorVersion > minimumMajorVersion || majorVersion === minimumMajorVersion && minorVersion > minimumMinorVersion || majorVersion === minimumMajorVersion && minorVersion === minimumMinorVersion && patchVersion >= minimumPatchVersion;
|
|
614
|
+
}
|
|
596
615
|
function titleCaseToKebabCase(string) {
|
|
597
616
|
return string.replaceAll(TITLE_CASE_BOUNDARY_REGEX, "-").replaceAll(/ +/g, "-").toLowerCase();
|
|
598
617
|
}
|
|
@@ -636,4 +655,4 @@ function* tupleKeys(tuple) {
|
|
|
636
655
|
|
|
637
656
|
const ReadonlyMap = Map;
|
|
638
657
|
|
|
639
|
-
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertArrayBoolean, assertArrayNumber, assertArrayObject, assertArrayString, assertBoolean, assertDefined, assertEnumValue, assertInteger, assertIs, assertNotNull, assertNumber, assertObject, assertString, assertStringNotEmpty, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterAsync, filterMap, filterMapAsync, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, getWidenedObjectValue, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isASCII, isArray, isArrayBoolean, isArrayNumber, isArrayObject, isArrayString, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapAsync, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectMap, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, setAdd, setHas, sortCaseInsensitive, sumArray, titleCaseToKebabCase, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
658
|
+
export { HOUR_IN_MILLISECONDS, MINUTE_IN_MILLISECONDS, ReadonlyMap, ReadonlySet, SECOND_IN_MILLISECONDS, addSetsToSet, arrayCopyTwoDimensional, arrayEquals, arrayRemove, arrayRemoveAllInPlace, arrayRemoveInPlace, assertArray, assertArrayBoolean, assertArrayNumber, assertArrayObject, assertArrayString, assertBoolean, assertDefined, assertEnumValue, assertInteger, assertIs, assertNotNull, assertNumber, assertObject, assertString, assertStringNotEmpty, capitalizeFirstLetter, clamp, combineSets, copySet, eRange, emptyArray, escapeHTMLCharacters, filterAsync, filterMap, filterMapAsync, getElapsedSeconds, getEnumEntries, getEnumKeys, getEnumValues, getNumConsecutiveDiacritics, getRandomArrayElement, getRandomArrayIndex, getRandomInt, getWidenedObjectValue, hasDiacritic, hasEmoji, hasWhitespace, iRange, includes, includesAny, interfaceSatisfiesEnum, isASCII, isArray, isArrayBoolean, isArrayNumber, isArrayObject, isArrayString, isEnumValue, isFirstLetterCapitalized, isKebabCase, isKeyOf, isLowerCase, isObject, isSemanticVersion, isUpperCase, kebabCaseToCamelCase, kebabCaseToPascalCase, mapAsync, mapFilter, mapFind, newArray, noop, normalizeString, objectFilter, objectKeysToSet, objectMap, objectToMap, objectToReverseMap, objectValuesToSet, parseFloatSafe, parseIntSafe, parseSemanticVersion, removeLinesBetweenMarkers, removeLinesMatching, removeNonPrintableCharacters, removeWhitespace, repeat, satisfiesSemanticVersion, setAdd, setHas, sortCaseInsensitive, sumArray, titleCaseToKebabCase, todo, trimPrefix, trimSuffix, truncateString, tupleEntries, tupleKeys };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @see https://semver.org/ */
|
|
2
|
+
export interface SemanticVersion {
|
|
3
|
+
/** The first number inside of the semantic version. */
|
|
4
|
+
majorVersion: number;
|
|
5
|
+
/** The second number inside of the semantic version. */
|
|
6
|
+
minorVersion: number;
|
|
7
|
+
/** The third number inside of the semantic version. */
|
|
8
|
+
patchVersion: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=SemanticVersion.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @see https://semver.org/ */
|
|
2
|
+
export interface SemanticVersion {
|
|
3
|
+
/** The first number inside of the semantic version. */
|
|
4
|
+
majorVersion: number;
|
|
5
|
+
/** The second number inside of the semantic version. */
|
|
6
|
+
minorVersion: number;
|
|
7
|
+
/** The third number inside of the semantic version. */
|
|
8
|
+
patchVersion: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=SemanticVersion.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @see https://semver.org/ */
|
|
2
|
+
export interface SemanticVersion {
|
|
3
|
+
/** The first number inside of the semantic version. */
|
|
4
|
+
majorVersion: number;
|
|
5
|
+
/** The second number inside of the semantic version. */
|
|
6
|
+
minorVersion: number;
|
|
7
|
+
/** The third number inside of the semantic version. */
|
|
8
|
+
patchVersion: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=SemanticVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SemanticVersion.d.ts","sourceRoot":"","sources":["../../src/interfaces/SemanticVersion.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IAErB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IAErB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
package/package.json
CHANGED
package/src/functions/string.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type { SemanticVersion } from "../interfaces/SemanticVersion.js";
|
|
8
|
+
import { assertDefined } from "./assert.js";
|
|
7
9
|
import { parseIntSafe } from "./utils.js";
|
|
8
10
|
|
|
9
11
|
// When regular expressions are located at the root instead of inside the function, the functions
|
|
@@ -205,18 +207,9 @@ export function normalizeString(string: string): string {
|
|
|
205
207
|
*
|
|
206
208
|
* @see https://semver.org/
|
|
207
209
|
*/
|
|
208
|
-
export function parseSemanticVersion(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
majorVersion: number;
|
|
212
|
-
|
|
213
|
-
/** The second number inside of the semantic version. */
|
|
214
|
-
minorVersion: number;
|
|
215
|
-
|
|
216
|
-
/** The third number inside of the semantic version. */
|
|
217
|
-
patchVersion: number;
|
|
218
|
-
}
|
|
219
|
-
| undefined {
|
|
210
|
+
export function parseSemanticVersion(
|
|
211
|
+
versionString: string,
|
|
212
|
+
): SemanticVersion | undefined {
|
|
220
213
|
const match = versionString.match(SEMANTIC_VERSION_REGEX);
|
|
221
214
|
if (match === null || match.groups === undefined) {
|
|
222
215
|
return undefined;
|
|
@@ -316,6 +309,46 @@ export function removeWhitespace(string: string): string {
|
|
|
316
309
|
return string.replaceAll(WHITESPACE_GLOBAL_REGEX, "");
|
|
317
310
|
}
|
|
318
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Helper function to check if a semantic version is equal to or greater than a second semantic
|
|
314
|
+
* version.
|
|
315
|
+
*
|
|
316
|
+
* @throws If either the version or minimum version are not valid semantic versions.
|
|
317
|
+
*/
|
|
318
|
+
export function satisfiesSemanticVersion(
|
|
319
|
+
version: string,
|
|
320
|
+
minimumVersion: string,
|
|
321
|
+
): boolean {
|
|
322
|
+
const semanticVersion = parseSemanticVersion(version);
|
|
323
|
+
assertDefined(
|
|
324
|
+
semanticVersion,
|
|
325
|
+
`The following version is not a semantic version: ${version}`,
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const { majorVersion, minorVersion, patchVersion } = semanticVersion;
|
|
329
|
+
|
|
330
|
+
const minimumSemanticVersion = parseSemanticVersion(minimumVersion);
|
|
331
|
+
assertDefined(
|
|
332
|
+
minimumSemanticVersion,
|
|
333
|
+
`The following minimum version is not a semantic version: ${minimumVersion}`,
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
const {
|
|
337
|
+
majorVersion: minimumMajorVersion,
|
|
338
|
+
minorVersion: minimumMinorVersion,
|
|
339
|
+
patchVersion: minimumPatchVersion,
|
|
340
|
+
} = minimumSemanticVersion;
|
|
341
|
+
|
|
342
|
+
return (
|
|
343
|
+
majorVersion > minimumMajorVersion
|
|
344
|
+
|| (majorVersion === minimumMajorVersion
|
|
345
|
+
&& minorVersion > minimumMinorVersion)
|
|
346
|
+
|| (majorVersion === minimumMajorVersion
|
|
347
|
+
&& minorVersion === minimumMinorVersion
|
|
348
|
+
&& patchVersion >= minimumPatchVersion)
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
319
352
|
/** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
|
|
320
353
|
export function titleCaseToKebabCase(string: string): string {
|
|
321
354
|
return string
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./functions/time.js";
|
|
|
13
13
|
export * from "./functions/tuple.js";
|
|
14
14
|
export * from "./functions/types.js";
|
|
15
15
|
export * from "./functions/utils.js";
|
|
16
|
+
export type * from "./interfaces/SemanticVersion.js";
|
|
16
17
|
export type * from "./types/AddSubtract.js";
|
|
17
18
|
export type * from "./types/CompositionTypeSatisfiesEnum.js";
|
|
18
19
|
export type * from "./types/ERange.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @see https://semver.org/ */
|
|
2
|
+
export interface SemanticVersion {
|
|
3
|
+
/** The first number inside of the semantic version. */
|
|
4
|
+
majorVersion: number;
|
|
5
|
+
|
|
6
|
+
/** The second number inside of the semantic version. */
|
|
7
|
+
minorVersion: number;
|
|
8
|
+
|
|
9
|
+
/** The third number inside of the semantic version. */
|
|
10
|
+
patchVersion: number;
|
|
11
|
+
}
|