-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
99 lines (89 loc) · 3.34 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
declare namespace rbush {
export interface BBox {
minX: number;
minY: number;
maxX: number;
maxY: number;
}
export interface RBush<T> {
/**
* Insert an item. To insert many items, use load().
*/
insert(item: T): RBush<T>;
/**
* Bulk-insert the given data into the tree.
*
* Bulk insertion is usually ~2-3 times faster than inserting items one by one.
* After bulk loading (bulk insertion into an empty tree), subsequent query
* performance is also ~20-30% better.
*
* Note that when you do bulk insertion into an existing tree, it bulk-loads
* the given data into a separate tree and inserts the smaller tree into the
* larger tree. This means that bulk insertion works very well for clustered
* data (where items in one update are close to each other), but makes query
* performance worse if the data is scattered.
*/
load(items: T[]): RBush<T>;
/**
* Remove a previously inserted item.
*
* By default, RBush removes objects by reference. However, you can pass a
* custom equals function to compare by value for removal, which is useful
* when you only have a copy of the object you need removed (e.g. loaded
* from server).
*/
remove(item: T, equals?: (a: T, b: T) => boolean): RBush<T>;
/** Remove all items */
clear(): RBush<T>;
/**
* Returns an array of data items (points or rectangles) that the given
* bounding box intersects.
*
* Note that the search method accepts a bounding box in {minX, minY, maxX, maxY}
* format regardless of the format specified in the constructor (which only
* affects inserted objects).
*/
search(bbox: BBox): T[];
/** Returns all items of the tree. */
all(): T[];
/**
* Export data as JSON object.
*
* Importing and exporting as JSON allows you to use RBush on both the server
* (using Node.js) and the browser combined, e.g. first indexing the data on
* the server and and then importing the resulting tree data on the client
* for searching.
*
* Note that the nodeSize option passed to the constructor must be the same
* in both trees for export/import to work properly.
*/
toJSON(): any;
/**
* Import previously exported data.
*
* Importing and exporting as JSON allows you to use RBush on both the server
* (using Node.js) and the browser combined, e.g. first indexing the data on
* the server and and then importing the resulting tree data on the client
* for searching.
*
* Note that the nodeSize option passed to the constructor must be the same
* in both trees for export/import to work properly.
*/
fromJSON(data: any): RBush<T>;
}
interface IRBush {
/**
* Create a spatial index.
*
* An optional argument to rbush defines the maximum number of entries in a tree node.
* 9 (used by default) is a reasonable choice for most applications. Higher value means\
* faster insertion and slower search, and vice versa.
*/
<T extends BBox>(nodeSize?: number): RBush<T>;
<T>(nodeSize: number, formatter: string[]): RBush<T>;
}
}
declare module 'rbush' {
const temp: rbush.IRBush;
export = temp;
}