Add browser support?
See original GitHub issueI’ve recently been having quite a bit of trouble with the browser’s built-in Map:
- Speed in V8 is really bad: https://bugs.chromium.org/p/v8/issues/detail?id=9348
- Memory allocation crashes: https://bugs.chromium.org/p/v8/issues/detail?id=9350 (example is with arrays but getting the same thing with maps)
So I went hunting and found your project - it looks great! Is there any interest in making it browser-compatible by detecting if the code is running in a browser and switching out Buffer for ArrayBuffer? Or even just using feross’s browser-based buffer polyfill? https://github.com/feross/buffer
For crypto.randomBytes
, there’s this isomorphic lib: https://www.npmjs.com/package/randombytes
Edit: Here’s a working proof of concept: https://gist.github.com/josephrocca/019f091e5f83e410533caeb6f371200e
All I did was:
npm install buffer
npm install randombytes
Then, in index.js
, swap require('crypto').randomBytes
for require('randombytes')
, and then just:
npm install -g browserify
browserify index.js -o HashTable.mjs
I haven’t used browserify before so that linked script pulls HashTable and Buffer out of the module in a weird way… but it works! (see bottom of HashTable.mjs
)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Rust is cool, https://ziglang.org is also worth checking out. Zig’s error handling sets are awesome. It strikes an almost perfect balance. It’s closer to C than Rust, which is closer to C++.
I’m also a mere web developer and I don’t think my own noobish bug reports ever get better over time. 😅 Always worth submitting a crbug!
Thanks! I will definitely check out Zig 😃