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

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

Closed
Krinkle opened this issue Aug 16, 2020 · 0 comments
Closed

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

Krinkle opened this issue Aug 16, 2020 · 0 comments

Comments

@Krinkle
Copy link
Contributor

Krinkle commented Aug 16, 2020

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);
  };
}
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

Successfully merging a pull request may close this issue.

1 participant