You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds support for SharedArrayBuffer which is a fully compatible alternative to ArrayBuffer. The implementation follows the style used for the PR that added SharedArrayBuffer support in flatbush.
Copy file name to clipboardExpand all lines: README.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,12 +68,14 @@ Alternatively, there's a browser bundle with a `KDBush` global variable:
68
68
69
69
## API
70
70
71
-
#### new KDBush(numItems[, nodeSize, ArrayType])
71
+
#### new KDBush(numItems[, nodeSize, ArrayType, ArrayBufferType])
72
72
73
73
Creates an index that will hold a given number of points (`numItems`). Additionally accepts:
74
74
75
75
-`nodeSize`: Size of the KD-tree node, `64` by default. Higher means faster indexing but slower search, and vise versa.
76
76
-`ArrayType`: Array type to use for storing coordinate values. `Float64Array` by default, but if your coordinates are integer values, `Int32Array` makes the index faster and smaller.
77
+
-`ArrayBufferType`: the array buffer type used to store data (`ArrayBuffer` by default);
78
+
you may prefer `SharedArrayBuffer` if you want to share the index between threads (multiple `Worker`, `SharedWorker` or `ServiceWorker`).
77
79
78
80
#### index.add(x, y)
79
81
@@ -89,7 +91,7 @@ Finds all items within a given radius from the query point and returns an array
89
91
90
92
#### `KDBush.from(data)`
91
93
92
-
Recreates a KDBush index from raw `ArrayBuffer` data
94
+
Recreates a KDBush index from raw `ArrayBuffer`or `SharedArrayBuffer`data
93
95
(that's exposed as `index.data` on a previously indexed KDBush instance).
94
96
Very useful for transferring or sharing indices between threads or storing them in a file.
0 commit comments