-
Notifications
You must be signed in to change notification settings - Fork 50
Description
I'd really like to use this module in browsers but the bundle size ends up being very large, just importing the CuckooFilter adds over 50KB of minified code to the bundle.
Using esbuild to bundle just this script:
import { CuckooFilter } from 'bloom-filters'
const filter = new CuckooFilter(1, 2, 3, 4)
console.info(filter.has('hello world'))Creates a 216KB bundle (63KB minified), and I have to shim some node internals (e.g. the Buffer class) for it to work:
The CuckooFilter implementation itself is 8.4KB un-minified so there's a lot of unused code here.
Would you be open to some PRs that make this module more browser friendly?
Some low hanging fruit I can see immediately:
- Switch tsc to output ESM for better tree shaking
- Replace use of node
Buffers with built-inUint8Arrays - Remove, replace or optimise use of lodash
- Remove
longdependency and use built-inBigInts
The first is a breaking change but will yield the biggest benefit - the breaking change is that consumers will no longer be able to require the module, they must import it via static or dynamic imports.
The second is breaking where Buffers are used as return values which from what I can see only appears to be in the Invertible Bloom Lookup Table implementation.
The rest are just internal changes so are non-breaking.