megahash icon indicating copy to clipboard operation
megahash copied to clipboard

ES6 Map compatibility

Open commenthol opened this issue 3 years ago • 1 comments

@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?

commenthol avatar Nov 01 '21 07:11 commenthol

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

jhuckaby avatar Nov 02 '21 18:11 jhuckaby