@types/rbush
Advanced tools
Comparing version 2.0.2 to 3.0.0
@@ -1,8 +0,8 @@ | ||
// Type definitions for rbush 2.0.1 | ||
// Type definitions for rbush 3.0 | ||
// Project: https://github.com/mourner/rbush | ||
// Definitions by: Dan Vanderkam <http://danvk.org/> | ||
// Definitions by: Dan Vanderkam <https://github.com/danvk> | ||
// Chris Lewis <https://github.com/cmslewis> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
declare namespace rbush { | ||
export interface BBox { | ||
export interface BBox { | ||
minX: number; | ||
@@ -12,16 +12,31 @@ minY: number; | ||
maxY: number; | ||
} | ||
} | ||
export interface RBush<T> { | ||
export default class RBush<T> { | ||
/** | ||
* Insert an item. To insert many items, use load(). | ||
* Constructs an `RBush`, a high-performance 2D spatial index for points and | ||
* rectangles. Based on an optimized __R-tree__ data structure with | ||
* __bulk-insertion__ support. | ||
* | ||
* @param maxEntries 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. | ||
*/ | ||
constructor(maxEntries?: number); | ||
/** | ||
* Inserts an item. To insert many items at once, use `load()`. | ||
* | ||
* @param item The item to insert. | ||
*/ | ||
insert(item: T): RBush<T>; | ||
/** | ||
* Bulk-insert the given data into the tree. | ||
* Bulk-inserts the given items 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. | ||
* 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. | ||
* | ||
@@ -33,16 +48,22 @@ * Note that when you do bulk insertion into an existing tree, it bulk-loads | ||
* performance worse if the data is scattered. | ||
* | ||
* @param items The items to load. | ||
*/ | ||
load(items: T[]): RBush<T>; | ||
load(items: ReadonlyArray<T>): RBush<T>; | ||
/** | ||
* Remove a previously inserted item. | ||
* Removes a previously inserted item, comparing by reference. | ||
* | ||
* 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). | ||
* To remove all items, use `clear()`. | ||
* | ||
* @param item The item to remove. | ||
* @param equals A custom function that allows comparing by value instead. | ||
* Useful when you have only 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 */ | ||
/** | ||
* Removes all items. | ||
*/ | ||
clear(): RBush<T>; | ||
@@ -54,60 +75,119 @@ | ||
* | ||
* 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). | ||
* Note that the search method accepts a bounding box in `{minX, minY, maxX, | ||
* maxY}` format regardless of the data format. | ||
* | ||
* @param box The bounding box in which to search. | ||
*/ | ||
search(bbox: BBox): T[]; | ||
search(box: BBox): T[]; | ||
/** Returns all items of the tree. */ | ||
/** | ||
* Returns all items contained in the tree. | ||
*/ | ||
all(): T[]; | ||
/** | ||
* Returns true if there are any items intersecting the given bounding box, | ||
* otherwise false. | ||
* Returns `true` if there are any items intersecting the given bounding | ||
* box, otherwise `false`. | ||
* | ||
* @param box The bounding box in which to search. | ||
*/ | ||
collides(bbox: BBox): boolean; | ||
collides(box: BBox): boolean; | ||
/** | ||
* Export data as JSON object. | ||
* Returns the bounding box for the provided item. | ||
* | ||
* 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. | ||
* By default, `RBush` assumes the format of data points to be an object | ||
* with `minX`, `minY`, `maxX`, and `maxY`. However, you can specify a | ||
* custom item format by overriding `toBBox()`, `compareMinX()`, and | ||
* `compareMinY()`. | ||
* | ||
* Note that the nodeSize option passed to the constructor must be the same | ||
* in both trees for export/import to work properly. | ||
* @example | ||
* class MyRBush<T> extends RBush<T> { | ||
* toBBox([x, y]) { return { minX: x, minY: y, maxX: x, maxY: y }; } | ||
* compareMinX(a, b) { return a.x - b.x; } | ||
* compareMinY(a, b) { return a.y - b.y; } | ||
* } | ||
* const tree = new MyRBush<[number, number]>(); | ||
* tree.insert([20, 50]); // accepts [x, y] points | ||
* | ||
* @param item The item whose bounding box should be returned. | ||
*/ | ||
toJSON(): any; | ||
toBBox(item: T): BBox; | ||
/** | ||
* Import previously exported data. | ||
* Compares the minimum x coordinate of two items. Returns -1 if `a`'s | ||
* x-coordinate is smaller, 1 if `b`'s x coordinate is smaller, or 0 if | ||
* they're equal. | ||
* | ||
* 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. | ||
* By default, `RBush` assumes the format of data points to be an object | ||
* with `minX`, `minY`, `maxX`, and `maxY`. However, you can specify a | ||
* custom item format by overriding `toBBox()`, `compareMinX()`, and | ||
* `compareMinY()`. | ||
* | ||
* Note that the nodeSize option passed to the constructor must be the same | ||
* @example | ||
* class MyRBush<T> extends RBush<T> { | ||
* toBBox([x, y]) { return { minX: x, minY: y, maxX: x, maxY: y }; } | ||
* compareMinX(a, b) { return a.x - b.x; } | ||
* compareMinY(a, b) { return a.y - b.y; } | ||
* } | ||
* const tree = new MyRBush<[number, number]>(); | ||
* tree.insert([20, 50]); // accepts [x, y] points | ||
* | ||
* @param a The first item to compare. | ||
* @param b The second item to compare. | ||
*/ | ||
compareMinX(a: T, b: T): number; | ||
/** | ||
* Compares the minimum y coordinate of two items. Returns -1 if `a`'s | ||
* x-coordinate is smaller, 1 if `b`'s x coordinate is smaller, or 0 if | ||
* they're equal. | ||
* | ||
* By default, `RBush` assumes the format of data points to be an object | ||
* with `minX`, `minY`, `maxX`, and `maxY`. However, you can specify a | ||
* custom item format by overriding `toBBox()`, `compareMinX()`, and | ||
* `compareMinY()`. | ||
* | ||
* @example | ||
* class MyRBush<T> extends RBush<T> { | ||
* toBBox([x, y]) { return { minX: x, minY: y, maxX: x, maxY: y }; } | ||
* compareMinX(a, b) { return a.x - b.x; } | ||
* compareMinY(a, b) { return a.y - b.y; } | ||
* } | ||
* const tree = new MyRBush<[number, number]>(); | ||
* tree.insert([20, 50]); // accepts [x, y] points | ||
* | ||
* @param a The first item to compare. | ||
* @param b The second item to compare. | ||
*/ | ||
compareMinY(a: T, b: T): number; | ||
/** | ||
* Exports the tree's contents as a 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 `maxEntries` option from the constructor must be the same | ||
* in both trees for export/import to work properly. | ||
*/ | ||
fromJSON(data: any): RBush<T>; | ||
} | ||
toJSON(): any; | ||
interface IRBush { | ||
/** | ||
* Create a spatial index. | ||
* Imports previously exported data into the tree (i.e., data that was | ||
* emitted by `toJSON()`). | ||
* | ||
* 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. | ||
* 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 `maxEntries` option from the constructor must be the same | ||
* in both trees for export/import to work properly. | ||
* | ||
* @param data The previously exported JSON data. | ||
*/ | ||
<T extends BBox>(nodeSize?: number): RBush<T>; | ||
<T>(nodeSize: number, formatter: string[]): RBush<T>; | ||
} | ||
fromJSON(data: any): RBush<T>; | ||
} | ||
declare module 'rbush' { | ||
const temp: rbush.IRBush; | ||
export = temp; | ||
} |
{ | ||
"name": "@types/rbush", | ||
"version": "2.0.2", | ||
"description": "TypeScript definitions for rbush 2.0.1", | ||
"version": "3.0.0", | ||
"description": "TypeScript definitions for rbush", | ||
"license": "MIT", | ||
"author": "Dan Vanderkam <http://danvk.org/>", | ||
"contributors": [ | ||
{ | ||
"name": "Dan Vanderkam", | ||
"url": "https://github.com/danvk", | ||
"githubUsername": "danvk" | ||
}, | ||
{ | ||
"name": "Chris Lewis", | ||
"url": "https://github.com/cmslewis", | ||
"githubUsername": "cmslewis" | ||
} | ||
], | ||
"main": "", | ||
"types": "index", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" | ||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", | ||
"directory": "types/rbush" | ||
}, | ||
"scripts": {}, | ||
"dependencies": {}, | ||
"peerDependencies": {}, | ||
"typings": "index.d.ts", | ||
"typesPublisherContentHash": "2e2a5a9c677aa7c4e518a6d7232e46139c7ef29ba1705aa5e2e6d06080f0b400" | ||
"typesPublisherContentHash": "bd38a553e5a91615f0b95f48cf305f78333cbd185f590191e6c5476e25f3c0db", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -5,15 +5,13 @@ # Installation | ||
# Summary | ||
This package contains type definitions for rbush 2.0.1 (https://github.com/mourner/rbush). | ||
This package contains type definitions for rbush (https://github.com/mourner/rbush). | ||
# Details | ||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/rbush | ||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/rbush | ||
Additional Details | ||
* Last updated: Wed, 05 Oct 2016 20:53:38 GMT | ||
* File structure: OldUMD | ||
* Library Dependencies: none | ||
* Module Dependencies: none | ||
* Last updated: Thu, 24 Oct 2019 18:11:37 GMT | ||
* Dependencies: none | ||
* Global values: none | ||
# Credits | ||
These definitions were written by Dan Vanderkam <http://danvk.org/>. | ||
These definitions were written by Dan Vanderkam <https://github.com/danvk>, and Chris Lewis <https://github.com/cmslewis>. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9406
176
17