@alextheman/utility 3.4.1 → 3.5.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 +5 -2
- package/dist/index.d.cts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/index.js +5 -2
- package/package.json +20 -22
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;
|
|
@@ -397,7 +400,7 @@ var omitProperties_default = omitProperties;
|
|
|
397
400
|
//#region src/functions/parsers/parseBoolean.ts
|
|
398
401
|
function parseBoolean(inputString) {
|
|
399
402
|
const normalisedString = inputString.toLowerCase();
|
|
400
|
-
if (
|
|
403
|
+
if (!["true", "false"].includes(normalisedString)) throw new TypeError("INVALID_BOOLEAN_STRING");
|
|
401
404
|
return normalisedString === "true";
|
|
402
405
|
}
|
|
403
406
|
/** @deprecated This function has been renamed to parseBoolean. */
|
package/dist/index.d.cts
CHANGED
|
@@ -84,20 +84,20 @@ type RecordKey = string | number | symbol;
|
|
|
84
84
|
//#region src/functions/createFormData.d.ts
|
|
85
85
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
86
86
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
87
|
-
interface CreateFormDataOptionsBase<K extends RecordKey> {
|
|
88
|
-
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K, FormDataArrayResolutionStrategy>>;
|
|
87
|
+
interface CreateFormDataOptionsBase<K$1 extends RecordKey> {
|
|
88
|
+
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K$1, FormDataArrayResolutionStrategy>>;
|
|
89
89
|
}
|
|
90
|
-
interface CreateFormDataOptionsUndefinedOrNullResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
91
|
-
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
92
|
-
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
90
|
+
interface CreateFormDataOptionsUndefinedOrNullResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
91
|
+
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
92
|
+
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
93
93
|
nullableResolution?: never;
|
|
94
94
|
}
|
|
95
|
-
interface CreateFormDataOptionsNullableResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
95
|
+
interface CreateFormDataOptionsNullableResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
96
96
|
undefinedResolution?: never;
|
|
97
97
|
nullResolution?: never;
|
|
98
|
-
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
98
|
+
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
99
99
|
}
|
|
100
|
-
type CreateFormDataOptions<K extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K> | CreateFormDataOptionsNullableResolution<K>;
|
|
100
|
+
type CreateFormDataOptions<K$1 extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K$1> | CreateFormDataOptionsNullableResolution<K$1>;
|
|
101
101
|
declare function createFormData<T extends Record<RecordKey, unknown>>(data: T, options?: CreateFormDataOptions<keyof T>): FormData;
|
|
102
102
|
//#endregion
|
|
103
103
|
//#region src/functions/createTemplateStringsArray.d.ts
|
|
@@ -124,8 +124,11 @@ declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
|
124
124
|
//#region src/functions/deepCopy.d.ts
|
|
125
125
|
declare function deepCopy<T extends object>(object: T): T;
|
|
126
126
|
//#endregion
|
|
127
|
+
//#region src/types/DeepReadonly.d.ts
|
|
128
|
+
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;
|
|
129
|
+
//#endregion
|
|
127
130
|
//#region src/functions/deepFreeze.d.ts
|
|
128
|
-
declare function deepFreeze<T extends object>(object: T):
|
|
131
|
+
declare function deepFreeze<T extends object>(object: T): DeepReadonly<T>;
|
|
129
132
|
//#endregion
|
|
130
133
|
//#region src/functions/getRandomNumber.d.ts
|
|
131
134
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
@@ -147,7 +150,7 @@ declare function normalizeImportPath(importPath: string): string;
|
|
|
147
150
|
declare const normaliseImportPath: typeof normalizeImportPath;
|
|
148
151
|
//#endregion
|
|
149
152
|
//#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>;
|
|
153
|
+
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
154
|
//#endregion
|
|
152
155
|
//#region src/functions/parsers/parseBoolean.d.ts
|
|
153
156
|
declare function parseBoolean(inputString: string): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -84,20 +84,20 @@ type RecordKey = string | number | symbol;
|
|
|
84
84
|
//#region src/functions/createFormData.d.ts
|
|
85
85
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
86
86
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
87
|
-
interface CreateFormDataOptionsBase<K extends RecordKey> {
|
|
88
|
-
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K, FormDataArrayResolutionStrategy>>;
|
|
87
|
+
interface CreateFormDataOptionsBase<K$1 extends RecordKey> {
|
|
88
|
+
arrayResolution?: FormDataArrayResolutionStrategy | Partial<Record<K$1, FormDataArrayResolutionStrategy>>;
|
|
89
89
|
}
|
|
90
|
-
interface CreateFormDataOptionsUndefinedOrNullResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
91
|
-
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
92
|
-
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
90
|
+
interface CreateFormDataOptionsUndefinedOrNullResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
91
|
+
undefinedResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
92
|
+
nullResolution?: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
93
93
|
nullableResolution?: never;
|
|
94
94
|
}
|
|
95
|
-
interface CreateFormDataOptionsNullableResolution<K extends RecordKey> extends CreateFormDataOptionsBase<K> {
|
|
95
|
+
interface CreateFormDataOptionsNullableResolution<K$1 extends RecordKey> extends CreateFormDataOptionsBase<K$1> {
|
|
96
96
|
undefinedResolution?: never;
|
|
97
97
|
nullResolution?: never;
|
|
98
|
-
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K, FormDataNullableResolutionStrategy>>;
|
|
98
|
+
nullableResolution: FormDataNullableResolutionStrategy | Partial<Record<K$1, FormDataNullableResolutionStrategy>>;
|
|
99
99
|
}
|
|
100
|
-
type CreateFormDataOptions<K extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K> | CreateFormDataOptionsNullableResolution<K>;
|
|
100
|
+
type CreateFormDataOptions<K$1 extends RecordKey> = CreateFormDataOptionsUndefinedOrNullResolution<K$1> | CreateFormDataOptionsNullableResolution<K$1>;
|
|
101
101
|
declare function createFormData<T extends Record<RecordKey, unknown>>(data: T, options?: CreateFormDataOptions<keyof T>): FormData;
|
|
102
102
|
//#endregion
|
|
103
103
|
//#region src/functions/createTemplateStringsArray.d.ts
|
|
@@ -124,8 +124,11 @@ declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
|
|
|
124
124
|
//#region src/functions/deepCopy.d.ts
|
|
125
125
|
declare function deepCopy<T extends object>(object: T): T;
|
|
126
126
|
//#endregion
|
|
127
|
+
//#region src/types/DeepReadonly.d.ts
|
|
128
|
+
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;
|
|
129
|
+
//#endregion
|
|
127
130
|
//#region src/functions/deepFreeze.d.ts
|
|
128
|
-
declare function deepFreeze<T extends object>(object: T):
|
|
131
|
+
declare function deepFreeze<T extends object>(object: T): DeepReadonly<T>;
|
|
129
132
|
//#endregion
|
|
130
133
|
//#region src/functions/getRandomNumber.d.ts
|
|
131
134
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
@@ -147,7 +150,7 @@ declare function normalizeImportPath(importPath: string): string;
|
|
|
147
150
|
declare const normaliseImportPath: typeof normalizeImportPath;
|
|
148
151
|
//#endregion
|
|
149
152
|
//#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>;
|
|
153
|
+
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
154
|
//#endregion
|
|
152
155
|
//#region src/functions/parsers/parseBoolean.d.ts
|
|
153
156
|
declare function parseBoolean(inputString: string): boolean;
|
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;
|
|
@@ -368,7 +371,7 @@ var omitProperties_default = omitProperties;
|
|
|
368
371
|
//#region src/functions/parsers/parseBoolean.ts
|
|
369
372
|
function parseBoolean(inputString) {
|
|
370
373
|
const normalisedString = inputString.toLowerCase();
|
|
371
|
-
if (
|
|
374
|
+
if (!["true", "false"].includes(normalisedString)) throw new TypeError("INVALID_BOOLEAN_STRING");
|
|
372
375
|
return normalisedString === "true";
|
|
373
376
|
}
|
|
374
377
|
/** @deprecated This function has been renamed to parseBoolean. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Helpful utility functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,6 +15,22 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "^4.1.13"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@alextheman/eslint-plugin": "^4.3.0",
|
|
23
|
+
"@types/node": "^24.10.1",
|
|
24
|
+
"eslint": "^9.39.1",
|
|
25
|
+
"globals": "^16.5.0",
|
|
26
|
+
"husky": "^9.1.7",
|
|
27
|
+
"jsdom": "^27.2.0",
|
|
28
|
+
"prettier": "^3.7.4",
|
|
29
|
+
"tsdown": "^0.17.0",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
32
|
+
"vitest": "^4.0.15"
|
|
33
|
+
},
|
|
18
34
|
"scripts": {
|
|
19
35
|
"build": "tsdown",
|
|
20
36
|
"change-major": "pnpm version major -m \"Change version number to v%s\"",
|
|
@@ -32,28 +48,10 @@
|
|
|
32
48
|
"lint-prettier-javascript": "prettier --check \"./**/*.js\"",
|
|
33
49
|
"lint-prettier-typescript": "prettier --check --parser typescript \"./**/*.ts\"",
|
|
34
50
|
"lint-tsc": "tsc --noEmit",
|
|
35
|
-
"prepare": "husky",
|
|
36
51
|
"test": "vitest run",
|
|
37
52
|
"test-watch": "vitest",
|
|
38
|
-
"update-dependencies": "
|
|
53
|
+
"update-dependencies": "pnpm update --latest && pnpm update",
|
|
39
54
|
"use-live-eslint-plugin": "pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev @alextheman/eslint-plugin",
|
|
40
55
|
"use-local-eslint-plugin": "npm --prefix ../eslint-plugin run create-local-package && pnpm uninstall @alextheman/eslint-plugin && pnpm install --save-dev ../eslint-plugin/alextheman-eslint-plugin-*.tgz"
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
"zod": "^4.1.13"
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@alextheman/eslint-plugin": "^4.2.3",
|
|
47
|
-
"@types/node": "^24.10.1",
|
|
48
|
-
"eslint": "^9.39.1",
|
|
49
|
-
"globals": "^16.5.0",
|
|
50
|
-
"husky": "^9.1.7",
|
|
51
|
-
"jsdom": "^27.2.0",
|
|
52
|
-
"prettier": "^3.7.2",
|
|
53
|
-
"tsdown": "^0.16.8",
|
|
54
|
-
"typescript": "^5.9.3",
|
|
55
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
56
|
-
"vitest": "^4.0.14"
|
|
57
|
-
},
|
|
58
|
-
"packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a"
|
|
59
|
-
}
|
|
56
|
+
}
|
|
57
|
+
}
|