distillate 0.6.0 → 0.8.0

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.
@@ -0,0 +1,73 @@
1
+ //#region src/core/bytes.d.ts
2
+ type BytesLike = string | Uint8Array | ArrayBuffer;
3
+ //#endregion
4
+ //#region src/core/serialize.d.ts
5
+ /**
6
+ * Base class for every defect `fromBytes` and `fromJSON` reject. Thrown
7
+ * directly when a JSON envelope is malformed: not an object, missing the
8
+ * `"distillate"` tag, missing `data`, or `data` that is not valid base64.
9
+ * Catch this to handle any decode failure at once, or a subclass to tell the
10
+ * causes apart. The input is corrupt or foreign, so discard it; retrying the
11
+ * same bytes cannot succeed.
12
+ */
13
+ declare class SerializationError extends Error {
14
+ /** Discriminates this error from other `Error`s. */
15
+ override readonly name: string;
16
+ }
17
+ /**
18
+ * Thrown when a frame is shorter than its header plus trailer, or when its
19
+ * body length does not match the length its declared params imply. The bytes
20
+ * were cut short in transit or storage; re-fetch the whole frame.
21
+ */
22
+ declare class TruncatedError extends SerializationError {
23
+ /** Discriminates this error from other `Error`s. */
24
+ override readonly name = "TruncatedError";
25
+ }
26
+ /**
27
+ * Thrown when a frame does not start with the four-byte `AMQF` magic, so it
28
+ * was never produced by `toBytes`. Check that the bytes really are a
29
+ * distillate frame and not another payload, a text encoding of one, or a
30
+ * slice taken at the wrong offset.
31
+ */
32
+ declare class BadMagicError extends SerializationError {
33
+ /** Discriminates this error from other `Error`s. */
34
+ override readonly name = "BadMagicError";
35
+ }
36
+ /**
37
+ * Thrown when a frame or JSON envelope declares a format version this release
38
+ * does not read. A reader must be at least as new as the producer, so upgrade
39
+ * `distillate` or re-serialize the data with the version you run.
40
+ */
41
+ declare class UnknownVersionError extends SerializationError {
42
+ /** Discriminates this error from other `Error`s. */
43
+ override readonly name = "UnknownVersionError";
44
+ }
45
+ /**
46
+ * Thrown when a frame's flags nibble names a hash this release cannot
47
+ * reproduce, so its stored bits are unreadable. Rebuild the filter from the
48
+ * source keys with the version you run.
49
+ */
50
+ declare class UnknownHashVariantError extends SerializationError {
51
+ /** Discriminates this error from other `Error`s. */
52
+ override readonly name = "UnknownHashVariantError";
53
+ }
54
+ /**
55
+ * Thrown when a frame's CRC32 trailer does not match its contents, so the
56
+ * bytes were corrupted after they were written. Discard them and re-fetch;
57
+ * the payload cannot be trusted even where it still parses.
58
+ */
59
+ declare class ChecksumError extends SerializationError {
60
+ /** Discriminates this error from other `Error`s. */
61
+ override readonly name = "ChecksumError";
62
+ }
63
+ /** JSON-friendly envelope for a filter: the binary frame, base64-encoded. */
64
+ interface FilterJSON {
65
+ /** Format tag; always `"distillate"`. */
66
+ $: string;
67
+ /** Binary format version. */
68
+ v: number;
69
+ /** Base64 of the `toBytes` frame. */
70
+ data: string;
71
+ }
72
+ //#endregion
73
+ export { TruncatedError as a, BytesLike as c, SerializationError as i, ChecksumError as n, UnknownHashVariantError as o, FilterJSON as r, UnknownVersionError as s, BadMagicError as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "distillate",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Probabilistic data structures for JavaScript. Space-efficient, approximate-membership filters (Bloom, Blocked Bloom, Binary Fuse) with tunable error and a portable binary format; zero dependencies, universal.",
5
5
  "keywords": [
6
6
  "bloom-filter",
@@ -66,15 +66,14 @@
66
66
  "devDependencies": {
67
67
  "@arethetypeswrong/cli": "^0.18.5",
68
68
  "@microsoft/api-extractor": "^7.58.12",
69
- "@types/node": "^26.1.2",
69
+ "@types/node": "^22.0.0",
70
70
  "@vitest/coverage-v8": "^4.1.10",
71
71
  "fast-check": "^4.9.0",
72
72
  "mitata": "^1.0.34",
73
- "publint": "^0.3.22",
73
+ "publint": "^0.3.23",
74
74
  "tsdown": "^0.22.14",
75
- "tsx": "^4.23.1",
75
+ "tsx": "^4.23.12",
76
76
  "typedoc": "^0.28.20",
77
- "typedoc-plugin-markdown": "^4.12.0",
78
77
  "typescript": "^5.9.3",
79
78
  "vitest": "^4.1.10"
80
79
  },
@@ -90,7 +89,7 @@
90
89
  "coverage": "vitest run --coverage",
91
90
  "api:report": "node scripts/api-extractor.mjs --local",
92
91
  "api:check": "node scripts/api-extractor.mjs",
93
- "docs:api": "typedoc",
92
+ "docs:check": "typedoc --emit none",
94
93
  "golden:gen": "tsx scripts/gen-golden.ts",
95
94
  "size:check": "node scripts/size-check.mjs",
96
95
  "bench": "tsx bench/core.bench.ts && tsx bench/bloom.bench.ts && tsx bench/blocked.bench.ts && tsx bench/fuse.bench.ts && tsx bench/accuracy.bench.ts",
@@ -1,15 +0,0 @@
1
- //#region src/core/bytes.d.ts
2
- type BytesLike = string | Uint8Array | ArrayBuffer;
3
- //#endregion
4
- //#region src/core/serialize.d.ts
5
- /** JSON-friendly envelope for a filter: the binary frame, base64-encoded. */
6
- interface FilterJSON {
7
- /** Format tag; always `"distillate"`. */
8
- $: string;
9
- /** Binary format version. */
10
- v: number;
11
- /** Base64 of the `toBytes` frame. */
12
- data: string;
13
- }
14
- //#endregion
15
- export { BytesLike as n, FilterJSON as t };
@@ -1,15 +0,0 @@
1
- //#region src/core/bytes.d.ts
2
- type BytesLike = string | Uint8Array | ArrayBuffer;
3
- //#endregion
4
- //#region src/core/serialize.d.ts
5
- /** JSON-friendly envelope for a filter: the binary frame, base64-encoded. */
6
- interface FilterJSON {
7
- /** Format tag; always `"distillate"`. */
8
- $: string;
9
- /** Binary format version. */
10
- v: number;
11
- /** Base64 of the `toBytes` frame. */
12
- data: string;
13
- }
14
- //#endregion
15
- export { BytesLike as n, FilterJSON as t };