Callidon / bloom-filters

JS implementation of probabilistic data structures: Bloom Filter (and its derived), HyperLogLog, Count-Min Sketch, Top-K and MinHash
https://callidon.github.io/bloom-filters/
MIT License
369 stars 42 forks source link

Error in Browser Chrome 105 #57

Closed kabapy closed 2 years ago

kabapy commented 2 years ago

environment is a quasar+vite+vue3

vue-router.mjs:3428 ReferenceError: Buffer is not defined at cell.js:178:76 at node_modules/bloom-filters/dist/iblt/cell.js (cell.js:200:1) at require (chunk-OL3AADLO.js?v=aca5486d:9:50) at node_modules/bloom-filters/dist/iblt/invertible-bloom-lookup-tables.js (invertible-bloom-lookup-tables.js:84:30) at __require (chunk-OL3AADLO.js?v=aca5486d:9:50) at node_modules/bloom-filters/dist/api.js (api.js:54:40) at require (chunk-OL3AADLO.js?v=aca5486d:9:50) at dep:bloom-filters:1:16

kabapy commented 2 years ago

Found a fix https://github.com/feross/buffer

you have to install a polyfill for Buffer npm install buffer

then import it in main.js and make it global using import { Buffer } from "buffer"; window.Buffer = window.Buffer || Buffer;

folkvir commented 2 years ago

Yes this is the fix. You cannot actually import all the modules in a browser but you can import some without polyfills. For the Invertible Bloom filter yes you need to install this package for a browser usage. See the warning https://github.com/Callidon/bloom-filters#invertible-bloom-filters