fast-tree-builder 2.0.0 → 2.0.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/index.d.cts +4 -4
- package/index.d.mts +4 -4
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -8,10 +8,10 @@ type TreeNode<TValue, TValueKey extends PropertyKey | false, TParentKey extends
|
|
|
8
8
|
[k in Exclude<TDepthKey, false>]: number;
|
|
9
9
|
});
|
|
10
10
|
type AccessorReturnType<O, P extends (keyof O) | ((item: O) => any)> = P extends ((item: O) => infer R) ? R : P extends (keyof O) ? O[P] : never;
|
|
11
|
-
type ObjectKeysOfIterableProperties<T> = {
|
|
11
|
+
type ObjectKeysOfIterableProperties<T> = 0 extends (1 & T) ? PropertyKey : {
|
|
12
12
|
[K in keyof T]: T[K] extends (Iterable<unknown> & object) | null | undefined ? K : never;
|
|
13
13
|
}[keyof T];
|
|
14
|
-
declare function buildTree<TIdAccessor extends
|
|
14
|
+
declare function buildTree<TIdAccessor extends NoInfer<keyof TInputValue> | ((item: NoInfer<TInputValue>) => unknown), TValueKey extends PropertyKey | false = 'value', TParentKey extends PropertyKey | false = 'parent', TChildrenKey extends PropertyKey = 'children', TDepthKey extends PropertyKey | false = false, TInputValue extends (TValueKey extends false ? object : TIdAccessor extends PropertyKey ? object : unknown) = any, TResolvedValue extends (TValueKey extends false ? object : unknown) = TInputValue>(items: Iterable<TInputValue>, options: {
|
|
15
15
|
/**
|
|
16
16
|
* A string key or function used to get the item's unique identifier.
|
|
17
17
|
*/
|
|
@@ -90,14 +90,14 @@ declare function buildTree<TIdAccessor extends (keyof NoInfer<TInputValue>) | ((
|
|
|
90
90
|
*
|
|
91
91
|
* Either `parentId` or `childIds` must be provided.
|
|
92
92
|
*/
|
|
93
|
-
childIds: ObjectKeysOfIterableProperties<
|
|
93
|
+
childIds: NoInfer<ObjectKeysOfIterableProperties<TInputValue>> | ((item: NoInfer<TInputValue>) => (Iterable<unknown> & object) | null | undefined);
|
|
94
94
|
} | {
|
|
95
95
|
/**
|
|
96
96
|
* A string key or function used to get the item's parent identifier.
|
|
97
97
|
*
|
|
98
98
|
* Either `parentId` or `childIds` must be provided.
|
|
99
99
|
*/
|
|
100
|
-
parentId:
|
|
100
|
+
parentId: NoInfer<keyof TInputValue> | ((item: NoInfer<TInputValue>) => unknown);
|
|
101
101
|
/**
|
|
102
102
|
* A string key or function to retrieve a list of child identifiers from an item.
|
|
103
103
|
*
|
package/index.d.mts
CHANGED
|
@@ -8,10 +8,10 @@ type TreeNode<TValue, TValueKey extends PropertyKey | false, TParentKey extends
|
|
|
8
8
|
[k in Exclude<TDepthKey, false>]: number;
|
|
9
9
|
});
|
|
10
10
|
type AccessorReturnType<O, P extends (keyof O) | ((item: O) => any)> = P extends ((item: O) => infer R) ? R : P extends (keyof O) ? O[P] : never;
|
|
11
|
-
type ObjectKeysOfIterableProperties<T> = {
|
|
11
|
+
type ObjectKeysOfIterableProperties<T> = 0 extends (1 & T) ? PropertyKey : {
|
|
12
12
|
[K in keyof T]: T[K] extends (Iterable<unknown> & object) | null | undefined ? K : never;
|
|
13
13
|
}[keyof T];
|
|
14
|
-
export default function buildTree<TIdAccessor extends
|
|
14
|
+
export default function buildTree<TIdAccessor extends NoInfer<keyof TInputValue> | ((item: NoInfer<TInputValue>) => unknown), TValueKey extends PropertyKey | false = 'value', TParentKey extends PropertyKey | false = 'parent', TChildrenKey extends PropertyKey = 'children', TDepthKey extends PropertyKey | false = false, TInputValue extends (TValueKey extends false ? object : TIdAccessor extends PropertyKey ? object : unknown) = any, TResolvedValue extends (TValueKey extends false ? object : unknown) = TInputValue>(items: Iterable<TInputValue>, options: {
|
|
15
15
|
/**
|
|
16
16
|
* A string key or function used to get the item's unique identifier.
|
|
17
17
|
*/
|
|
@@ -90,14 +90,14 @@ export default function buildTree<TIdAccessor extends (keyof NoInfer<TInputValue
|
|
|
90
90
|
*
|
|
91
91
|
* Either `parentId` or `childIds` must be provided.
|
|
92
92
|
*/
|
|
93
|
-
childIds: ObjectKeysOfIterableProperties<
|
|
93
|
+
childIds: NoInfer<ObjectKeysOfIterableProperties<TInputValue>> | ((item: NoInfer<TInputValue>) => (Iterable<unknown> & object) | null | undefined);
|
|
94
94
|
} | {
|
|
95
95
|
/**
|
|
96
96
|
* A string key or function used to get the item's parent identifier.
|
|
97
97
|
*
|
|
98
98
|
* Either `parentId` or `childIds` must be provided.
|
|
99
99
|
*/
|
|
100
|
-
parentId:
|
|
100
|
+
parentId: NoInfer<keyof TInputValue> | ((item: NoInfer<TInputValue>) => unknown);
|
|
101
101
|
/**
|
|
102
102
|
* A string key or function to retrieve a list of child identifiers from an item.
|
|
103
103
|
*
|
package/package.json
CHANGED