-
Notifications
You must be signed in to change notification settings - Fork 14
Description
I'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
)