@alextheman/utility 2.12.1 → 2.13.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/index.cjs +12 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +11 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,7 @@ __export(index_exports, {
|
|
|
54
54
|
fillArray: () => fillArray_default,
|
|
55
55
|
formatDateAndTime: () => formatDateAndTime_default,
|
|
56
56
|
getRandomNumber: () => getRandomNumber_default,
|
|
57
|
+
getRecordKeys: () => getRecordKeys_default,
|
|
57
58
|
httpErrorCodeLookup: () => httpErrorCodeLookup,
|
|
58
59
|
interpolateObjects: () => interpolateObjects_default,
|
|
59
60
|
isLeapYear: () => isLeapYear_default,
|
|
@@ -126,7 +127,10 @@ function getNullableResolutionStrategy(key, strategy) {
|
|
|
126
127
|
var _a;
|
|
127
128
|
return (_a = typeof strategy === "object" ? strategy[key] : strategy) != null ? _a : "empty";
|
|
128
129
|
}
|
|
129
|
-
function createFormData(data, options = {
|
|
130
|
+
function createFormData(data, options = {
|
|
131
|
+
arrayResolution: "stringify",
|
|
132
|
+
nullableResolution: "empty"
|
|
133
|
+
}) {
|
|
130
134
|
const formData = new FormData();
|
|
131
135
|
function resolveNullablesByStrategy(key, value, resolutionStrategy) {
|
|
132
136
|
switch (resolutionStrategy) {
|
|
@@ -276,6 +280,12 @@ function getRandomNumber(lowerBound, upperBound) {
|
|
|
276
280
|
}
|
|
277
281
|
var getRandomNumber_default = getRandomNumber;
|
|
278
282
|
|
|
283
|
+
// src/functions/getRecordKeys.ts
|
|
284
|
+
function getRecordKeys(record) {
|
|
285
|
+
return Object.keys(record);
|
|
286
|
+
}
|
|
287
|
+
var getRecordKeys_default = getRecordKeys;
|
|
288
|
+
|
|
279
289
|
// src/functions/isLeapYear.ts
|
|
280
290
|
function isLeapYear(year) {
|
|
281
291
|
const parsedYear = parseIntStrict_default(`${year}`);
|
|
@@ -509,6 +519,7 @@ var UUID_default = parseUUID;
|
|
|
509
519
|
fillArray,
|
|
510
520
|
formatDateAndTime,
|
|
511
521
|
getRandomNumber,
|
|
522
|
+
getRecordKeys,
|
|
512
523
|
httpErrorCodeLookup,
|
|
513
524
|
interpolateObjects,
|
|
514
525
|
isLeapYear,
|
package/dist/index.d.cts
CHANGED
|
@@ -58,7 +58,7 @@ interface CreateFormDataOptionsNullableResolution<K extends RecordKey> extends C
|
|
|
58
58
|
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
59
59
|
}
|
|
60
60
|
type CreateFormDataOptions<K extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K> | CreateFormDataOptionsNullableResolution<K>;
|
|
61
|
-
declare function createFormData<T extends Record<RecordKey, unknown
|
|
61
|
+
declare function createFormData<T extends Record<RecordKey, unknown>>(data: T, options?: CreateFormDataOptions<keyof T>): FormData;
|
|
62
62
|
|
|
63
63
|
declare function fillArray<T>(callback: (index: number) => Promise<T>, length?: number): Promise<T[]>;
|
|
64
64
|
declare function fillArray<T>(callback: (index: number) => T, length?: number): T[];
|
|
@@ -67,6 +67,8 @@ declare function formatDateAndTime(inputDate: Date): string;
|
|
|
67
67
|
|
|
68
68
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
69
69
|
|
|
70
|
+
declare function getRecordKeys<T extends Record<RecordKey, unknown>>(record: T & object): (keyof T)[];
|
|
71
|
+
|
|
70
72
|
declare function isLeapYear(year: number): boolean;
|
|
71
73
|
|
|
72
74
|
declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
@@ -99,4 +101,4 @@ declare function wait(seconds: number): Promise<void>;
|
|
|
99
101
|
|
|
100
102
|
declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
101
103
|
|
|
102
|
-
export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
|
|
104
|
+
export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ interface CreateFormDataOptionsNullableResolution<K extends RecordKey> extends C
|
|
|
58
58
|
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
59
59
|
}
|
|
60
60
|
type CreateFormDataOptions<K extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K> | CreateFormDataOptionsNullableResolution<K>;
|
|
61
|
-
declare function createFormData<T extends Record<RecordKey, unknown
|
|
61
|
+
declare function createFormData<T extends Record<RecordKey, unknown>>(data: T, options?: CreateFormDataOptions<keyof T>): FormData;
|
|
62
62
|
|
|
63
63
|
declare function fillArray<T>(callback: (index: number) => Promise<T>, length?: number): Promise<T[]>;
|
|
64
64
|
declare function fillArray<T>(callback: (index: number) => T, length?: number): T[];
|
|
@@ -67,6 +67,8 @@ declare function formatDateAndTime(inputDate: Date): string;
|
|
|
67
67
|
|
|
68
68
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
69
69
|
|
|
70
|
+
declare function getRecordKeys<T extends Record<RecordKey, unknown>>(record: T & object): (keyof T)[];
|
|
71
|
+
|
|
70
72
|
declare function isLeapYear(year: number): boolean;
|
|
71
73
|
|
|
72
74
|
declare function isMonthlyMultiple(firstDate: Date, secondDate: Date): boolean;
|
|
@@ -99,4 +101,4 @@ declare function wait(seconds: number): Promise<void>;
|
|
|
99
101
|
|
|
100
102
|
declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
101
103
|
|
|
102
|
-
export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
|
|
104
|
+
export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -67,7 +67,10 @@ function getNullableResolutionStrategy(key, strategy) {
|
|
|
67
67
|
var _a;
|
|
68
68
|
return (_a = typeof strategy === "object" ? strategy[key] : strategy) != null ? _a : "empty";
|
|
69
69
|
}
|
|
70
|
-
function createFormData(data, options = {
|
|
70
|
+
function createFormData(data, options = {
|
|
71
|
+
arrayResolution: "stringify",
|
|
72
|
+
nullableResolution: "empty"
|
|
73
|
+
}) {
|
|
71
74
|
const formData = new FormData();
|
|
72
75
|
function resolveNullablesByStrategy(key, value, resolutionStrategy) {
|
|
73
76
|
switch (resolutionStrategy) {
|
|
@@ -217,6 +220,12 @@ function getRandomNumber(lowerBound, upperBound) {
|
|
|
217
220
|
}
|
|
218
221
|
var getRandomNumber_default = getRandomNumber;
|
|
219
222
|
|
|
223
|
+
// src/functions/getRecordKeys.ts
|
|
224
|
+
function getRecordKeys(record) {
|
|
225
|
+
return Object.keys(record);
|
|
226
|
+
}
|
|
227
|
+
var getRecordKeys_default = getRecordKeys;
|
|
228
|
+
|
|
220
229
|
// src/functions/isLeapYear.ts
|
|
221
230
|
function isLeapYear(year) {
|
|
222
231
|
const parsedYear = parseIntStrict_default(`${year}`);
|
|
@@ -449,6 +458,7 @@ export {
|
|
|
449
458
|
fillArray_default as fillArray,
|
|
450
459
|
formatDateAndTime_default as formatDateAndTime,
|
|
451
460
|
getRandomNumber_default as getRandomNumber,
|
|
461
|
+
getRecordKeys_default as getRecordKeys,
|
|
452
462
|
httpErrorCodeLookup,
|
|
453
463
|
interpolateObjects_default as interpolateObjects,
|
|
454
464
|
isLeapYear_default as isLeapYear,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.1",
|
|
4
4
|
"description": "Helpful utility functions",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "alextheman",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@alextheman/eslint-plugin": "^2.5.0",
|
|
40
|
-
"@eslint/js": "^9.39.
|
|
41
|
-
"@types/node": "^24.
|
|
42
|
-
"eslint": "^9.39.
|
|
40
|
+
"@eslint/js": "^9.39.1",
|
|
41
|
+
"@types/node": "^24.10.0",
|
|
42
|
+
"eslint": "^9.39.1",
|
|
43
43
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
44
44
|
"eslint-plugin-import": "^2.32.0",
|
|
45
|
-
"globals": "^16.
|
|
45
|
+
"globals": "^16.5.0",
|
|
46
46
|
"husky": "^9.1.7",
|
|
47
47
|
"jsdom": "^27.1.0",
|
|
48
48
|
"prettier": "^3.6.2",
|
|
49
49
|
"tsup": "^8.5.0",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
|
-
"typescript-eslint": "^8.46.
|
|
51
|
+
"typescript-eslint": "^8.46.3",
|
|
52
52
|
"vite-tsconfig-paths": "^5.1.4",
|
|
53
|
-
"vitest": "^4.0.
|
|
53
|
+
"vitest": "^4.0.8"
|
|
54
54
|
}
|
|
55
55
|
}
|