@1nkvi/utils 0.3.0 → 0.3.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/build/artifacts/src/types/DotPaths.d.ts +1 -1
- package/build/artifacts/src/types/DotPathsWithArrayIndex.d.ts +1 -1
- package/build/artifacts/src/types/FlatObject.d.ts +2 -1
- package/build/artifacts/src/types/LeafDotPaths.d.ts +1 -1
- package/package.json +1 -1
- package/build/artifacts/src/merge/DeepPartial.d.ts +0 -6
- package/build/artifacts/src/merge/DeepPartial.js +0 -1
- package/build/artifacts/src/merge/utils.d.ts +0 -4
- package/build/artifacts/src/merge/utils.js +0 -14
|
@@ -10,5 +10,5 @@ import type { IsPlainObject } from "../types/IsPlainObject";
|
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
12
|
export type DotPaths<TObject> = {
|
|
13
|
-
[TKey in keyof TObject]
|
|
13
|
+
[TKey in keyof TObject]-?: IsPlainObject<TObject[TKey]> extends true ? (TKey & string) | `${TKey & string}.${DotPaths<TObject[TKey]>}` : TKey & string;
|
|
14
14
|
}[keyof TObject];
|
|
@@ -17,5 +17,5 @@ import type { IsPlainObject } from "../types/IsPlainObject";
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export type DotPathsWithArrayIndex<TObject> = TObject extends unknown[] ? TObject extends (infer TElement)[] ? TElement extends unknown[] ? `${number}` | `${number}.${DotPathsWithArrayIndex<TElement>}` : IsPlainObject<TElement> extends true ? `${number}` | `${number}.${DotPathsWithArrayIndex<TElement>}` : `${number}` : never : {
|
|
20
|
-
[TKey in keyof TObject]
|
|
20
|
+
[TKey in keyof TObject]-?: TObject[TKey] extends unknown[] ? (TKey & string) | `${TKey & string}.${DotPathsWithArrayIndex<TObject[TKey]>}` : IsPlainObject<TObject[TKey]> extends true ? (TKey & string) | `${TKey & string}.${DotPathsWithArrayIndex<TObject[TKey]>}` : TKey & string;
|
|
21
21
|
}[keyof TObject];
|
|
@@ -42,7 +42,8 @@ export type FlatObject<T> = T extends readonly (infer TElement)[] ? IsPlainObjec
|
|
|
42
42
|
[SubKey in keyof FlatObject<TElement> & string as `${number}.${SubKey}`]: FlatObject<TElement>[SubKey];
|
|
43
43
|
} : {
|
|
44
44
|
[Index in `${number}`]: TElement;
|
|
45
|
-
} :
|
|
45
|
+
} : FlatObjectFromKeys<Required<T>>;
|
|
46
|
+
type FlatObjectFromKeys<T> = UnionToIntersection<{
|
|
46
47
|
[Key in keyof T & string]: IsPlainObject<T[Key]> extends true ? {
|
|
47
48
|
[FlatKey in Key]: T[Key];
|
|
48
49
|
} & {
|
|
@@ -16,5 +16,5 @@ import type { IsPlainObject } from "../types/IsPlainObject";
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export type LeafDotPaths<TObject> = {
|
|
19
|
-
[TKey in keyof TObject]
|
|
19
|
+
[TKey in keyof TObject]-?: IsPlainObject<TObject[TKey]> extends true ? `${TKey & string}.${LeafDotPaths<TObject[TKey]>}` : TKey & string;
|
|
20
20
|
}[keyof TObject];
|
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expects json object. Walks through the children and makes all keys optional
|
|
3
|
-
*/
|
|
4
|
-
export type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends object ? {
|
|
5
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
6
|
-
} : T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function isPlainObject(v: unknown): v is Record<string, unknown>;
|
|
2
|
-
export declare function isEmptyObject(v: unknown): v is object;
|
|
3
|
-
export declare function isEmptyArray(v: unknown): v is Array<unknown>;
|
|
4
|
-
export declare function isInvalidNumber(v: unknown): boolean;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function isPlainObject(v) {
|
|
2
|
-
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3
|
-
}
|
|
4
|
-
export function isEmptyObject(v) {
|
|
5
|
-
if (!isPlainObject(v))
|
|
6
|
-
return false;
|
|
7
|
-
return Object.keys(v).length === 0;
|
|
8
|
-
}
|
|
9
|
-
export function isEmptyArray(v) {
|
|
10
|
-
return Array.isArray(v) && v.length === 0;
|
|
11
|
-
}
|
|
12
|
-
export function isInvalidNumber(v) {
|
|
13
|
-
return typeof v === "number" && (!Number.isFinite(v) || Number.isNaN(v));
|
|
14
|
-
}
|