Skip to content

Add browser support? #1

Description

@josephrocca

I've recently been having quite a bit of trouble with the browser's built-in Map:

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions