distillate 0.2.0 → 0.3.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.
- package/dist/blocked/index.cjs +20 -0
- package/dist/blocked/index.d.cts +11 -0
- package/dist/blocked/index.d.ts +11 -0
- package/dist/blocked/index.js +20 -0
- package/dist/bloom/index.cjs +26 -0
- package/dist/bloom/index.d.cts +16 -0
- package/dist/bloom/index.d.ts +16 -0
- package/dist/bloom/index.js +26 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/blocked/index.cjs
CHANGED
|
@@ -77,6 +77,26 @@ var BlockedBloomFilter = class BlockedBloomFilter {
|
|
|
77
77
|
get bitsPerKey() {
|
|
78
78
|
return this.#numBlocks * 256 / this.#n;
|
|
79
79
|
}
|
|
80
|
+
/** Number of bits currently set across all lanes. */
|
|
81
|
+
get length() {
|
|
82
|
+
let bits = 0;
|
|
83
|
+
for (let w of this.#lanes) while (w) {
|
|
84
|
+
w &= w - 1;
|
|
85
|
+
bits++;
|
|
86
|
+
}
|
|
87
|
+
return bits;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
91
|
+
* `(length / totalBits) ** 8`. A split-block query checks exactly 8 lane-bits,
|
|
92
|
+
* so the exponent is 8 rather than a classic probe count `k`. This reflects
|
|
93
|
+
* how full the filter is right now, not the design target.
|
|
94
|
+
*
|
|
95
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
96
|
+
*/
|
|
97
|
+
rate() {
|
|
98
|
+
return (this.length / (this.#numBlocks * 256)) ** 8;
|
|
99
|
+
}
|
|
80
100
|
/**
|
|
81
101
|
* Restores a filter from its {@link BlockedBloomFilter.toBytes} serialization.
|
|
82
102
|
*
|
package/dist/blocked/index.d.cts
CHANGED
|
@@ -43,6 +43,17 @@ declare class BlockedBloomFilter {
|
|
|
43
43
|
constructor({ bitsPerKey, capacity, seed }: BlockedBloomParams);
|
|
44
44
|
/** Actual bits allocated per key (`total bits / capacity`). */
|
|
45
45
|
get bitsPerKey(): number;
|
|
46
|
+
/** Number of bits currently set across all lanes. */
|
|
47
|
+
get length(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
50
|
+
* `(length / totalBits) ** 8`. A split-block query checks exactly 8 lane-bits,
|
|
51
|
+
* so the exponent is 8 rather than a classic probe count `k`. This reflects
|
|
52
|
+
* how full the filter is right now, not the design target.
|
|
53
|
+
*
|
|
54
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
55
|
+
*/
|
|
56
|
+
rate(): number;
|
|
46
57
|
/**
|
|
47
58
|
* Restores a filter from its {@link BlockedBloomFilter.toBytes} serialization.
|
|
48
59
|
*
|
package/dist/blocked/index.d.ts
CHANGED
|
@@ -43,6 +43,17 @@ declare class BlockedBloomFilter {
|
|
|
43
43
|
constructor({ bitsPerKey, capacity, seed }: BlockedBloomParams);
|
|
44
44
|
/** Actual bits allocated per key (`total bits / capacity`). */
|
|
45
45
|
get bitsPerKey(): number;
|
|
46
|
+
/** Number of bits currently set across all lanes. */
|
|
47
|
+
get length(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
50
|
+
* `(length / totalBits) ** 8`. A split-block query checks exactly 8 lane-bits,
|
|
51
|
+
* so the exponent is 8 rather than a classic probe count `k`. This reflects
|
|
52
|
+
* how full the filter is right now, not the design target.
|
|
53
|
+
*
|
|
54
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
55
|
+
*/
|
|
56
|
+
rate(): number;
|
|
46
57
|
/**
|
|
47
58
|
* Restores a filter from its {@link BlockedBloomFilter.toBytes} serialization.
|
|
48
59
|
*
|
package/dist/blocked/index.js
CHANGED
|
@@ -76,6 +76,26 @@ var BlockedBloomFilter = class BlockedBloomFilter {
|
|
|
76
76
|
get bitsPerKey() {
|
|
77
77
|
return this.#numBlocks * 256 / this.#n;
|
|
78
78
|
}
|
|
79
|
+
/** Number of bits currently set across all lanes. */
|
|
80
|
+
get length() {
|
|
81
|
+
let bits = 0;
|
|
82
|
+
for (let w of this.#lanes) while (w) {
|
|
83
|
+
w &= w - 1;
|
|
84
|
+
bits++;
|
|
85
|
+
}
|
|
86
|
+
return bits;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
90
|
+
* `(length / totalBits) ** 8`. A split-block query checks exactly 8 lane-bits,
|
|
91
|
+
* so the exponent is 8 rather than a classic probe count `k`. This reflects
|
|
92
|
+
* how full the filter is right now, not the design target.
|
|
93
|
+
*
|
|
94
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
95
|
+
*/
|
|
96
|
+
rate() {
|
|
97
|
+
return (this.length / (this.#numBlocks * 256)) ** 8;
|
|
98
|
+
}
|
|
79
99
|
/**
|
|
80
100
|
* Restores a filter from its {@link BlockedBloomFilter.toBytes} serialization.
|
|
81
101
|
*
|
package/dist/bloom/index.cjs
CHANGED
|
@@ -122,11 +122,37 @@ var BloomFilter = class BloomFilter {
|
|
|
122
122
|
this.#scratch = new Uint32Array(k);
|
|
123
123
|
this.#n = Math.round(m * Math.LN2 / k);
|
|
124
124
|
}
|
|
125
|
+
/** Number of bits in the filter. */
|
|
126
|
+
get m() {
|
|
127
|
+
return this.#m;
|
|
128
|
+
}
|
|
129
|
+
/** Number of hash probes per key. */
|
|
130
|
+
get k() {
|
|
131
|
+
return this.#k;
|
|
132
|
+
}
|
|
133
|
+
/** Hash seed. */
|
|
134
|
+
get seed() {
|
|
135
|
+
return this.#seed;
|
|
136
|
+
}
|
|
137
|
+
/** Number of bits currently set. */
|
|
138
|
+
get length() {
|
|
139
|
+
return this.#bits.count();
|
|
140
|
+
}
|
|
125
141
|
/** Analytic design bits-per-key `m / n`. */
|
|
126
142
|
get bitsPerKey() {
|
|
127
143
|
return this.#m / this.#n;
|
|
128
144
|
}
|
|
129
145
|
/**
|
|
146
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
147
|
+
* `(length / m) ** k`. This reflects how full the filter is right now, not
|
|
148
|
+
* the design target; it rises as keys are added.
|
|
149
|
+
*
|
|
150
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
151
|
+
*/
|
|
152
|
+
rate() {
|
|
153
|
+
return (this.length / this.#m) ** this.#k;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
130
156
|
* Serializes the filter to a portable little-endian byte layout.
|
|
131
157
|
*
|
|
132
158
|
* @returns The serialized filter, readable by {@link BloomFilter.fromBytes}.
|
package/dist/bloom/index.d.cts
CHANGED
|
@@ -49,8 +49,24 @@ declare class BloomFilter {
|
|
|
49
49
|
* {@link BloomFilter.create} unless restoring a specific configuration.
|
|
50
50
|
*/
|
|
51
51
|
constructor({ m, k, seed }: BloomParams);
|
|
52
|
+
/** Number of bits in the filter. */
|
|
53
|
+
get m(): number;
|
|
54
|
+
/** Number of hash probes per key. */
|
|
55
|
+
get k(): number;
|
|
56
|
+
/** Hash seed. */
|
|
57
|
+
get seed(): number;
|
|
58
|
+
/** Number of bits currently set. */
|
|
59
|
+
get length(): number;
|
|
52
60
|
/** Analytic design bits-per-key `m / n`. */
|
|
53
61
|
get bitsPerKey(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
64
|
+
* `(length / m) ** k`. This reflects how full the filter is right now, not
|
|
65
|
+
* the design target; it rises as keys are added.
|
|
66
|
+
*
|
|
67
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
68
|
+
*/
|
|
69
|
+
rate(): number;
|
|
54
70
|
/**
|
|
55
71
|
* Serializes the filter to a portable little-endian byte layout.
|
|
56
72
|
*
|
package/dist/bloom/index.d.ts
CHANGED
|
@@ -49,8 +49,24 @@ declare class BloomFilter {
|
|
|
49
49
|
* {@link BloomFilter.create} unless restoring a specific configuration.
|
|
50
50
|
*/
|
|
51
51
|
constructor({ m, k, seed }: BloomParams);
|
|
52
|
+
/** Number of bits in the filter. */
|
|
53
|
+
get m(): number;
|
|
54
|
+
/** Number of hash probes per key. */
|
|
55
|
+
get k(): number;
|
|
56
|
+
/** Hash seed. */
|
|
57
|
+
get seed(): number;
|
|
58
|
+
/** Number of bits currently set. */
|
|
59
|
+
get length(): number;
|
|
52
60
|
/** Analytic design bits-per-key `m / n`. */
|
|
53
61
|
get bitsPerKey(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
64
|
+
* `(length / m) ** k`. This reflects how full the filter is right now, not
|
|
65
|
+
* the design target; it rises as keys are added.
|
|
66
|
+
*
|
|
67
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
68
|
+
*/
|
|
69
|
+
rate(): number;
|
|
54
70
|
/**
|
|
55
71
|
* Serializes the filter to a portable little-endian byte layout.
|
|
56
72
|
*
|
package/dist/bloom/index.js
CHANGED
|
@@ -121,11 +121,37 @@ var BloomFilter = class BloomFilter {
|
|
|
121
121
|
this.#scratch = new Uint32Array(k);
|
|
122
122
|
this.#n = Math.round(m * Math.LN2 / k);
|
|
123
123
|
}
|
|
124
|
+
/** Number of bits in the filter. */
|
|
125
|
+
get m() {
|
|
126
|
+
return this.#m;
|
|
127
|
+
}
|
|
128
|
+
/** Number of hash probes per key. */
|
|
129
|
+
get k() {
|
|
130
|
+
return this.#k;
|
|
131
|
+
}
|
|
132
|
+
/** Hash seed. */
|
|
133
|
+
get seed() {
|
|
134
|
+
return this.#seed;
|
|
135
|
+
}
|
|
136
|
+
/** Number of bits currently set. */
|
|
137
|
+
get length() {
|
|
138
|
+
return this.#bits.count();
|
|
139
|
+
}
|
|
124
140
|
/** Analytic design bits-per-key `m / n`. */
|
|
125
141
|
get bitsPerKey() {
|
|
126
142
|
return this.#m / this.#n;
|
|
127
143
|
}
|
|
128
144
|
/**
|
|
145
|
+
* Estimates the current false-positive rate from the actual fill,
|
|
146
|
+
* `(length / m) ** k`. This reflects how full the filter is right now, not
|
|
147
|
+
* the design target; it rises as keys are added.
|
|
148
|
+
*
|
|
149
|
+
* @returns The estimated false-positive rate, `0` for an empty filter.
|
|
150
|
+
*/
|
|
151
|
+
rate() {
|
|
152
|
+
return (this.length / this.#m) ** this.#k;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
129
155
|
* Serializes the filter to a portable little-endian byte layout.
|
|
130
156
|
*
|
|
131
157
|
* @returns The serialized filter, readable by {@link BloomFilter.fromBytes}.
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "distillate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|