Skip to content

Commit ef318ff

Browse files
committed
Release v1.0.0: Production-ready with serialization fix
Breaking Changes: - SerializedBloomSift now includes 'capacity' field - Ensures fillRatio is properly preserved through serialization Added: - capacity field to serialization format - Validation for capacity in deserialize - Test for invalid capacity Changed: - Version bumped from 0.1.0 to 1.0.0 - deserialize() now properly restores original capacity This release makes the library production-ready with proper state preservation across serialization boundaries.
1 parent ca1d360 commit ef318ff

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.0] - 2025-11-20
9+
10+
### Added
11+
- `capacity` field to `SerializedBloomSift` interface for proper fillRatio preservation
12+
- Validation for `capacity` in deserialize method
13+
- Test for invalid capacity deserialization
14+
15+
### Changed
16+
- **BREAKING**: Serialization format now includes `capacity` field
17+
- `deserialize()` now properly restores original capacity and fillRatio
18+
819
## [0.1.0] - 2025-11-20
920

1021
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bloom-sift",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "Bloom filter with 128-bit MurmurHash3 optimization using Kirsch-Mitzenmacher technique",
55
"type": "module",
66
"main": "./dist/index.js",

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export interface SerializedBloomSift {
1515
size: number;
1616
/** Number of hash functions (k) */
1717
hashCount: number;
18+
/** Expected capacity */
19+
capacity: number;
1820
/** Approximate number of items added */
1921
count: number;
2022
}
@@ -137,6 +139,7 @@ export class BloomSift {
137139
bits,
138140
size: this._size,
139141
hashCount: this._hashCount,
142+
capacity: this._capacity,
140143
count: this._count,
141144
};
142145
}
@@ -158,6 +161,9 @@ export class BloomSift {
158161
if (data.hashCount <= 0 || !Number.isInteger(data.hashCount)) {
159162
throw new Error('Invalid serialized data: hashCount must be a positive integer');
160163
}
164+
if (data.capacity <= 0 || !Number.isInteger(data.capacity)) {
165+
throw new Error('Invalid serialized data: capacity must be a positive integer');
166+
}
161167
if (data.count < 0 || !Number.isInteger(data.count)) {
162168
throw new Error('Invalid serialized data: count must be a non-negative integer');
163169
}
@@ -185,7 +191,7 @@ export class BloomSift {
185191
raw.bits = bits;
186192
raw._size = data.size;
187193
raw._hashCount = data.hashCount;
188-
raw._capacity = data.count || 1;
194+
raw._capacity = data.capacity;
189195
raw._count = data.count;
190196

191197
return instance;

test/bloom-sift.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,15 @@ describe('BloomSift', () => {
357357
bits: 'AA==',
358358
size: 0,
359359
hashCount: 7,
360+
capacity: 100,
360361
count: 0
361362
})).toThrow('size must be a positive integer');
362363

363364
expect(() => BloomSift.deserialize({
364365
bits: 'AA==',
365366
size: -1,
366367
hashCount: 7,
368+
capacity: 100,
367369
count: 0
368370
})).toThrow('size must be a positive integer');
369371
});
@@ -373,6 +375,7 @@ describe('BloomSift', () => {
373375
bits: 'AA==',
374376
size: 8,
375377
hashCount: 0,
378+
capacity: 100,
376379
count: 0
377380
})).toThrow('hashCount must be a positive integer');
378381
});
@@ -382,6 +385,7 @@ describe('BloomSift', () => {
382385
bits: 'AA==',
383386
size: 8,
384387
hashCount: 7,
388+
capacity: 100,
385389
count: -1
386390
})).toThrow('count must be a non-negative integer');
387391
});
@@ -391,8 +395,19 @@ describe('BloomSift', () => {
391395
bits: 'AA==', // 1 byte
392396
size: 100, // expects 13 bytes
393397
hashCount: 7,
398+
capacity: 100,
394399
count: 0
395400
})).toThrow('expected 13 bytes, got 1');
396401
});
402+
403+
it('should reject invalid capacity', () => {
404+
expect(() => BloomSift.deserialize({
405+
bits: 'AA==',
406+
size: 8,
407+
hashCount: 7,
408+
capacity: 0,
409+
count: 0
410+
})).toThrow('capacity must be a positive integer');
411+
});
397412
});
398413
});

0 commit comments

Comments
 (0)