@alextheman/utility 5.16.0 → 5.17.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/index.cjs +34 -0
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +33 -1
- package/package.json +14 -11
package/dist/index.cjs
CHANGED
|
@@ -1871,6 +1871,38 @@ function assertNotNull(input) {
|
|
|
1871
1871
|
if (input === null) throw new DataError$1({ input }, "NULL_INPUT", "Expected the input not to be null");
|
|
1872
1872
|
}
|
|
1873
1873
|
//#endregion
|
|
1874
|
+
//#region src/root/errors/assertNotNullable.ts
|
|
1875
|
+
/**
|
|
1876
|
+
* Asserts that a given input is not `undefined` or `null`, and throws a DataError if it does.
|
|
1877
|
+
*
|
|
1878
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined` or `null`.
|
|
1879
|
+
*
|
|
1880
|
+
* @template InputType The type of the input.
|
|
1881
|
+
*
|
|
1882
|
+
* @param input - The input to assert against.
|
|
1883
|
+
*
|
|
1884
|
+
* @throws {DataError} If the input is `undefined` or `null`.
|
|
1885
|
+
*/
|
|
1886
|
+
function assertNotNullable(input) {
|
|
1887
|
+
if (input === null || input === void 0) throw new DataError$1({ input }, "NULLABLE_INPUT", "Expected the input not to be undefined or null");
|
|
1888
|
+
}
|
|
1889
|
+
//#endregion
|
|
1890
|
+
//#region src/root/errors/assertNotUndefined.ts
|
|
1891
|
+
/**
|
|
1892
|
+
* Asserts that a given input is not `undefined`, and throws a DataError if it does.
|
|
1893
|
+
*
|
|
1894
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined`.
|
|
1895
|
+
*
|
|
1896
|
+
* @template InputType The type of the input.
|
|
1897
|
+
*
|
|
1898
|
+
* @param input - The input to assert against.
|
|
1899
|
+
*
|
|
1900
|
+
* @throws {DataError} If the input is `undefined`.
|
|
1901
|
+
*/
|
|
1902
|
+
function assertNotUndefined(input) {
|
|
1903
|
+
if (input === void 0) throw new DataError$1({ input }, "UNDEFINED_INPUT", "Expected the input not to be undefined");
|
|
1904
|
+
}
|
|
1905
|
+
//#endregion
|
|
1874
1906
|
exports.APIError = APIError;
|
|
1875
1907
|
exports.DataError = DataError;
|
|
1876
1908
|
exports.Env = Env;
|
|
@@ -1886,6 +1918,8 @@ exports.VersionType = VersionType;
|
|
|
1886
1918
|
exports.addDaysToDate = addDaysToDate;
|
|
1887
1919
|
exports.appendSemicolon = appendSemicolon;
|
|
1888
1920
|
exports.assertNotNull = assertNotNull;
|
|
1921
|
+
exports.assertNotNullable = assertNotNullable;
|
|
1922
|
+
exports.assertNotUndefined = assertNotUndefined;
|
|
1889
1923
|
exports.az = az;
|
|
1890
1924
|
exports.calculateMonthlyDifference = calculateMonthlyDifference;
|
|
1891
1925
|
exports.camelToKebab = camelToKebab;
|
package/dist/index.d.cts
CHANGED
|
@@ -1137,6 +1137,34 @@ type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condit
|
|
|
1137
1137
|
*/
|
|
1138
1138
|
declare function assertNotNull<InputType>(input: InputType): asserts input is NonNull<InputType>;
|
|
1139
1139
|
//#endregion
|
|
1140
|
+
//#region src/root/errors/assertNotNullable.d.ts
|
|
1141
|
+
/**
|
|
1142
|
+
* Asserts that a given input is not `undefined` or `null`, and throws a DataError if it does.
|
|
1143
|
+
*
|
|
1144
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined` or `null`.
|
|
1145
|
+
*
|
|
1146
|
+
* @template InputType The type of the input.
|
|
1147
|
+
*
|
|
1148
|
+
* @param input - The input to assert against.
|
|
1149
|
+
*
|
|
1150
|
+
* @throws {DataError} If the input is `undefined` or `null`.
|
|
1151
|
+
*/
|
|
1152
|
+
declare function assertNotNullable<InputType>(input: InputType): asserts input is NonNullable<InputType>;
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region src/root/errors/assertNotUndefined.d.ts
|
|
1155
|
+
/**
|
|
1156
|
+
* Asserts that a given input is not `undefined`, and throws a DataError if it does.
|
|
1157
|
+
*
|
|
1158
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined`.
|
|
1159
|
+
*
|
|
1160
|
+
* @template InputType The type of the input.
|
|
1161
|
+
*
|
|
1162
|
+
* @param input - The input to assert against.
|
|
1163
|
+
*
|
|
1164
|
+
* @throws {DataError} If the input is `undefined`.
|
|
1165
|
+
*/
|
|
1166
|
+
declare function assertNotUndefined<InputType>(input: InputType): asserts input is NonUndefined<InputType>;
|
|
1167
|
+
//#endregion
|
|
1140
1168
|
//#region src/v6/CodeError.d.ts
|
|
1141
1169
|
interface ExpectErrorOptions<ErrorCode extends string = string> {
|
|
1142
1170
|
expectedCode?: ErrorCode;
|
|
@@ -1340,4 +1368,4 @@ declare const az: {
|
|
|
1340
1368
|
};
|
|
1341
1369
|
};
|
|
1342
1370
|
//#endregion
|
|
1343
|
-
export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, type NonNull, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, type StringListToArrayOptions, ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, assertNotNull, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
1371
|
+
export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, type NonNull, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, type StringListToArrayOptions, ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
package/dist/index.d.ts
CHANGED
|
@@ -1137,6 +1137,34 @@ type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condit
|
|
|
1137
1137
|
*/
|
|
1138
1138
|
declare function assertNotNull<InputType>(input: InputType): asserts input is NonNull<InputType>;
|
|
1139
1139
|
//#endregion
|
|
1140
|
+
//#region src/root/errors/assertNotNullable.d.ts
|
|
1141
|
+
/**
|
|
1142
|
+
* Asserts that a given input is not `undefined` or `null`, and throws a DataError if it does.
|
|
1143
|
+
*
|
|
1144
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined` or `null`.
|
|
1145
|
+
*
|
|
1146
|
+
* @template InputType The type of the input.
|
|
1147
|
+
*
|
|
1148
|
+
* @param input - The input to assert against.
|
|
1149
|
+
*
|
|
1150
|
+
* @throws {DataError} If the input is `undefined` or `null`.
|
|
1151
|
+
*/
|
|
1152
|
+
declare function assertNotNullable<InputType>(input: InputType): asserts input is NonNullable<InputType>;
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region src/root/errors/assertNotUndefined.d.ts
|
|
1155
|
+
/**
|
|
1156
|
+
* Asserts that a given input is not `undefined`, and throws a DataError if it does.
|
|
1157
|
+
*
|
|
1158
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined`.
|
|
1159
|
+
*
|
|
1160
|
+
* @template InputType The type of the input.
|
|
1161
|
+
*
|
|
1162
|
+
* @param input - The input to assert against.
|
|
1163
|
+
*
|
|
1164
|
+
* @throws {DataError} If the input is `undefined`.
|
|
1165
|
+
*/
|
|
1166
|
+
declare function assertNotUndefined<InputType>(input: InputType): asserts input is NonUndefined<InputType>;
|
|
1167
|
+
//#endregion
|
|
1140
1168
|
//#region src/v6/CodeError.d.ts
|
|
1141
1169
|
interface ExpectErrorOptions<ErrorCode extends string = string> {
|
|
1142
1170
|
expectedCode?: ErrorCode;
|
|
@@ -1340,4 +1368,4 @@ declare const az: {
|
|
|
1340
1368
|
};
|
|
1341
1369
|
};
|
|
1342
1370
|
//#endregion
|
|
1343
|
-
export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, type NonNull, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, type StringListToArrayOptions, ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, assertNotNull, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
1371
|
+
export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, type NonNull, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, type StringListToArrayOptions, ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
package/dist/index.js
CHANGED
|
@@ -1847,4 +1847,36 @@ function assertNotNull(input) {
|
|
|
1847
1847
|
if (input === null) throw new DataError$1({ input }, "NULL_INPUT", "Expected the input not to be null");
|
|
1848
1848
|
}
|
|
1849
1849
|
//#endregion
|
|
1850
|
-
|
|
1850
|
+
//#region src/root/errors/assertNotNullable.ts
|
|
1851
|
+
/**
|
|
1852
|
+
* Asserts that a given input is not `undefined` or `null`, and throws a DataError if it does.
|
|
1853
|
+
*
|
|
1854
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined` or `null`.
|
|
1855
|
+
*
|
|
1856
|
+
* @template InputType The type of the input.
|
|
1857
|
+
*
|
|
1858
|
+
* @param input - The input to assert against.
|
|
1859
|
+
*
|
|
1860
|
+
* @throws {DataError} If the input is `undefined` or `null`.
|
|
1861
|
+
*/
|
|
1862
|
+
function assertNotNullable(input) {
|
|
1863
|
+
if (input === null || input === void 0) throw new DataError$1({ input }, "NULLABLE_INPUT", "Expected the input not to be undefined or null");
|
|
1864
|
+
}
|
|
1865
|
+
//#endregion
|
|
1866
|
+
//#region src/root/errors/assertNotUndefined.ts
|
|
1867
|
+
/**
|
|
1868
|
+
* Asserts that a given input is not `undefined`, and throws a DataError if it does.
|
|
1869
|
+
*
|
|
1870
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined`.
|
|
1871
|
+
*
|
|
1872
|
+
* @template InputType The type of the input.
|
|
1873
|
+
*
|
|
1874
|
+
* @param input - The input to assert against.
|
|
1875
|
+
*
|
|
1876
|
+
* @throws {DataError} If the input is `undefined`.
|
|
1877
|
+
*/
|
|
1878
|
+
function assertNotUndefined(input) {
|
|
1879
|
+
if (input === void 0) throw new DataError$1({ input }, "UNDEFINED_INPUT", "Expected the input not to be undefined");
|
|
1880
|
+
}
|
|
1881
|
+
//#endregion
|
|
1882
|
+
export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0",
|
|
4
4
|
"description": "Helpful utility functions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,34 +37,37 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"dotenv": "17.4.2",
|
|
40
|
-
"execa": "9.6.1"
|
|
41
|
-
"zod": "4.3.6"
|
|
40
|
+
"execa": "9.6.1"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@alextheman/eslint-plugin": "5.
|
|
43
|
+
"@alextheman/eslint-plugin": "5.14.0",
|
|
45
44
|
"@types/node": "25.6.0",
|
|
46
|
-
"alex-c-line": "2.7.
|
|
45
|
+
"alex-c-line": "2.7.2",
|
|
47
46
|
"cross-env": "10.1.0",
|
|
48
47
|
"dotenv-cli": "11.0.0",
|
|
49
|
-
"eslint": "10.
|
|
50
|
-
"globals": "17.
|
|
48
|
+
"eslint": "10.3.0",
|
|
49
|
+
"globals": "17.6.0",
|
|
51
50
|
"husky": "9.1.7",
|
|
52
|
-
"jsdom": "29.
|
|
51
|
+
"jsdom": "29.1.1",
|
|
53
52
|
"prettier": "3.8.3",
|
|
54
53
|
"tempy": "3.2.0",
|
|
55
|
-
"tsdown": "0.21.
|
|
54
|
+
"tsdown": "0.21.10",
|
|
56
55
|
"tsx": "4.21.0",
|
|
57
56
|
"typedoc": "0.28.19",
|
|
58
57
|
"typedoc-plugin-markdown": "4.11.0",
|
|
59
58
|
"typedoc-rhineai-theme": "1.2.0",
|
|
60
59
|
"typescript": "6.0.3",
|
|
61
|
-
"typescript-eslint": "8.59.
|
|
60
|
+
"typescript-eslint": "8.59.1",
|
|
62
61
|
"vite": "8.0.10",
|
|
63
|
-
"vitest": "4.1.5"
|
|
62
|
+
"vitest": "4.1.5",
|
|
63
|
+
"zod": "4.4.2"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=22.3.0"
|
|
67
67
|
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"zod": ">=4.0.0"
|
|
70
|
+
},
|
|
68
71
|
"scripts": {
|
|
69
72
|
"build": "tsdown",
|
|
70
73
|
"build-configs": "tsdown --config tsdown.configs.config.ts",
|