complete-common 2.19.1 → 2.20.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,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,11 @@ 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
+ export declare function satisfiesSemanticVersion(version: string, minimumVersion: string): boolean;
118
117
  /** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
119
118
  export declare function titleCaseToKebabCase(string: string): string;
120
119
  /**
@@ -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,11 @@ 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
+ export declare function satisfiesSemanticVersion(version: string, minimumVersion: string): boolean;
118
117
  /** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
119
118
  export declare function titleCaseToKebabCase(string: string): string;
120
119
  /**
@@ -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,11 @@ 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
+ export declare function satisfiesSemanticVersion(version: string, minimumVersion: string): boolean;
118
117
  /** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
119
118
  export declare function titleCaseToKebabCase(string: string): string;
120
119
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH,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;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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.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,9 @@
1
+ export interface SemanticVersion {
2
+ /** The first number inside of the semantic version. */
3
+ majorVersion: number;
4
+ /** The second number inside of the semantic version. */
5
+ minorVersion: number;
6
+ /** The third number inside of the semantic version. */
7
+ patchVersion: number;
8
+ }
9
+ //# sourceMappingURL=SemanticVersion.d.ts.map
@@ -0,0 +1,9 @@
1
+ export interface SemanticVersion {
2
+ /** The first number inside of the semantic version. */
3
+ majorVersion: number;
4
+ /** The second number inside of the semantic version. */
5
+ minorVersion: number;
6
+ /** The third number inside of the semantic version. */
7
+ patchVersion: number;
8
+ }
9
+ //# sourceMappingURL=SemanticVersion.d.ts.map
@@ -0,0 +1,9 @@
1
+ export interface SemanticVersion {
2
+ /** The first number inside of the semantic version. */
3
+ majorVersion: number;
4
+ /** The second number inside of the semantic version. */
5
+ minorVersion: number;
6
+ /** The third number inside of the semantic version. */
7
+ patchVersion: number;
8
+ }
9
+ //# sourceMappingURL=SemanticVersion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SemanticVersion.d.ts","sourceRoot":"","sources":["../../src/interfaces/SemanticVersion.ts"],"names":[],"mappings":"AAAA,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "complete-common",
3
- "version": "2.19.1",
3
+ "version": "2.20.0",
4
4
  "description": "Helper functions for TypeScript projects.",
5
5
  "homepage": "https://complete-ts.github.io/",
6
6
  "bugs": {
@@ -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(versionString: string):
209
- | {
210
- /** The first number inside of the semantic version. */
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,44 @@ 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
+ export function satisfiesSemanticVersion(
317
+ version: string,
318
+ minimumVersion: string,
319
+ ): boolean {
320
+ const semanticVersion = parseSemanticVersion(version);
321
+ assertDefined(
322
+ semanticVersion,
323
+ `The following version is not a semantic version: ${version}`,
324
+ );
325
+
326
+ const { majorVersion, minorVersion, patchVersion } = semanticVersion;
327
+
328
+ const minimumSemanticVersion = parseSemanticVersion(minimumVersion);
329
+ assertDefined(
330
+ minimumSemanticVersion,
331
+ `The following minimum version is not a semantic version: ${minimumVersion}`,
332
+ );
333
+
334
+ const {
335
+ majorVersion: minimumMajorVersion,
336
+ minorVersion: minimumMinorVersion,
337
+ patchVersion: minimumPatchVersion,
338
+ } = minimumSemanticVersion;
339
+
340
+ return (
341
+ majorVersion > minimumMajorVersion
342
+ || (majorVersion === minimumMajorVersion
343
+ && minorVersion > minimumMinorVersion)
344
+ || (majorVersion === minimumMajorVersion
345
+ && minorVersion === minimumMinorVersion
346
+ && patchVersion >= minimumPatchVersion)
347
+ );
348
+ }
349
+
319
350
  /** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */
320
351
  export function titleCaseToKebabCase(string: string): string {
321
352
  return string
@@ -0,0 +1,10 @@
1
+ export interface SemanticVersion {
2
+ /** The first number inside of the semantic version. */
3
+ majorVersion: number;
4
+
5
+ /** The second number inside of the semantic version. */
6
+ minorVersion: number;
7
+
8
+ /** The third number inside of the semantic version. */
9
+ patchVersion: number;
10
+ }