@alextheman/utility 3.4.2 → 3.5.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 +4 -1
- package/dist/index.d.cts +17 -11
- package/dist/index.d.ts +17 -11
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -320,7 +320,10 @@ var deepCopy_default = deepCopy;
|
|
|
320
320
|
//#endregion
|
|
321
321
|
//#region src/functions/deepFreeze.ts
|
|
322
322
|
function deepFreeze(object) {
|
|
323
|
-
for (const value of Object.values(object))
|
|
323
|
+
for (const value of Object.values(object)) {
|
|
324
|
+
if (typeof value === "function") continue;
|
|
325
|
+
if (value && typeof value === "object") deepFreeze(value);
|
|
326
|
+
}
|
|
324
327
|
return Object.freeze(object);
|
|
325
328
|
}
|
|
326
329
|
var deepFreeze_default = deepFreeze;
|
package/dist/index.d.cts
CHANGED
|
@@ -66,6 +66,12 @@ declare const uuidSchema: z.core.$ZodBranded<z.ZodUUID, "UUID">;
|
|
|
66
66
|
type UUID = z.infer<typeof uuidSchema>;
|
|
67
67
|
declare function parseUUID(UUID: unknown): UUID;
|
|
68
68
|
//#endregion
|
|
69
|
+
//#region src/types/ArrayElement.d.ts
|
|
70
|
+
type ArrayElement<T extends readonly unknown[]> = T extends readonly (infer ElementType)[] ? ElementType : never;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/types/DeepReadonly.d.ts
|
|
73
|
+
type DeepReadonly<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends (infer ItemType)[] ? readonly DeepReadonly<ItemType>[] : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
|
|
74
|
+
//#endregion
|
|
69
75
|
//#region src/types/DisallowUndefined.d.ts
|
|
70
76
|
type DisallowUndefined<T> = undefined extends T ? ["Error: Generic type cannot include undefined"] : T;
|
|
71
77
|
//#endregion
|
|
@@ -84,20 +90,20 @@ type RecordKey = string | number | symbol;
|
|
|
84
90
|
//#region src/functions/createFormData.d.ts
|
|
85
91
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
86
92
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
87
|
-
interface CreateFormDataOptionsBase<K extends RecordKey> {
|
|
88
|
-
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K, FormDataArrayResolutionStrategy>>;
|
|
93
|
+
interface CreateFormDataOptionsBase<K$1 extends RecordKey> {
|
|
94
|
+
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K$1, FormDataArrayResolutionStrategy>>;
|
|
89
95
|
}
|
|
90
|
-
interface CreateFormDataOptionsUndefinedOrNullResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
91
|
-
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
92
|
-
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
96
|
+
interface CreateFormDataOptionsUndefinedOrNullResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
97
|
+
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
98
|
+
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
93
99
|
nullableResolution?: never;
|
|
94
100
|
}
|
|
95
|
-
interface CreateFormDataOptionsNullableResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
101
|
+
interface CreateFormDataOptionsNullableResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
96
102
|
undefinedResolution?: never;
|
|
97
103
|
nullResolution?: never;
|
|
98
|
-
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
104
|
+
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
99
105
|
}
|
|
100
|
-
type CreateFormDataOptions<K extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K> | CreateFormDataOptionsNullableResolution<K>;
|
|
106
|
+
type CreateFormDataOptions<K$1 extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K$1> | CreateFormDataOptionsNullableResolution<K$1>;
|
|
101
107
|
declare function createFormData<T extends Record<RecordKey, unknown>>(data: T, options?: CreateFormDataOptions<keyof T>): FormData;
|
|
102
108
|
//#endregion
|
|
103
109
|
//#region src/functions/createTemplateStringsArray.d.ts
|
|
@@ -125,7 +131,7 @@ declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
|
125
131
|
declare function deepCopy<T extends object>(object: T): T;
|
|
126
132
|
//#endregion
|
|
127
133
|
//#region src/functions/deepFreeze.d.ts
|
|
128
|
-
declare function deepFreeze<T extends object>(object: T):
|
|
134
|
+
declare function deepFreeze<T extends object>(object: T): DeepReadonly<T>;
|
|
129
135
|
//#endregion
|
|
130
136
|
//#region src/functions/getRandomNumber.d.ts
|
|
131
137
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
@@ -147,7 +153,7 @@ declare function normalizeImportPath(importPath: string): string;
|
|
|
147
153
|
declare const normaliseImportPath: typeof normalizeImportPath;
|
|
148
154
|
//#endregion
|
|
149
155
|
//#region src/functions/omitProperties.d.ts
|
|
150
|
-
declare function omitProperties<T extends Record<string, unknown> | Readonly<Record<string, unknown>>, K extends keyof T>(object: T, keysToOmit: K | readonly K[]): Omit<T, K>;
|
|
156
|
+
declare function omitProperties<T extends Record<string, unknown> | Readonly<Record<string, unknown>>, K$1 extends keyof T>(object: T, keysToOmit: K$1 | readonly K$1[]): Omit<T, K$1>;
|
|
151
157
|
//#endregion
|
|
152
158
|
//#region src/functions/parsers/parseBoolean.d.ts
|
|
153
159
|
declare function parseBoolean(inputString: string): boolean;
|
|
@@ -210,4 +216,4 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
210
216
|
//#region src/functions/wait.d.ts
|
|
211
217
|
declare function wait(seconds: number): Promise<void>;
|
|
212
218
|
//#endregion
|
|
213
|
-
export { APIError, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Email, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, StringListToArrayOptions, UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
|
219
|
+
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, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,12 @@ declare const uuidSchema: z.core.$ZodBranded<z.ZodUUID, "UUID">;
|
|
|
66
66
|
type UUID = z.infer<typeof uuidSchema>;
|
|
67
67
|
declare function parseUUID(UUID: unknown): UUID;
|
|
68
68
|
//#endregion
|
|
69
|
+
//#region src/types/ArrayElement.d.ts
|
|
70
|
+
type ArrayElement<T extends readonly unknown[]> = T extends readonly (infer ElementType)[] ? ElementType : never;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/types/DeepReadonly.d.ts
|
|
73
|
+
type DeepReadonly<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends (infer ItemType)[] ? readonly DeepReadonly<ItemType>[] : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
|
|
74
|
+
//#endregion
|
|
69
75
|
//#region src/types/DisallowUndefined.d.ts
|
|
70
76
|
type DisallowUndefined<T> = undefined extends T ? ["Error: Generic type cannot include undefined"] : T;
|
|
71
77
|
//#endregion
|
|
@@ -84,20 +90,20 @@ type RecordKey = string | number | symbol;
|
|
|
84
90
|
//#region src/functions/createFormData.d.ts
|
|
85
91
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
86
92
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
87
|
-
interface CreateFormDataOptionsBase<K extends RecordKey> {
|
|
88
|
-
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K, FormDataArrayResolutionStrategy>>;
|
|
93
|
+
interface CreateFormDataOptionsBase<K$1 extends RecordKey> {
|
|
94
|
+
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K$1, FormDataArrayResolutionStrategy>>;
|
|
89
95
|
}
|
|
90
|
-
interface CreateFormDataOptionsUndefinedOrNullResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
91
|
-
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
92
|
-
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
96
|
+
interface CreateFormDataOptionsUndefinedOrNullResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
97
|
+
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
98
|
+
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
93
99
|
nullableResolution?: never;
|
|
94
100
|
}
|
|
95
|
-
interface CreateFormDataOptionsNullableResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
101
|
+
interface CreateFormDataOptionsNullableResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
96
102
|
undefinedResolution?: never;
|
|
97
103
|
nullResolution?: never;
|
|
98
|
-
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
104
|
+
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
99
105
|
}
|
|
100
|
-
type CreateFormDataOptions<K extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K> | CreateFormDataOptionsNullableResolution<K>;
|
|
106
|
+
type CreateFormDataOptions<K$1 extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K$1> | CreateFormDataOptionsNullableResolution<K$1>;
|
|
101
107
|
declare function createFormData<T extends Record<RecordKey, unknown>>(data: T, options?: CreateFormDataOptions<keyof T>): FormData;
|
|
102
108
|
//#endregion
|
|
103
109
|
//#region src/functions/createTemplateStringsArray.d.ts
|
|
@@ -125,7 +131,7 @@ declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
|
125
131
|
declare function deepCopy<T extends object>(object: T): T;
|
|
126
132
|
//#endregion
|
|
127
133
|
//#region src/functions/deepFreeze.d.ts
|
|
128
|
-
declare function deepFreeze<T extends object>(object: T):
|
|
134
|
+
declare function deepFreeze<T extends object>(object: T): DeepReadonly<T>;
|
|
129
135
|
//#endregion
|
|
130
136
|
//#region src/functions/getRandomNumber.d.ts
|
|
131
137
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
@@ -147,7 +153,7 @@ declare function normalizeImportPath(importPath: string): string;
|
|
|
147
153
|
declare const normaliseImportPath: typeof normalizeImportPath;
|
|
148
154
|
//#endregion
|
|
149
155
|
//#region src/functions/omitProperties.d.ts
|
|
150
|
-
declare function omitProperties<T extends Record<string, unknown> | Readonly<Record<string, unknown>>, K extends keyof T>(object: T, keysToOmit: K | readonly K[]): Omit<T, K>;
|
|
156
|
+
declare function omitProperties<T extends Record<string, unknown> | Readonly<Record<string, unknown>>, K$1 extends keyof T>(object: T, keysToOmit: K$1 | readonly K$1[]): Omit<T, K$1>;
|
|
151
157
|
//#endregion
|
|
152
158
|
//#region src/functions/parsers/parseBoolean.d.ts
|
|
153
159
|
declare function parseBoolean(inputString: string): boolean;
|
|
@@ -210,4 +216,4 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
|
|
|
210
216
|
//#region src/functions/wait.d.ts
|
|
211
217
|
declare function wait(seconds: number): Promise<void>;
|
|
212
218
|
//#endregion
|
|
213
|
-
export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, type Email, type Env, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, type RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
|
219
|
+
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 KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, type RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -291,7 +291,10 @@ var deepCopy_default = deepCopy;
|
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/functions/deepFreeze.ts
|
|
293
293
|
function deepFreeze(object) {
|
|
294
|
-
for (const value of Object.values(object))
|
|
294
|
+
for (const value of Object.values(object)) {
|
|
295
|
+
if (typeof value === "function") continue;
|
|
296
|
+
if (value && typeof value === "object") deepFreeze(value);
|
|
297
|
+
}
|
|
295
298
|
return Object.freeze(object);
|
|
296
299
|
}
|
|
297
300
|
var deepFreeze_default = deepFreeze;
|