@alextheman/utility 3.8.0 → 3.9.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 +0 -119
- package/dist/index.cjs +26 -0
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +26 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,122 +24,3 @@ import { formatDateAndTime } from "@alextheman/utility";
|
|
|
24
24
|
const myVariable: NonUndefined<string> = formatDateAndTime(new Date());
|
|
25
25
|
// ...
|
|
26
26
|
```
|
|
27
|
-
|
|
28
|
-
## Contributing
|
|
29
|
-
|
|
30
|
-
### Creating a function
|
|
31
|
-
#### Setup
|
|
32
|
-
To create a new function in the package, you must first checkout a new branch. Do **not** commit directly on main.
|
|
33
|
-
|
|
34
|
-
From there, create the skeleton of the function. This is just the function declaration itself, along with the arguments and their types, along with the return type.
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
function myFunction(firstArg: ArgType): ReturnType {
|
|
38
|
-
// Implementation goes here
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default myFunction
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Note that every function that gets exported from this package **must** have a type annotation. This is also enforced by ESLint. This helps to make the return types extra explicit and more intentional.
|
|
45
|
-
|
|
46
|
-
Once you have this, export the function from `src/functions/index.ts` so that consumers can import your function. Also export any types you may want to export near the bottom of the file:
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
export { default as addDaysToDate } from "src/functions/addDaysToDate";
|
|
50
|
-
export { default as appendSemicolon } from "src/functions/appendSemicolon";
|
|
51
|
-
export { default as camelToKebab } from "src/functions/camelToKebab";
|
|
52
|
-
export { default as convertFileToBase64 } from "src/functions/convertFileToBase64";
|
|
53
|
-
export { default as createFormData } from "src/functions/createFormData";
|
|
54
|
-
export { default as fillArray } from "src/functions/fillArray";
|
|
55
|
-
export { default as formatDateAndTime } from "src/functions/formatDateAndTime";
|
|
56
|
-
// ...
|
|
57
|
-
export { default as myFunction } from "src/functions/myFunction";
|
|
58
|
-
// ...
|
|
59
|
-
|
|
60
|
-
export type { MyFunctionOptions } from "src/functions/myFunction";
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
#### Testing
|
|
64
|
-
|
|
65
|
-
Every function must also be tested. Tests are located in the `tests` folder and follows roughly the same structure as `src`. We use Vitest for our tests, and instead of relying on the global test functions like you might do with Jest, we instead import each test function directly.
|
|
66
|
-
|
|
67
|
-
Tests are generally structured in the following way:
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
import { describe, expect, test } from "vitest";
|
|
71
|
-
|
|
72
|
-
import myFunction from "src/functions/myFunction";
|
|
73
|
-
|
|
74
|
-
describe("myFunction", () => {
|
|
75
|
-
test("Does a thing", () => {
|
|
76
|
-
expect(myFunction("hello")).toBe("world");
|
|
77
|
-
});
|
|
78
|
-
test("Does another thing", () => {
|
|
79
|
-
expect(myFunction("one")).toBe("two");
|
|
80
|
-
});
|
|
81
|
-
// ...
|
|
82
|
-
});
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
That is, we wrap all tests around a describe block grouping all related tests to that function together, then each test block tests a specific behaviour.
|
|
86
|
-
|
|
87
|
-
Every function must at least have one test for the core behaviour of it. Of course, the more tests, the better, but at the very least, test the core behaviour of the function. From there, if you feel like there may be a few edge cases you want to verify the behaviour of, please add tests in for that as well.
|
|
88
|
-
|
|
89
|
-
Some functions that we create may often end up taking in an array or object. Due to the nature of how JavaScript passes these, we must have non-mutation tests in place to prevent unintended mutation of the input array/object. The best way to do this is to use `Object.freeze()`, as that will ensure that we get an error if the function ever even tries to mutate the input.
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
describe("removeDuplicates", () => {
|
|
93
|
-
describe("Mutation checks", () => {
|
|
94
|
-
test("Does not mutate the original array", () => {
|
|
95
|
-
const inputArray = Object.freeze([1, 1, 2, 3, 4]);
|
|
96
|
-
// since the array has been frozen, this will give a TypeError if it tries to mutate the inputArray.
|
|
97
|
-
removeDuplicates(inputArray);
|
|
98
|
-
expect(inputArray).toEqual([1, 1, 2, 3, 4]);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Also, if the return type of the function is the same as one or more of the inputs, it's also often helpful to have a test that ensures the output returns a new reference in memory:
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
describe("removeDuplicates", () => {
|
|
108
|
-
describe("Mutation checks", () => {
|
|
109
|
-
test("Returns an array with a new reference in memory", () => {
|
|
110
|
-
const inputArray = [1, 1, 2, 3, 4];
|
|
111
|
-
const outputArray = removeDuplicates(inputArray);
|
|
112
|
-
expect(outputArray).not.toBe(inputArray);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Note the use of `.toBe()` over `.toEqual()` here. This is because in this case, we are comparing the variable's memory reference to the output's memory reference rather than the actual contents of the array.
|
|
119
|
-
|
|
120
|
-
### Creating a type
|
|
121
|
-
|
|
122
|
-
Creating a type works in a similar way to creating a function, in the sense that you create a new file for it, add it to `src/types/index.ts`, and test it. Yes, test it. It is possible to test type declarations using `expectTypeOf`. As an example:
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
import type { OptionalOnCondition } from "src/types";
|
|
126
|
-
|
|
127
|
-
import { describe, expectTypeOf, test } from "vitest";
|
|
128
|
-
|
|
129
|
-
describe("OptionalOnCondition", () => {
|
|
130
|
-
test("Resolves to the type of the second type argument if first type argument is true", () => {
|
|
131
|
-
expectTypeOf<OptionalOnCondition<true, string>>().toEqualTypeOf<string>();
|
|
132
|
-
});
|
|
133
|
-
test("Resolves to a union of the second type and undefined if first type argument is false", () => {
|
|
134
|
-
expectTypeOf<OptionalOnCondition<false, string>>().toEqualTypeOf<string | undefined>();
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Note that when you actually run the tests using `npm test`, the tests will always pass even if the logic is incorrect. This is because type tests run with the TypeScript compiler so it will error in your editor and in linting, but it will never fail in runtime. As such, just remember to be extra careful with these type tests and remember that the actual test results for these show in the editor and not in runtime.
|
|
140
|
-
|
|
141
|
-
### Publishing
|
|
142
|
-
|
|
143
|
-
Once you are happy with your changes, commit the changes to your branch, then change the version number. You can do this by running one of `npm run change-major`, `npm run change-minor`, or `npm run change-patch`. Major changes generally correspond to breaking changes (e.g. removing features, changing the build process substantially), minor changes correspond to non-breaking additions/deprecations, and patch changes are for the small things that aren't as noticeable. Note that your change will fail CI if you change the source code but forget to change the version number. From there, after your changes have been approved and merged, the publish script will automatically run, and if you remembered to change the version number, it will pass the publishing action.
|
|
144
|
-
|
|
145
|
-
Version number changes must also **not** be part of your main commit(s) - they must be their own standalone commit. This helps to make it easier to revert changes if needed - if the version change is part of the main commit, that means that if we need to revert it for whatever reason, the version change also gets reverted, which is not really ideal as it makes re-publishing a bit harder.
|
package/dist/index.cjs
CHANGED
|
@@ -1117,6 +1117,31 @@ function determineVersionType(version) {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
var determineVersionType_default = determineVersionType;
|
|
1119
1119
|
|
|
1120
|
+
//#endregion
|
|
1121
|
+
//#region src/functions/versioning/incrementVersion.ts
|
|
1122
|
+
/**
|
|
1123
|
+
* Increments the given input version depending on the given increment type.
|
|
1124
|
+
*
|
|
1125
|
+
* @param version - The version to increment
|
|
1126
|
+
* @param incrementType - The type of increment. Can be one of the following:
|
|
1127
|
+
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
1128
|
+
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
1129
|
+
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
1130
|
+
* @param options - Extra options to apply.
|
|
1131
|
+
*
|
|
1132
|
+
* @returns A new string representing the version with the increment applied.
|
|
1133
|
+
*/
|
|
1134
|
+
function incrementVersion(version, incrementType, options) {
|
|
1135
|
+
const [major, minor, patch] = getIndividualVersionNumbers_default(version);
|
|
1136
|
+
const newVersion = {
|
|
1137
|
+
major: `${major + 1}.0.0`,
|
|
1138
|
+
minor: `${major}.${minor + 1}.0`,
|
|
1139
|
+
patch: `${major}.${minor}.${patch + 1}`
|
|
1140
|
+
}[incrementType];
|
|
1141
|
+
return parseVersion_default(newVersion, { omitPrefix: options?.omitPrefix });
|
|
1142
|
+
}
|
|
1143
|
+
var incrementVersion_default = incrementVersion;
|
|
1144
|
+
|
|
1120
1145
|
//#endregion
|
|
1121
1146
|
exports.APIError = APIError_default;
|
|
1122
1147
|
exports.DataError = DataError_default;
|
|
@@ -1137,6 +1162,7 @@ exports.getIndividualVersionNumbers = getIndividualVersionNumbers_default;
|
|
|
1137
1162
|
exports.getRandomNumber = getRandomNumber_default;
|
|
1138
1163
|
exports.getRecordKeys = getRecordKeys_default;
|
|
1139
1164
|
exports.httpErrorCodeLookup = httpErrorCodeLookup;
|
|
1165
|
+
exports.incrementVersion = incrementVersion_default;
|
|
1140
1166
|
exports.interpolate = interpolate_default;
|
|
1141
1167
|
exports.interpolateObjects = interpolateObjects_default;
|
|
1142
1168
|
exports.isAnniversary = isAnniversary_default;
|
package/dist/index.d.cts
CHANGED
|
@@ -285,6 +285,9 @@ type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condit
|
|
|
285
285
|
/** Represents the native Record's possible key type. */
|
|
286
286
|
type RecordKey = string | number | symbol;
|
|
287
287
|
//#endregion
|
|
288
|
+
//#region src/types/VersionType.d.ts
|
|
289
|
+
type VersionType = "major" | "minor" | "patch";
|
|
290
|
+
//#endregion
|
|
288
291
|
//#region src/functions/miscellaneous/createFormData.d.ts
|
|
289
292
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
290
293
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
@@ -702,7 +705,6 @@ declare function removeIndents(options: RemoveIndentsOptions): RemoveIndentsFunc
|
|
|
702
705
|
declare function removeIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
|
|
703
706
|
//#endregion
|
|
704
707
|
//#region src/functions/versioning/determineVersionType.d.ts
|
|
705
|
-
type VersionType = "major" | "minor" | "patch";
|
|
706
708
|
/**
|
|
707
709
|
* Determines whether the given version is a major, minor, or patch version.
|
|
708
710
|
*
|
|
@@ -722,8 +724,28 @@ declare function determineVersionType(version: string): VersionType;
|
|
|
722
724
|
*/
|
|
723
725
|
declare function getIndividualVersionNumbers(version: string): [number, number, number];
|
|
724
726
|
//#endregion
|
|
727
|
+
//#region src/functions/versioning/incrementVersion.d.ts
|
|
728
|
+
interface IncrementVersionOptions {
|
|
729
|
+
/** Whether to omit the `v` prefix from the output version or not. */
|
|
730
|
+
omitPrefix?: boolean;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Increments the given input version depending on the given increment type.
|
|
734
|
+
*
|
|
735
|
+
* @param version - The version to increment
|
|
736
|
+
* @param incrementType - The type of increment. Can be one of the following:
|
|
737
|
+
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
738
|
+
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
739
|
+
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
740
|
+
* @param options - Extra options to apply.
|
|
741
|
+
*
|
|
742
|
+
* @returns A new string representing the version with the increment applied.
|
|
743
|
+
*/
|
|
744
|
+
declare function incrementVersion(version: string, incrementType: VersionType, options?: IncrementVersionOptions): string;
|
|
745
|
+
//#endregion
|
|
725
746
|
//#region src/functions/versioning/parseVersion.d.ts
|
|
726
747
|
interface ParseVersionOptions {
|
|
748
|
+
/** Whether to omit the `v` prefix from the output version or not. */
|
|
727
749
|
omitPrefix?: boolean;
|
|
728
750
|
}
|
|
729
751
|
/**
|
|
@@ -740,4 +762,4 @@ interface ParseVersionOptions {
|
|
|
740
762
|
*/
|
|
741
763
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
742
764
|
//#endregion
|
|
743
|
-
export { APIError, ArrayElement, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DeepReadonly, DisallowUndefined, Email, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, StringListToArrayOptions, UUID, VERSION_NUMBER_REGEX, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
|
765
|
+
export { APIError, ArrayElement, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DeepReadonly, DisallowUndefined, Email, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParseVersionOptions, RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, StringListToArrayOptions, UUID, VERSION_NUMBER_REGEX, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -285,6 +285,9 @@ type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condit
|
|
|
285
285
|
/** Represents the native Record's possible key type. */
|
|
286
286
|
type RecordKey = string | number | symbol;
|
|
287
287
|
//#endregion
|
|
288
|
+
//#region src/types/VersionType.d.ts
|
|
289
|
+
type VersionType = "major" | "minor" | "patch";
|
|
290
|
+
//#endregion
|
|
288
291
|
//#region src/functions/miscellaneous/createFormData.d.ts
|
|
289
292
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
290
293
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
@@ -702,7 +705,6 @@ declare function removeIndents(options: RemoveIndentsOptions): RemoveIndentsFunc
|
|
|
702
705
|
declare function removeIndents(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
|
|
703
706
|
//#endregion
|
|
704
707
|
//#region src/functions/versioning/determineVersionType.d.ts
|
|
705
|
-
type VersionType = "major" | "minor" | "patch";
|
|
706
708
|
/**
|
|
707
709
|
* Determines whether the given version is a major, minor, or patch version.
|
|
708
710
|
*
|
|
@@ -722,8 +724,28 @@ declare function determineVersionType(version: string): VersionType;
|
|
|
722
724
|
*/
|
|
723
725
|
declare function getIndividualVersionNumbers(version: string): [number, number, number];
|
|
724
726
|
//#endregion
|
|
727
|
+
//#region src/functions/versioning/incrementVersion.d.ts
|
|
728
|
+
interface IncrementVersionOptions {
|
|
729
|
+
/** Whether to omit the `v` prefix from the output version or not. */
|
|
730
|
+
omitPrefix?: boolean;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Increments the given input version depending on the given increment type.
|
|
734
|
+
*
|
|
735
|
+
* @param version - The version to increment
|
|
736
|
+
* @param incrementType - The type of increment. Can be one of the following:
|
|
737
|
+
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
738
|
+
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
739
|
+
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
740
|
+
* @param options - Extra options to apply.
|
|
741
|
+
*
|
|
742
|
+
* @returns A new string representing the version with the increment applied.
|
|
743
|
+
*/
|
|
744
|
+
declare function incrementVersion(version: string, incrementType: VersionType, options?: IncrementVersionOptions): string;
|
|
745
|
+
//#endregion
|
|
725
746
|
//#region src/functions/versioning/parseVersion.d.ts
|
|
726
747
|
interface ParseVersionOptions {
|
|
748
|
+
/** Whether to omit the `v` prefix from the output version or not. */
|
|
727
749
|
omitPrefix?: boolean;
|
|
728
750
|
}
|
|
729
751
|
/**
|
|
@@ -740,4 +762,4 @@ interface ParseVersionOptions {
|
|
|
740
762
|
*/
|
|
741
763
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
742
764
|
//#endregion
|
|
743
|
-
export { APIError, type ArrayElement, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DeepReadonly, type DisallowUndefined, type Email, type Env, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, type RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, type StringListToArrayOptions, type UUID, VERSION_NUMBER_REGEX, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
|
765
|
+
export { APIError, type ArrayElement, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DeepReadonly, type DisallowUndefined, type Email, type Env, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, type ParseVersionOptions, type RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, type StringListToArrayOptions, type UUID, VERSION_NUMBER_REGEX, type VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -1089,4 +1089,29 @@ function determineVersionType(version) {
|
|
|
1089
1089
|
var determineVersionType_default = determineVersionType;
|
|
1090
1090
|
|
|
1091
1091
|
//#endregion
|
|
1092
|
-
|
|
1092
|
+
//#region src/functions/versioning/incrementVersion.ts
|
|
1093
|
+
/**
|
|
1094
|
+
* Increments the given input version depending on the given increment type.
|
|
1095
|
+
*
|
|
1096
|
+
* @param version - The version to increment
|
|
1097
|
+
* @param incrementType - The type of increment. Can be one of the following:
|
|
1098
|
+
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
1099
|
+
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
1100
|
+
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
1101
|
+
* @param options - Extra options to apply.
|
|
1102
|
+
*
|
|
1103
|
+
* @returns A new string representing the version with the increment applied.
|
|
1104
|
+
*/
|
|
1105
|
+
function incrementVersion(version, incrementType, options) {
|
|
1106
|
+
const [major, minor, patch] = getIndividualVersionNumbers_default(version);
|
|
1107
|
+
const newVersion = {
|
|
1108
|
+
major: `${major + 1}.0.0`,
|
|
1109
|
+
minor: `${major}.${minor + 1}.0`,
|
|
1110
|
+
patch: `${major}.${minor}.${patch + 1}`
|
|
1111
|
+
}[incrementType];
|
|
1112
|
+
return parseVersion_default(newVersion, { omitPrefix: options?.omitPrefix });
|
|
1113
|
+
}
|
|
1114
|
+
var incrementVersion_default = incrementVersion;
|
|
1115
|
+
|
|
1116
|
+
//#endregion
|
|
1117
|
+
export { APIError_default as APIError, DataError_default as DataError, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, deepCopy_default as deepCopy, deepFreeze_default as deepFreeze, determineVersionType_default as determineVersionType, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, incrementVersion_default as incrementVersion, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normaliseIndents_default as normaliseIndents, normalizeImportPath_default as normalizeImportPath, normalizeIndents, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, Email_default as parseEmail, parseEnv_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, UUID_default as parseUUID, parseVersion_default as parseVersion, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeIndents_default as removeIndents, stringListToArray_default as stringListToArray, stringToBoolean, truncate_default as truncate, wait_default as wait };
|