@osmix/core 0.1.2 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/entities.d.ts +1 -1
- package/dist/entities.d.ts.map +1 -1
- package/dist/ids.d.ts +1 -1
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +1 -2
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/nodes.d.ts +1 -1
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js.map +1 -1
- package/dist/osm.d.ts.map +1 -1
- package/dist/osm.js +1 -1
- package/dist/osm.js.map +1 -1
- package/dist/relations.d.ts +1 -1
- package/dist/relations.d.ts.map +1 -1
- package/dist/relations.js +1 -1
- package/dist/relations.js.map +1 -1
- package/dist/stringtable.d.ts +1 -1
- package/dist/stringtable.d.ts.map +1 -1
- package/dist/stringtable.js.map +1 -1
- package/dist/tags.d.ts +1 -1
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js.map +1 -1
- package/dist/typed-arrays.d.ts +2 -2
- package/dist/ways.d.ts +1 -1
- package/dist/ways.d.ts.map +1 -1
- package/dist/ways.js +0 -7
- package/dist/ways.js.map +1 -1
- package/package.json +3 -3
- package/src/entities.ts +1 -1
- package/src/ids.ts +2 -3
- package/src/index.ts +0 -1
- package/src/nodes.ts +1 -1
- package/src/osm.ts +1 -1
- package/src/relations.ts +2 -1
- package/src/stringtable.ts +1 -1
- package/src/tags.ts +1 -1
- package/src/ways.ts +1 -8
- package/dist/src/entities.d.ts +0 -120
- package/dist/src/entities.d.ts.map +0 -1
- package/dist/src/entities.js +0 -159
- package/dist/src/entities.js.map +0 -1
- package/dist/src/ids.d.ts +0 -119
- package/dist/src/ids.d.ts.map +0 -1
- package/dist/src/ids.js +0 -243
- package/dist/src/ids.js.map +0 -1
- package/dist/src/index.d.ts +0 -32
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -35
- package/dist/src/index.js.map +0 -1
- package/dist/src/nodes.d.ts +0 -106
- package/dist/src/nodes.d.ts.map +0 -1
- package/dist/src/nodes.js +0 -318
- package/dist/src/nodes.js.map +0 -1
- package/dist/src/osm.d.ts +0 -99
- package/dist/src/osm.d.ts.map +0 -1
- package/dist/src/osm.js +0 -165
- package/dist/src/osm.js.map +0 -1
- package/dist/src/relations.d.ts +0 -123
- package/dist/src/relations.d.ts.map +0 -1
- package/dist/src/relations.js +0 -424
- package/dist/src/relations.js.map +0 -1
- package/dist/src/stringtable.d.ts +0 -101
- package/dist/src/stringtable.d.ts.map +0 -1
- package/dist/src/stringtable.js +0 -180
- package/dist/src/stringtable.js.map +0 -1
- package/dist/src/tags.d.ts +0 -132
- package/dist/src/tags.d.ts.map +0 -1
- package/dist/src/tags.js +0 -239
- package/dist/src/tags.js.map +0 -1
- package/dist/src/typed-arrays.d.ts +0 -124
- package/dist/src/typed-arrays.d.ts.map +0 -1
- package/dist/src/typed-arrays.js +0 -198
- package/dist/src/typed-arrays.js.map +0 -1
- package/dist/src/utils.d.ts +0 -38
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -87
- package/dist/src/utils.js.map +0 -1
- package/dist/src/ways.d.ts +0 -106
- package/dist/src/ways.d.ts.map +0 -1
- package/dist/src/ways.js +0 -346
- package/dist/src/ways.js.map +0 -1
- package/dist/test/memory.test.d.ts +0 -7
- package/dist/test/memory.test.d.ts.map +0 -1
- package/dist/test/memory.test.js +0 -29
- package/dist/test/memory.test.js.map +0 -1
- package/dist/test/mock-osm.d.ts +0 -13
- package/dist/test/mock-osm.d.ts.map +0 -1
- package/dist/test/mock-osm.js +0 -122
- package/dist/test/mock-osm.js.map +0 -1
- package/dist/test/tags-search.test.d.ts +0 -2
- package/dist/test/tags-search.test.d.ts.map +0 -1
- package/dist/test/tags-search.test.js +0 -56
- package/dist/test/tags-search.test.js.map +0 -1
- package/dist/test/typed-arrays.test.d.ts +0 -2
- package/dist/test/typed-arrays.test.d.ts.map +0 -1
- package/dist/test/typed-arrays.test.js +0 -102
- package/dist/test/typed-arrays.test.js.map +0 -1
- package/dist/utils.d.ts +0 -38
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -87
- package/dist/utils.js.map +0 -1
- package/src/utils.ts +0 -95
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { BufferConstructor, ResizeableTypedArray } from "../src/typed-arrays";
|
|
3
|
-
describe("typed array helpers", () => {
|
|
4
|
-
it("selects the appropriate buffer constructor", () => {
|
|
5
|
-
if (typeof SharedArrayBuffer !== "undefined") {
|
|
6
|
-
expect(BufferConstructor).toBe(SharedArrayBuffer);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
expect(BufferConstructor).toBe(ArrayBuffer);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
describe("ResizeableTypedArray", () => {
|
|
13
|
-
it("push stores values and returns the index", () => {
|
|
14
|
-
const arr = new ResizeableTypedArray(Float64Array);
|
|
15
|
-
const first = arr.push(1.5);
|
|
16
|
-
const second = arr.push(2.5);
|
|
17
|
-
expect(first).toBe(0);
|
|
18
|
-
expect(second).toBe(1);
|
|
19
|
-
expect(arr.length).toBe(2);
|
|
20
|
-
expect(arr.at(0)).toBe(1.5);
|
|
21
|
-
expect(arr.at(1)).toBe(2.5);
|
|
22
|
-
});
|
|
23
|
-
it("should push many values", () => {
|
|
24
|
-
const arr = new ResizeableTypedArray(Float64Array);
|
|
25
|
-
arr.pushMany([1.5, 2.5]);
|
|
26
|
-
expect(arr.length).toBe(2);
|
|
27
|
-
expect(arr.at(0)).toBe(1.5);
|
|
28
|
-
expect(arr.at(1)).toBe(2.5);
|
|
29
|
-
});
|
|
30
|
-
it("at supports negative indices and guards bounds", () => {
|
|
31
|
-
const arr = new ResizeableTypedArray(Int16Array);
|
|
32
|
-
arr.pushMany([10, 20, 30]);
|
|
33
|
-
expect(arr.length).toBe(3);
|
|
34
|
-
expect(Array.from(arr.slice(0, arr.length))).toEqual([10, 20, 30]);
|
|
35
|
-
expect(arr.at(-1)).toBe(30);
|
|
36
|
-
expect(arr.at(-3)).toBe(10);
|
|
37
|
-
expect(() => arr.at(-4)).toThrow(/Index out of bounds/);
|
|
38
|
-
expect(() => arr.at(3)).toThrow(/Index out of bounds/);
|
|
39
|
-
});
|
|
40
|
-
it("pushMany appends arrays while preserving order", () => {
|
|
41
|
-
const arr = new ResizeableTypedArray(Uint32Array);
|
|
42
|
-
arr.pushMany([1, 2, 3]);
|
|
43
|
-
arr.pushMany(Uint32Array.from([4, 5]));
|
|
44
|
-
expect(arr.length).toBe(5);
|
|
45
|
-
expect(Array.from(arr.slice(0, arr.length))).toEqual([1, 2, 3, 4, 5]);
|
|
46
|
-
});
|
|
47
|
-
it("slice returns a copy of the requested segment", () => {
|
|
48
|
-
const arr = new ResizeableTypedArray(Uint8Array);
|
|
49
|
-
arr.pushMany([1, 2, 3, 4]);
|
|
50
|
-
const segment = arr.slice(1, 3);
|
|
51
|
-
expect(segment).toBeInstanceOf(Uint8Array);
|
|
52
|
-
expect(Array.from(segment)).toEqual([2, 3]);
|
|
53
|
-
segment[0] = 99;
|
|
54
|
-
expect(arr.at(1)).toBe(2);
|
|
55
|
-
});
|
|
56
|
-
it("compact trims unused capacity", () => {
|
|
57
|
-
const arr = new ResizeableTypedArray(Float64Array);
|
|
58
|
-
arr.pushMany([5, 6, 7]);
|
|
59
|
-
const previousCapacity = arr.array.length;
|
|
60
|
-
const compacted = arr.compact();
|
|
61
|
-
const expectedByteLength = arr.length * Float64Array.BYTES_PER_ELEMENT;
|
|
62
|
-
expect(compacted).toBe(arr.array);
|
|
63
|
-
expect(compacted.length).toBe(arr.length);
|
|
64
|
-
expect(compacted.length).toBeLessThan(previousCapacity);
|
|
65
|
-
expect(arr.array.buffer.byteLength).toBe(expectedByteLength);
|
|
66
|
-
});
|
|
67
|
-
it("from reuses an existing buffer and grows when needed", () => {
|
|
68
|
-
const backing = new ArrayBuffer(16);
|
|
69
|
-
new Uint32Array(backing).set([1, 2, 3, 4]);
|
|
70
|
-
const arr = ResizeableTypedArray.from(Uint32Array, backing);
|
|
71
|
-
arr.bufferSize = arr.buffer.byteLength;
|
|
72
|
-
arr.maxByteLength = Math.max(arr.maxByteLength, arr.bufferSize * 2);
|
|
73
|
-
arr.items = arr.array.length;
|
|
74
|
-
expect(arr.length).toBe(4);
|
|
75
|
-
expect(Array.from(arr.slice(0, arr.length))).toEqual([1, 2, 3, 4]);
|
|
76
|
-
arr.push(5);
|
|
77
|
-
expect(arr.length).toBe(5);
|
|
78
|
-
expect(arr.array.length).toBe(8);
|
|
79
|
-
expect(Array.from(arr.slice(0, arr.length))).toEqual([1, 2, 3, 4, 5]);
|
|
80
|
-
});
|
|
81
|
-
if (typeof SharedArrayBuffer !== "undefined") {
|
|
82
|
-
it("grows shared buffers in place", () => {
|
|
83
|
-
const backing = new SharedArrayBuffer(8, {
|
|
84
|
-
maxByteLength: 32,
|
|
85
|
-
});
|
|
86
|
-
const seed = new Uint8Array(backing);
|
|
87
|
-
seed.set([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
88
|
-
const arr = ResizeableTypedArray.from(Uint8Array, backing);
|
|
89
|
-
arr.bufferSize = arr.buffer.byteLength;
|
|
90
|
-
arr.maxByteLength = backing.maxByteLength;
|
|
91
|
-
arr.items = arr.array.length;
|
|
92
|
-
const originalBuffer = arr.buffer;
|
|
93
|
-
arr.push(9);
|
|
94
|
-
expect(arr.buffer).toBe(originalBuffer);
|
|
95
|
-
expect(arr.array.length).toBe(16);
|
|
96
|
-
expect(arr.buffer.byteLength).toBe(16);
|
|
97
|
-
expect(Array.from(arr.slice(0, 9))).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
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AC,CAAA;QACH,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for @osmix/core.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import type { GeoBbox2D, LonLat } from "@osmix/shared/types";
|
|
6
|
-
/**
|
|
7
|
-
* Compute the bounding box of a set of coordinates.
|
|
8
|
-
* Returns `[minLon, minLat, maxLon, maxLat]`.
|
|
9
|
-
*/
|
|
10
|
-
export declare function bboxFromLonLats(lonLats: LonLat[]): GeoBbox2D;
|
|
11
|
-
/**
|
|
12
|
-
* Hash state that can be incrementally updated with multiple buffers.
|
|
13
|
-
*/
|
|
14
|
-
export declare class ContentHasher {
|
|
15
|
-
private hash;
|
|
16
|
-
/**
|
|
17
|
-
* Update the hash with a typed array's underlying bytes.
|
|
18
|
-
*/
|
|
19
|
-
update(data: ArrayBufferView | ArrayBuffer): this;
|
|
20
|
-
/**
|
|
21
|
-
* Update the hash with a number (as 8 bytes).
|
|
22
|
-
*/
|
|
23
|
-
updateNumber(n: number): this;
|
|
24
|
-
/**
|
|
25
|
-
* Get the final hash as a hex string.
|
|
26
|
-
*/
|
|
27
|
-
digest(): string;
|
|
28
|
-
/**
|
|
29
|
-
* Get the raw hash value.
|
|
30
|
-
*/
|
|
31
|
-
digestNumber(): number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Create a content hash from multiple typed arrays.
|
|
35
|
-
* Returns a hex string suitable for use as a content identifier.
|
|
36
|
-
*/
|
|
37
|
-
export declare function hashBuffers(...buffers: (ArrayBufferView | ArrayBuffer)[]): string;
|
|
38
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5D;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAY5D;AAmBD;;GAEG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAE/B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;IAOjD;;OAEG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAM7B;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,YAAY,IAAI,MAAM;CAGtB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,GAAG,OAAO,EAAE,CAAC,eAAe,GAAG,WAAW,CAAC,EAAE,GAC3C,MAAM,CAMR"}
|
package/dist/utils.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for @osmix/core.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Compute the bounding box of a set of coordinates.
|
|
7
|
-
* Returns `[minLon, minLat, maxLon, maxLat]`.
|
|
8
|
-
*/
|
|
9
|
-
export function bboxFromLonLats(lonLats) {
|
|
10
|
-
let minLon = Number.POSITIVE_INFINITY;
|
|
11
|
-
let minLat = Number.POSITIVE_INFINITY;
|
|
12
|
-
let maxLon = Number.NEGATIVE_INFINITY;
|
|
13
|
-
let maxLat = Number.NEGATIVE_INFINITY;
|
|
14
|
-
for (const [lon, lat] of lonLats) {
|
|
15
|
-
if (lon < minLon)
|
|
16
|
-
minLon = lon;
|
|
17
|
-
if (lat < minLat)
|
|
18
|
-
minLat = lat;
|
|
19
|
-
if (lon > maxLon)
|
|
20
|
-
maxLon = lon;
|
|
21
|
-
if (lat > maxLat)
|
|
22
|
-
maxLat = lat;
|
|
23
|
-
}
|
|
24
|
-
return [minLon, minLat, maxLon, maxLat];
|
|
25
|
-
}
|
|
26
|
-
// FNV-1a hash constants (32-bit)
|
|
27
|
-
const FNV_OFFSET_BASIS = 2166136261;
|
|
28
|
-
const FNV_PRIME = 16777619;
|
|
29
|
-
/**
|
|
30
|
-
* FNV-1a hash implementation for Uint8Array.
|
|
31
|
-
* Fast, non-cryptographic hash suitable for content comparison.
|
|
32
|
-
*/
|
|
33
|
-
function fnv1aHash(data, initialHash = FNV_OFFSET_BASIS) {
|
|
34
|
-
let hash = initialHash;
|
|
35
|
-
for (let i = 0; i < data.length; i++) {
|
|
36
|
-
hash ^= data[i];
|
|
37
|
-
hash = Math.imul(hash, FNV_PRIME) >>> 0;
|
|
38
|
-
}
|
|
39
|
-
return hash >>> 0;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Hash state that can be incrementally updated with multiple buffers.
|
|
43
|
-
*/
|
|
44
|
-
export class ContentHasher {
|
|
45
|
-
hash = FNV_OFFSET_BASIS;
|
|
46
|
-
/**
|
|
47
|
-
* Update the hash with a typed array's underlying bytes.
|
|
48
|
-
*/
|
|
49
|
-
update(data) {
|
|
50
|
-
const buffer = data instanceof ArrayBuffer ? data : data.buffer;
|
|
51
|
-
const bytes = new Uint8Array(buffer);
|
|
52
|
-
this.hash = fnv1aHash(bytes, this.hash);
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Update the hash with a number (as 8 bytes).
|
|
57
|
-
*/
|
|
58
|
-
updateNumber(n) {
|
|
59
|
-
const buffer = new ArrayBuffer(8);
|
|
60
|
-
new Float64Array(buffer)[0] = n;
|
|
61
|
-
return this.update(buffer);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Get the final hash as a hex string.
|
|
65
|
-
*/
|
|
66
|
-
digest() {
|
|
67
|
-
return this.hash.toString(16).padStart(8, "0");
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Get the raw hash value.
|
|
71
|
-
*/
|
|
72
|
-
digestNumber() {
|
|
73
|
-
return this.hash;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Create a content hash from multiple typed arrays.
|
|
78
|
-
* Returns a hex string suitable for use as a content identifier.
|
|
79
|
-
*/
|
|
80
|
-
export function hashBuffers(...buffers) {
|
|
81
|
-
const hasher = new ContentHasher();
|
|
82
|
-
for (const buffer of buffers) {
|
|
83
|
-
hasher.update(buffer);
|
|
84
|
-
}
|
|
85
|
-
return hasher.digest();
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAiB;IAChD,IAAI,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAA;IACrC,IAAI,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAA;IACrC,IAAI,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAA;IACrC,IAAI,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAA;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC;QAClC,IAAI,GAAG,GAAG,MAAM;YAAE,MAAM,GAAG,GAAG,CAAA;QAC9B,IAAI,GAAG,GAAG,MAAM;YAAE,MAAM,GAAG,GAAG,CAAA;QAC9B,IAAI,GAAG,GAAG,MAAM;YAAE,MAAM,GAAG,GAAG,CAAA;QAC9B,IAAI,GAAG,GAAG,MAAM;YAAE,MAAM,GAAG,GAAG,CAAA;IAC/B,CAAC;IACD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AACxC,CAAC;AAED,iCAAiC;AACjC,MAAM,gBAAgB,GAAG,UAAU,CAAA;AACnC,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;QACX,OAAO,IAAI,CAAC,IAAI,CAAA;IACjB,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAC1B,GAAG,OAA0C;IAE7C,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAA;IAClC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,EAAE,CAAA;AACvB,CAAC"}
|
package/src/utils.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for @osmix/core.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { GeoBbox2D, LonLat } from "@osmix/shared/types"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Compute the bounding box of a set of coordinates.
|
|
10
|
-
* Returns `[minLon, minLat, maxLon, maxLat]`.
|
|
11
|
-
*/
|
|
12
|
-
export function bboxFromLonLats(lonLats: LonLat[]): GeoBbox2D {
|
|
13
|
-
let minLon = Number.POSITIVE_INFINITY
|
|
14
|
-
let minLat = Number.POSITIVE_INFINITY
|
|
15
|
-
let maxLon = Number.NEGATIVE_INFINITY
|
|
16
|
-
let maxLat = Number.NEGATIVE_INFINITY
|
|
17
|
-
for (const [lon, lat] of lonLats) {
|
|
18
|
-
if (lon < minLon) minLon = lon
|
|
19
|
-
if (lat < minLat) minLat = lat
|
|
20
|
-
if (lon > maxLon) maxLon = lon
|
|
21
|
-
if (lat > maxLat) maxLat = lat
|
|
22
|
-
}
|
|
23
|
-
return [minLon, minLat, maxLon, maxLat]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// FNV-1a hash constants (32-bit)
|
|
27
|
-
const FNV_OFFSET_BASIS = 2166136261
|
|
28
|
-
const FNV_PRIME = 16777619
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* FNV-1a hash implementation for Uint8Array.
|
|
32
|
-
* Fast, non-cryptographic hash suitable for content comparison.
|
|
33
|
-
*/
|
|
34
|
-
function fnv1aHash(data: Uint8Array, initialHash = FNV_OFFSET_BASIS): number {
|
|
35
|
-
let hash = initialHash
|
|
36
|
-
for (let i = 0; i < data.length; i++) {
|
|
37
|
-
hash ^= data[i] as number
|
|
38
|
-
hash = Math.imul(hash, FNV_PRIME) >>> 0
|
|
39
|
-
}
|
|
40
|
-
return hash >>> 0
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Hash state that can be incrementally updated with multiple buffers.
|
|
45
|
-
*/
|
|
46
|
-
export class ContentHasher {
|
|
47
|
-
private hash = FNV_OFFSET_BASIS
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Update the hash with a typed array's underlying bytes.
|
|
51
|
-
*/
|
|
52
|
-
update(data: ArrayBufferView | ArrayBuffer): this {
|
|
53
|
-
const buffer = data instanceof ArrayBuffer ? data : data.buffer
|
|
54
|
-
const bytes = new Uint8Array(buffer)
|
|
55
|
-
this.hash = fnv1aHash(bytes, this.hash)
|
|
56
|
-
return this
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Update the hash with a number (as 8 bytes).
|
|
61
|
-
*/
|
|
62
|
-
updateNumber(n: number): this {
|
|
63
|
-
const buffer = new ArrayBuffer(8)
|
|
64
|
-
new Float64Array(buffer)[0] = n
|
|
65
|
-
return this.update(buffer)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get the final hash as a hex string.
|
|
70
|
-
*/
|
|
71
|
-
digest(): string {
|
|
72
|
-
return this.hash.toString(16).padStart(8, "0")
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Get the raw hash value.
|
|
77
|
-
*/
|
|
78
|
-
digestNumber(): number {
|
|
79
|
-
return this.hash
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Create a content hash from multiple typed arrays.
|
|
85
|
-
* Returns a hex string suitable for use as a content identifier.
|
|
86
|
-
*/
|
|
87
|
-
export function hashBuffers(
|
|
88
|
-
...buffers: (ArrayBufferView | ArrayBuffer)[]
|
|
89
|
-
): string {
|
|
90
|
-
const hasher = new ContentHasher()
|
|
91
|
-
for (const buffer of buffers) {
|
|
92
|
-
hasher.update(buffer)
|
|
93
|
-
}
|
|
94
|
-
return hasher.digest()
|
|
95
|
-
}
|