Skip to content

Document dependency on ES6 Map (or add inline fallback) #71

Closed
@Krinkle

Description

@Krinkle

The commits 82e8403 and b36ea4d added use of ES6 Map.

This is fine, but with the package using UMD and ES5-compatible syntax and no mention of an ES6 dependency, it took me by surprise when testing it in older browsers as part of QUnit (ref qunitjs/qunit#1440).

I'd recommend shipping a 5-line shim for the basic string map use case (or to document the dependency with a recommendation to use es6-shim or something like that?).

The following is what I ended up using in QUnit for fuzzysort:

var Map = Map || function StringMap() {
  var store = Object.create(null);
  this.get = function(key) {
    return store[key];
  };
  this.set = function(key, val) {
    store[key] = val;
    return this;
  };
  this.clear = function() {
    store = Object.create(null);
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions