Skip to content

Commit 3a6f0f0

Browse files
committed
upgrade dev deps, close #58
1 parent a737e6e commit 3a6f0f0

File tree

3 files changed

+145
-138
lines changed

3 files changed

+145
-138
lines changed

index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class Flatbush {
99

1010
/**
1111
* Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
12-
* @param {ArrayBuffer | SharedArrayBuffer} data
12+
* @param {ArrayBufferLike} data
1313
* @param {number} [byteOffset=0] byte offset to the start of the Flatbush buffer in the referenced ArrayBuffer.
1414
* @returns {Flatbush} index
1515
*/
@@ -47,7 +47,7 @@ export default class Flatbush {
4747
* @param {number} [nodeSize=16] Size of the tree node (16 by default).
4848
* @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
4949
* @param {ArrayBufferConstructor | SharedArrayBufferConstructor} [ArrayBufferType=ArrayBuffer] The array buffer type used to store data (`ArrayBuffer` by default).
50-
* @param {ArrayBuffer | SharedArrayBuffer} [data] (Only used internally)
50+
* @param {ArrayBufferLike} [data] (Only used internally)
5151
* @param {number} [byteOffset=0] (Only used internally)
5252
*/
5353
constructor(numItems, nodeSize = 16, ArrayType = Float64Array, ArrayBufferType = ArrayBuffer, data, byteOffset = 0) {
@@ -81,9 +81,7 @@ export default class Flatbush {
8181

8282
if (data) {
8383
this.data = data;
84-
// @ts-expect-error TS can't figure out the constructor from the complex union type
8584
this._boxes = new ArrayType(data, byteOffset + 8, numNodes * 4);
86-
// @ts-expect-error
8785
this._indices = new this.IndexArrayType(data, byteOffset + 8 + nodesByteSize, numNodes);
8886

8987
this._pos = numNodes * 4;
@@ -93,20 +91,18 @@ export default class Flatbush {
9391
this.maxY = this._boxes[this._pos - 1];
9492

9593
} else {
96-
this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT);
97-
// @ts-expect-error
98-
this._boxes = new ArrayType(this.data, 8, numNodes * 4);
99-
// @ts-expect-error
100-
this._indices = new this.IndexArrayType(this.data, 8 + nodesByteSize, numNodes);
94+
const data = this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT);
95+
this._boxes = new ArrayType(data, 8, numNodes * 4);
96+
this._indices = new this.IndexArrayType(data, 8 + nodesByteSize, numNodes);
10197
this._pos = 0;
10298
this.minX = Infinity;
10399
this.minY = Infinity;
104100
this.maxX = -Infinity;
105101
this.maxY = -Infinity;
106102

107-
new Uint8Array(this.data, 0, 2).set([0xfb, (VERSION << 4) + arrayTypeIndex]);
108-
new Uint16Array(this.data, 2, 1)[0] = nodeSize;
109-
new Uint32Array(this.data, 4, 1)[0] = numItems;
103+
new Uint8Array(data, 0, 2).set([0xfb, (VERSION << 4) + arrayTypeIndex]);
104+
new Uint16Array(data, 2, 1)[0] = nodeSize;
105+
new Uint32Array(data, 4, 1)[0] = numItems;
110106
}
111107

112108
// a priority queue for k-nearest-neighbors queries

0 commit comments

Comments
 (0)