Skip to content

Commit

Permalink
fix: Add inline string map fallback for ES6 Map
Browse files Browse the repository at this point in the history
Fixes farzher#71.
  • Loading branch information
Krinkle committed Aug 16, 2020
1 parent c660499 commit 511bfbc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions fuzzysort.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,21 @@ USAGE:
var isNode = typeof require !== 'undefined' && typeof window === 'undefined'
// var MAX_INT = Number.MAX_SAFE_INTEGER
// var MIN_INT = Number.MIN_VALUE
var preparedCache = new Map()
var preparedSearchCache = new Map()
var StringMap = typeof Map !== 'undefined' ? 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)
}
}
var preparedCache = new StringMap()
var preparedSearchCache = new StringMap()
var noResults = []; noResults.total = 0
var matchesSimple = []; var matchesStrict = []
function cleanup() { preparedCache.clear(); preparedSearchCache.clear(); matchesSimple = []; matchesStrict = [] }
Expand Down

0 comments on commit 511bfbc

Please sign in to comment.