-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.d.ts
45 lines (37 loc) · 991 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Project:
// Definitions by: Peter Muriuki<https://gitthub.com/p-netm>
// typescript version: 3.8.3
export = FlatToNested;
/**
* Create a new FlatToNested object.
*
* @param config The configuration object.
*/
declare class FlatToNested {
constructor(config: FlatToNested.Config);
private config: FlatToNested.Config;
/**
* Convert a hierarchy from flat to nested representation.
*
* @param flat The array with the hierarchy flat representation.
*/
convert<T extends object>(flat: T[]): FlatToNested.Nested<T>;
}
declare namespace FlatToNested {
interface Dictionary<T = any> {
[key: string]: T;
}
interface ConfigOptions {
deleteParent: boolean;
}
interface Config {
id?: string;
parent?: string;
children?: string;
options?: ConfigOptions;
}
interface RecursiveObjectTree<T extends object = {}> {
[children: string]: RecursiveObjectTree<T> & T;
}
type Nested<T extends object> = RecursiveObjectTree<T> & T;
}