Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 Map compatibility #12

Open
commenthol opened this issue Nov 1, 2021 · 1 comment
Open

ES6 Map compatibility #12

commenthol opened this issue Nov 1, 2021 · 1 comment

Comments

@commenthol
Copy link

@jhuckaby Would you accept a PR which makes the megahash interface compatible with ES6 Map?
If so, what would be your preferred option?
E.g. Using class inheritance like:

const MegaHash = require('./main.js')

class Map extends MegaHash {
  get size () {
    return this.length()
  }

  * keys () {
    let key
    while (1) {
      key = this.nextKey(key)
      if (key === undefined) break
      yield key
    }
    return key
  }

//...
}

module.exports = Map

or adding the prototypes in main.js?

@jhuckaby
Copy link
Owner

jhuckaby commented Nov 2, 2021

Hello! Yes, that would be awesome. I would prefer that it be a separate subclass (possibly called MegaMap?) which inherits from MegaHash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants