From 290cfe49a5bee7573ef2fde02adb220c8925db1a Mon Sep 17 00:00:00 2001 From: Kirollos Risk Date: Sun, 10 Feb 2019 14:07:51 -0800 Subject: [PATCH] Fixed #288 --- .babelrc | 1 + CHANGELOG.md | 12 + dist/fuse.js | 1134 ++++++++++++++++++++++++---------------------- dist/fuse.min.js | 4 +- package.json | 6 +- yarn.lock | 844 ++++++++++++++++------------------ 6 files changed, 988 insertions(+), 1013 deletions(-) diff --git a/.babelrc b/.babelrc index 4801cabca..882ec7f69 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,5 @@ { + "presets": ["@babel/preset-env"], "plugins": [ "babel-plugin-add-module-exports" ] diff --git a/CHANGELOG.md b/CHANGELOG.md index a4f8a61b4..83ac76c59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +# Version 3.4.2 + +- Fixed #288 + +# Version 3.4.1 + +- Ensured `dist/` content is production ready (both full and min versions) #283 + +# Version 3.4.0 + +- Upgraded build tool to Webpack 4. New `dist/` output. + # Version 3.3.1 - Fixed the circular JSON TypeError (#197). Thanks [ThinkTankShark](https://github.com/ThinkTankShark)! diff --git a/dist/fuse.js b/dist/fuse.js index 1aae6c174..ed96104b6 100644 --- a/dist/fuse.js +++ b/dist/fuse.js @@ -1,5 +1,5 @@ /*! - * Fuse.js v3.4.1 - Lightweight fuzzy-search (http://fusejs.io) + * Fuse.js v3.4.2 - Lightweight fuzzy-search (http://fusejs.io) * * Copyright (c) 2012-2017 Kirollos Risk (http://kiro.me) * All Rights Reserved. Apache Software License 2.0 @@ -111,14 +111,16 @@ return /******/ (function(modules) { // webpackBootstrap /*! no static exports found */ /***/ (function(module, exports) { -module.exports = (matchmask = [], minMatchCharLength = 1) => { - let matchedIndices = []; - let start = -1; - let end = -1; - let i = 0; +module.exports = function () { + var matchmask = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var minMatchCharLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; + var matchedIndices = []; + var start = -1; + var end = -1; + var i = 0; - for (let len = matchmask.length; i < len; i += 1) { - let match = matchmask[i]; + for (var len = matchmask.length; i < len; i += 1) { + var match = matchmask[i]; if (match && start === -1) { start = i; @@ -150,16 +152,16 @@ module.exports = (matchmask = [], minMatchCharLength = 1) => { /*! no static exports found */ /***/ (function(module, exports) { -module.exports = pattern => { - let mask = {}; - let len = pattern.length; +module.exports = function (pattern) { + var mask = {}; + var len = pattern.length; - for (let i = 0; i < len; i += 1) { + for (var i = 0; i < len; i += 1) { mask[pattern.charAt(i)] = 0; } - for (let i = 0; i < len; i += 1) { - mask[pattern.charAt(i)] |= 1 << len - i - 1; + for (var _i = 0; _i < len; _i += 1) { + mask[pattern.charAt(_i)] |= 1 << len - _i - 1; } return mask; @@ -174,17 +176,18 @@ module.exports = pattern => { /*! no static exports found */ /***/ (function(module, exports) { -const SPECIAL_CHARS_REGEX = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; +var SPECIAL_CHARS_REGEX = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; -module.exports = (text, pattern, tokenSeparator = / +/g) => { - let regex = new RegExp(pattern.replace(SPECIAL_CHARS_REGEX, '\\$&').replace(tokenSeparator, '|')); - let matches = text.match(regex); - let isMatch = !!matches; - let matchedIndices = []; +module.exports = function (text, pattern) { + var tokenSeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : / +/g; + var regex = new RegExp(pattern.replace(SPECIAL_CHARS_REGEX, '\\$&').replace(tokenSeparator, '|')); + var matches = text.match(regex); + var isMatch = !!matches; + var matchedIndices = []; if (isMatch) { - for (let i = 0, matchesLen = matches.length; i < matchesLen; i += 1) { - let match = matches[i]; + for (var i = 0, matchesLen = matches.length; i < matchesLen; i += 1) { + var match = matches[i]; matchedIndices.push([text.indexOf(match), match.length - 1]); } } @@ -192,8 +195,8 @@ module.exports = (text, pattern, tokenSeparator = / +/g) => { return { // TODO: revisit this score score: isMatch ? 0.5 : 1, - isMatch, - matchedIndices + isMatch: isMatch, + matchedIndices: matchedIndices }; }; @@ -206,14 +209,17 @@ module.exports = (text, pattern, tokenSeparator = / +/g) => { /*! no static exports found */ /***/ (function(module, exports) { -module.exports = (pattern, { - errors = 0, - currentLocation = 0, - expectedLocation = 0, - distance = 100 -}) => { - const accuracy = errors / pattern.length; - const proximity = Math.abs(expectedLocation - currentLocation); +module.exports = function (pattern, _ref) { + var _ref$errors = _ref.errors, + errors = _ref$errors === void 0 ? 0 : _ref$errors, + _ref$currentLocation = _ref.currentLocation, + currentLocation = _ref$currentLocation === void 0 ? 0 : _ref$currentLocation, + _ref$expectedLocation = _ref.expectedLocation, + expectedLocation = _ref$expectedLocation === void 0 ? 0 : _ref$expectedLocation, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance; + var accuracy = errors / pattern.length; + var proximity = Math.abs(expectedLocation - currentLocation); if (!distance) { // Dodge divide by zero error. @@ -232,77 +238,82 @@ module.exports = (pattern, { /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const bitapScore = __webpack_require__(/*! ./bitap_score */ "./src/bitap/bitap_score.js"); +var bitapScore = __webpack_require__(/*! ./bitap_score */ "./src/bitap/bitap_score.js"); -const matchedIndices = __webpack_require__(/*! ./bitap_matched_indices */ "./src/bitap/bitap_matched_indices.js"); +var matchedIndices = __webpack_require__(/*! ./bitap_matched_indices */ "./src/bitap/bitap_matched_indices.js"); -module.exports = (text, pattern, patternAlphabet, { - location = 0, - distance = 100, - threshold = 0.6, - findAllMatches = false, - minMatchCharLength = 1 -}) => { - const expectedLocation = location; // Set starting location at beginning text and initialize the alphabet. +module.exports = function (text, pattern, patternAlphabet, _ref) { + var _ref$location = _ref.location, + location = _ref$location === void 0 ? 0 : _ref$location, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance, + _ref$threshold = _ref.threshold, + threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold, + _ref$findAllMatches = _ref.findAllMatches, + findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches, + _ref$minMatchCharLeng = _ref.minMatchCharLength, + minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng; + var expectedLocation = location; // Set starting location at beginning text and initialize the alphabet. - const textLen = text.length; // Highest score beyond which we give up. + var textLen = text.length; // Highest score beyond which we give up. - let currentThreshold = threshold; // Is there a nearby exact match? (speedup) + var currentThreshold = threshold; // Is there a nearby exact match? (speedup) - let bestLocation = text.indexOf(pattern, expectedLocation); - const patternLen = pattern.length; // a mask of the matches + var bestLocation = text.indexOf(pattern, expectedLocation); + var patternLen = pattern.length; // a mask of the matches - const matchMask = []; + var matchMask = []; - for (let i = 0; i < textLen; i += 1) { + for (var i = 0; i < textLen; i += 1) { matchMask[i] = 0; } if (bestLocation !== -1) { - let score = bitapScore(pattern, { + var score = bitapScore(pattern, { errors: 0, currentLocation: bestLocation, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); currentThreshold = Math.min(score, currentThreshold); // What about in the other direction? (speed up) bestLocation = text.lastIndexOf(pattern, expectedLocation + patternLen); if (bestLocation !== -1) { - let score = bitapScore(pattern, { + var _score = bitapScore(pattern, { errors: 0, currentLocation: bestLocation, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); - currentThreshold = Math.min(score, currentThreshold); + + currentThreshold = Math.min(_score, currentThreshold); } } // Reset the best location bestLocation = -1; - let lastBitArr = []; - let finalScore = 1; - let binMax = patternLen + textLen; - const mask = 1 << patternLen - 1; + var lastBitArr = []; + var finalScore = 1; + var binMax = patternLen + textLen; + var mask = 1 << patternLen - 1; - for (let i = 0; i < patternLen; i += 1) { + for (var _i = 0; _i < patternLen; _i += 1) { // Scan for the best match; each iteration allows for one more error. // Run a binary search to determine how far from the match location we can stray // at this error level. - let binMin = 0; - let binMid = binMax; + var binMin = 0; + var binMid = binMax; while (binMin < binMid) { - const score = bitapScore(pattern, { - errors: i, + var _score3 = bitapScore(pattern, { + errors: _i, currentLocation: expectedLocation + binMid, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); - if (score <= currentThreshold) { + if (_score3 <= currentThreshold) { binMin = binMid; } else { binMax = binMid; @@ -313,15 +324,15 @@ module.exports = (text, pattern, patternAlphabet, { binMax = binMid; - let start = Math.max(1, expectedLocation - binMid + 1); - let finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen; // Initialize the bit array + var start = Math.max(1, expectedLocation - binMid + 1); + var finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen; // Initialize the bit array - let bitArr = Array(finish + 2); - bitArr[finish + 1] = (1 << i) - 1; + var bitArr = Array(finish + 2); + bitArr[finish + 1] = (1 << _i) - 1; - for (let j = finish; j >= start; j -= 1) { - let currentLocation = j - 1; - let charMatch = patternAlphabet[text.charAt(currentLocation)]; + for (var j = finish; j >= start; j -= 1) { + var currentLocation = j - 1; + var charMatch = patternAlphabet[text.charAt(currentLocation)]; if (charMatch) { matchMask[currentLocation] = 1; @@ -330,16 +341,16 @@ module.exports = (text, pattern, patternAlphabet, { bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch; // Subsequent passes: fuzzy match - if (i !== 0) { + if (_i !== 0) { bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1]; } if (bitArr[j] & mask) { finalScore = bitapScore(pattern, { - errors: i, - currentLocation, - expectedLocation, - distance + errors: _i, + currentLocation: currentLocation, + expectedLocation: expectedLocation, + distance: distance }); // This match will almost certainly be better than any existing match. // But check anyway. @@ -359,14 +370,15 @@ module.exports = (text, pattern, patternAlphabet, { } // No hope for a (better) match at greater error levels. - const score = bitapScore(pattern, { - errors: i + 1, + var _score2 = bitapScore(pattern, { + errors: _i + 1, currentLocation: expectedLocation, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); // console.log('score', score, finalScore) - if (score > currentThreshold) { + + if (_score2 > currentThreshold) { break; } @@ -391,46 +403,50 @@ module.exports = (text, pattern, patternAlphabet, { /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const bitapRegexSearch = __webpack_require__(/*! ./bitap_regex_search */ "./src/bitap/bitap_regex_search.js"); - -const bitapSearch = __webpack_require__(/*! ./bitap_search */ "./src/bitap/bitap_search.js"); - -const patternAlphabet = __webpack_require__(/*! ./bitap_pattern_alphabet */ "./src/bitap/bitap_pattern_alphabet.js"); - -class Bitap { - constructor(pattern, { - // Approximately where in the text is the pattern expected to be found? - location = 0, - // Determines how close the match must be to the fuzzy location (specified above). - // An exact letter match which is 'distance' characters away from the fuzzy location - // would score as a complete mismatch. A distance of '0' requires the match be at - // the exact location specified, a threshold of '1000' would require a perfect match - // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. - distance = 100, - // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match - // (of both letters and location), a threshold of '1.0' would match anything. - threshold = 0.6, - // Machine word size - maxPatternLength = 32, - // Indicates whether comparisons should be case sensitive. - isCaseSensitive = false, - // Regex used to separate words when searching. Only applicable when `tokenize` is `true`. - tokenSeparator = / +/g, - // When true, the algorithm continues searching to the end of the input even if a perfect - // match is found before the end of the same input. - findAllMatches = false, - // Minimum number of characters that must be matched before a result is considered a match - minMatchCharLength = 1 - }) { +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var bitapRegexSearch = __webpack_require__(/*! ./bitap_regex_search */ "./src/bitap/bitap_regex_search.js"); + +var bitapSearch = __webpack_require__(/*! ./bitap_search */ "./src/bitap/bitap_search.js"); + +var patternAlphabet = __webpack_require__(/*! ./bitap_pattern_alphabet */ "./src/bitap/bitap_pattern_alphabet.js"); + +var Bitap = +/*#__PURE__*/ +function () { + function Bitap(pattern, _ref) { + var _ref$location = _ref.location, + location = _ref$location === void 0 ? 0 : _ref$location, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance, + _ref$threshold = _ref.threshold, + threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold, + _ref$maxPatternLength = _ref.maxPatternLength, + maxPatternLength = _ref$maxPatternLength === void 0 ? 32 : _ref$maxPatternLength, + _ref$isCaseSensitive = _ref.isCaseSensitive, + isCaseSensitive = _ref$isCaseSensitive === void 0 ? false : _ref$isCaseSensitive, + _ref$tokenSeparator = _ref.tokenSeparator, + tokenSeparator = _ref$tokenSeparator === void 0 ? / +/g : _ref$tokenSeparator, + _ref$findAllMatches = _ref.findAllMatches, + findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches, + _ref$minMatchCharLeng = _ref.minMatchCharLength, + minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng; + + _classCallCheck(this, Bitap); + this.options = { - location, - distance, - threshold, - maxPatternLength, - isCaseSensitive, - tokenSeparator, - findAllMatches, - minMatchCharLength + location: location, + distance: distance, + threshold: threshold, + maxPatternLength: maxPatternLength, + isCaseSensitive: isCaseSensitive, + tokenSeparator: tokenSeparator, + findAllMatches: findAllMatches, + minMatchCharLength: minMatchCharLength }; this.pattern = this.options.isCaseSensitive ? pattern : pattern.toLowerCase(); @@ -439,48 +455,50 @@ class Bitap { } } - search(text) { - if (!this.options.isCaseSensitive) { - text = text.toLowerCase(); - } // Exact match - - - if (this.pattern === text) { - return { - isMatch: true, - score: 0, - matchedIndices: [[0, text.length - 1]] - }; - } // When pattern length is greater than the machine word length, just do a a regex comparison - - - const { - maxPatternLength, - tokenSeparator - } = this.options; - - if (this.pattern.length > maxPatternLength) { - return bitapRegexSearch(text, this.pattern, tokenSeparator); - } // Otherwise, use Bitap algorithm - - - const { - location, - distance, - threshold, - findAllMatches, - minMatchCharLength - } = this.options; - return bitapSearch(text, this.pattern, this.patternAlphabet, { - location, - distance, - threshold, - findAllMatches, - minMatchCharLength - }); - } + _createClass(Bitap, [{ + key: "search", + value: function search(text) { + if (!this.options.isCaseSensitive) { + text = text.toLowerCase(); + } // Exact match + + + if (this.pattern === text) { + return { + isMatch: true, + score: 0, + matchedIndices: [[0, text.length - 1]] + }; + } // When pattern length is greater than the machine word length, just do a a regex comparison + + + var _this$options = this.options, + maxPatternLength = _this$options.maxPatternLength, + tokenSeparator = _this$options.tokenSeparator; + + if (this.pattern.length > maxPatternLength) { + return bitapRegexSearch(text, this.pattern, tokenSeparator); + } // Otherwise, use Bitap algorithm + + + var _this$options2 = this.options, + location = _this$options2.location, + distance = _this$options2.distance, + threshold = _this$options2.threshold, + findAllMatches = _this$options2.findAllMatches, + minMatchCharLength = _this$options2.minMatchCharLength; + return bitapSearch(text, this.pattern, this.patternAlphabet, { + location: location, + distance: distance, + threshold: threshold, + findAllMatches: findAllMatches, + minMatchCharLength: minMatchCharLength + }); + } + }]); -} // let x = new Bitap("od mn war", {}) + return Bitap; +}(); // let x = new Bitap("od mn war", {}) // let result = x.search("Old Man's War") // console.log(result) @@ -496,30 +514,30 @@ module.exports = Bitap; /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const isArray = __webpack_require__(/*! ./is_array */ "./src/helpers/is_array.js"); +var isArray = __webpack_require__(/*! ./is_array */ "./src/helpers/is_array.js"); -const deepValue = (obj, path, list) => { +var deepValue = function deepValue(obj, path, list) { if (!path) { // If there's no path left, we've gotten to the object we care about. list.push(obj); } else { - const dotIndex = path.indexOf('.'); - let firstSegment = path; - let remaining = null; + var dotIndex = path.indexOf('.'); + var firstSegment = path; + var remaining = null; if (dotIndex !== -1) { firstSegment = path.slice(0, dotIndex); remaining = path.slice(dotIndex + 1); } - const value = obj[firstSegment]; + var value = obj[firstSegment]; if (value !== null && value !== undefined) { if (!remaining && (typeof value === 'string' || typeof value === 'number')) { list.push(value.toString()); } else if (isArray(value)) { // Search each item in the array. - for (let i = 0, len = value.length; i < len; i += 1) { + for (var i = 0, len = value.length; i < len; i += 1) { deepValue(value[i], remaining, list); } } else if (remaining) { @@ -532,7 +550,7 @@ const deepValue = (obj, path, list) => { return list; }; -module.exports = (obj, path) => { +module.exports = function (obj, path) { return deepValue(obj, path, []); }; @@ -545,7 +563,9 @@ module.exports = (obj, path) => { /*! no static exports found */ /***/ (function(module, exports) { -module.exports = obj => !Array.isArray ? Object.prototype.toString.call(obj) === '[object Array]' : Array.isArray(obj); +module.exports = function (obj) { + return !Array.isArray ? Object.prototype.toString.call(obj) === '[object Array]' : Array.isArray(obj); +}; /***/ }), @@ -556,476 +576,502 @@ module.exports = obj => !Array.isArray ? Object.prototype.toString.call(obj) === /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const Bitap = __webpack_require__(/*! ./bitap */ "./src/bitap/index.js"); - -const deepValue = __webpack_require__(/*! ./helpers/deep_value */ "./src/helpers/deep_value.js"); - -const isArray = __webpack_require__(/*! ./helpers/is_array */ "./src/helpers/is_array.js"); - -class Fuse { - constructor(list, { - // Approximately where in the text is the pattern expected to be found? - location = 0, - // Determines how close the match must be to the fuzzy location (specified above). - // An exact letter match which is 'distance' characters away from the fuzzy location - // would score as a complete mismatch. A distance of '0' requires the match be at - // the exact location specified, a threshold of '1000' would require a perfect match - // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. - distance = 100, - // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match - // (of both letters and location), a threshold of '1.0' would match anything. - threshold = 0.6, - // Machine word size - maxPatternLength = 32, - // Indicates whether comparisons should be case sensitive. - caseSensitive = false, - // Regex used to separate words when searching. Only applicable when `tokenize` is `true`. - tokenSeparator = / +/g, - // When true, the algorithm continues searching to the end of the input even if a perfect - // match is found before the end of the same input. - findAllMatches = false, - // Minimum number of characters that must be matched before a result is considered a match - minMatchCharLength = 1, - // The name of the identifier property. If specified, the returned result will be a list - // of the items' dentifiers, otherwise it will be a list of the items. - id = null, - // List of properties that will be searched. This also supports nested properties. - keys = [], - // Whether to sort the result list, by score - shouldSort = true, - // The get function to use when fetching an object's properties. - // The default will search nested paths *ie foo.bar.baz* - getFn = deepValue, - // Default sort function - sortFn = (a, b) => a.score - b.score, - // When true, the search algorithm will search individual words **and** the full string, - // computing the final score as a function of both. Note that when `tokenize` is `true`, - // the `threshold`, `distance`, and `location` are inconsequential for individual tokens. - tokenize = false, - // When true, the result set will only include records that match all tokens. Will only work - // if `tokenize` is also true. - matchAllTokens = false, - includeMatches = false, - includeScore = false, - // Will print to the console. Useful for debugging. - verbose = false - }) { +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var Bitap = __webpack_require__(/*! ./bitap */ "./src/bitap/index.js"); + +var deepValue = __webpack_require__(/*! ./helpers/deep_value */ "./src/helpers/deep_value.js"); + +var isArray = __webpack_require__(/*! ./helpers/is_array */ "./src/helpers/is_array.js"); + +var Fuse = +/*#__PURE__*/ +function () { + function Fuse(list, _ref) { + var _ref$location = _ref.location, + location = _ref$location === void 0 ? 0 : _ref$location, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance, + _ref$threshold = _ref.threshold, + threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold, + _ref$maxPatternLength = _ref.maxPatternLength, + maxPatternLength = _ref$maxPatternLength === void 0 ? 32 : _ref$maxPatternLength, + _ref$caseSensitive = _ref.caseSensitive, + caseSensitive = _ref$caseSensitive === void 0 ? false : _ref$caseSensitive, + _ref$tokenSeparator = _ref.tokenSeparator, + tokenSeparator = _ref$tokenSeparator === void 0 ? / +/g : _ref$tokenSeparator, + _ref$findAllMatches = _ref.findAllMatches, + findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches, + _ref$minMatchCharLeng = _ref.minMatchCharLength, + minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng, + _ref$id = _ref.id, + id = _ref$id === void 0 ? null : _ref$id, + _ref$keys = _ref.keys, + keys = _ref$keys === void 0 ? [] : _ref$keys, + _ref$shouldSort = _ref.shouldSort, + shouldSort = _ref$shouldSort === void 0 ? true : _ref$shouldSort, + _ref$getFn = _ref.getFn, + getFn = _ref$getFn === void 0 ? deepValue : _ref$getFn, + _ref$sortFn = _ref.sortFn, + sortFn = _ref$sortFn === void 0 ? function (a, b) { + return a.score - b.score; + } : _ref$sortFn, + _ref$tokenize = _ref.tokenize, + tokenize = _ref$tokenize === void 0 ? false : _ref$tokenize, + _ref$matchAllTokens = _ref.matchAllTokens, + matchAllTokens = _ref$matchAllTokens === void 0 ? false : _ref$matchAllTokens, + _ref$includeMatches = _ref.includeMatches, + includeMatches = _ref$includeMatches === void 0 ? false : _ref$includeMatches, + _ref$includeScore = _ref.includeScore, + includeScore = _ref$includeScore === void 0 ? false : _ref$includeScore, + _ref$verbose = _ref.verbose, + verbose = _ref$verbose === void 0 ? false : _ref$verbose; + + _classCallCheck(this, Fuse); + this.options = { - location, - distance, - threshold, - maxPatternLength, + location: location, + distance: distance, + threshold: threshold, + maxPatternLength: maxPatternLength, isCaseSensitive: caseSensitive, - tokenSeparator, - findAllMatches, - minMatchCharLength, - id, - keys, - includeMatches, - includeScore, - shouldSort, - getFn, - sortFn, - verbose, - tokenize, - matchAllTokens + tokenSeparator: tokenSeparator, + findAllMatches: findAllMatches, + minMatchCharLength: minMatchCharLength, + id: id, + keys: keys, + includeMatches: includeMatches, + includeScore: includeScore, + shouldSort: shouldSort, + getFn: getFn, + sortFn: sortFn, + verbose: verbose, + tokenize: tokenize, + matchAllTokens: matchAllTokens }; this.setCollection(list); } - setCollection(list) { - this.list = list; - return list; - } - - search(pattern, opts = { - limit: false - }) { - this._log(`---------\nSearch pattern: "${pattern}"`); - - const { - tokenSearchers, - fullSearcher - } = this._prepareSearchers(pattern); - - let { - weights, - results - } = this._search(tokenSearchers, fullSearcher); - - this._computeScore(weights, results); - - if (this.options.shouldSort) { - this._sort(results); + _createClass(Fuse, [{ + key: "setCollection", + value: function setCollection(list) { + this.list = list; + return list; } + }, { + key: "search", + value: function search(pattern) { + var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + limit: false + }; - if (opts.limit && typeof opts.limit === 'number') { - results = results.slice(0, opts.limit); - } + this._log("---------\nSearch pattern: \"".concat(pattern, "\"")); - return this._format(results); - } + var _this$_prepareSearche = this._prepareSearchers(pattern), + tokenSearchers = _this$_prepareSearche.tokenSearchers, + fullSearcher = _this$_prepareSearche.fullSearcher; - _prepareSearchers(pattern = '') { - const tokenSearchers = []; + var _this$_search = this._search(tokenSearchers, fullSearcher), + weights = _this$_search.weights, + results = _this$_search.results; - if (this.options.tokenize) { - // Tokenize on the separator - const tokens = pattern.split(this.options.tokenSeparator); + this._computeScore(weights, results); - for (let i = 0, len = tokens.length; i < len; i += 1) { - tokenSearchers.push(new Bitap(tokens[i], this.options)); + if (this.options.shouldSort) { + this._sort(results); } + + if (opts.limit && typeof opts.limit === 'number') { + results = results.slice(0, opts.limit); + } + + return this._format(results); } + }, { + key: "_prepareSearchers", + value: function _prepareSearchers() { + var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + var tokenSearchers = []; - let fullSearcher = new Bitap(pattern, this.options); - return { - tokenSearchers, - fullSearcher - }; - } + if (this.options.tokenize) { + // Tokenize on the separator + var tokens = pattern.split(this.options.tokenSeparator); - _search(tokenSearchers = [], fullSearcher) { - const list = this.list; - const resultMap = {}; - const results = []; // Check the first item in the list, if it's a string, then we assume - // that every item in the list is also a string, and thus it's a flattened array. - - if (typeof list[0] === 'string') { - // Iterate over every item - for (let i = 0, len = list.length; i < len; i += 1) { - this._analyze({ - key: '', - value: list[i], - record: i, - index: i - }, { - resultMap, - results, - tokenSearchers, - fullSearcher - }); + for (var i = 0, len = tokens.length; i < len; i += 1) { + tokenSearchers.push(new Bitap(tokens[i], this.options)); + } } + var fullSearcher = new Bitap(pattern, this.options); return { - weights: null, - results + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher }; - } // Otherwise, the first item is an Object (hopefully), and thus the searching - // is done on the values of the keys of each item. + } + }, { + key: "_search", + value: function _search() { + var tokenSearchers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var fullSearcher = arguments.length > 1 ? arguments[1] : undefined; + var list = this.list; + var resultMap = {}; + var results = []; // Check the first item in the list, if it's a string, then we assume + // that every item in the list is also a string, and thus it's a flattened array. + + if (typeof list[0] === 'string') { + // Iterate over every item + for (var i = 0, len = list.length; i < len; i += 1) { + this._analyze({ + key: '', + value: list[i], + record: i, + index: i + }, { + resultMap: resultMap, + results: results, + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher + }); + } + + return { + weights: null, + results: results + }; + } // Otherwise, the first item is an Object (hopefully), and thus the searching + // is done on the values of the keys of each item. - const weights = {}; + var weights = {}; - for (let i = 0, len = list.length; i < len; i += 1) { - let item = list[i]; // Iterate over every key + for (var _i = 0, _len = list.length; _i < _len; _i += 1) { + var item = list[_i]; // Iterate over every key - for (let j = 0, keysLen = this.options.keys.length; j < keysLen; j += 1) { - let key = this.options.keys[j]; + for (var j = 0, keysLen = this.options.keys.length; j < keysLen; j += 1) { + var key = this.options.keys[j]; - if (typeof key !== 'string') { - weights[key.name] = { - weight: 1 - key.weight || 1 - }; + if (typeof key !== 'string') { + weights[key.name] = { + weight: 1 - key.weight || 1 + }; - if (key.weight <= 0 || key.weight > 1) { - throw new Error('Key weight has to be > 0 and <= 1'); + if (key.weight <= 0 || key.weight > 1) { + throw new Error('Key weight has to be > 0 and <= 1'); + } + + key = key.name; + } else { + weights[key] = { + weight: 1 + }; } - key = key.name; - } else { - weights[key] = { - weight: 1 - }; + this._analyze({ + key: key, + value: this.options.getFn(item, key), + record: item, + index: _i + }, { + resultMap: resultMap, + results: results, + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher + }); } - - this._analyze({ - key, - value: this.options.getFn(item, key), - record: item, - index: i - }, { - resultMap, - results, - tokenSearchers, - fullSearcher - }); } - } - - return { - weights, - results - }; - } - _analyze({ - key, - arrayIndex = -1, - value, - record, - index - }, { - tokenSearchers = [], - fullSearcher = [], - resultMap = {}, - results = [] - }) { - // Check if the texvaluet can be searched - if (value === undefined || value === null) { - return; + return { + weights: weights, + results: results + }; } + }, { + key: "_analyze", + value: function _analyze(_ref2, _ref3) { + var key = _ref2.key, + _ref2$arrayIndex = _ref2.arrayIndex, + arrayIndex = _ref2$arrayIndex === void 0 ? -1 : _ref2$arrayIndex, + value = _ref2.value, + record = _ref2.record, + index = _ref2.index; + var _ref3$tokenSearchers = _ref3.tokenSearchers, + tokenSearchers = _ref3$tokenSearchers === void 0 ? [] : _ref3$tokenSearchers, + _ref3$fullSearcher = _ref3.fullSearcher, + fullSearcher = _ref3$fullSearcher === void 0 ? [] : _ref3$fullSearcher, + _ref3$resultMap = _ref3.resultMap, + resultMap = _ref3$resultMap === void 0 ? {} : _ref3$resultMap, + _ref3$results = _ref3.results, + results = _ref3$results === void 0 ? [] : _ref3$results; + + // Check if the texvaluet can be searched + if (value === undefined || value === null) { + return; + } - let exists = false; - let averageScore = -1; - let numTextMatches = 0; + var exists = false; + var averageScore = -1; + var numTextMatches = 0; - if (typeof value === 'string') { - this._log(`\nKey: ${key === '' ? '-' : key}`); + if (typeof value === 'string') { + this._log("\nKey: ".concat(key === '' ? '-' : key)); - let mainSearchResult = fullSearcher.search(value); + var mainSearchResult = fullSearcher.search(value); - this._log(`Full text: "${value}", score: ${mainSearchResult.score}`); + this._log("Full text: \"".concat(value, "\", score: ").concat(mainSearchResult.score)); - if (this.options.tokenize) { - let words = value.split(this.options.tokenSeparator); - let scores = []; + if (this.options.tokenize) { + var words = value.split(this.options.tokenSeparator); + var scores = []; - for (let i = 0; i < tokenSearchers.length; i += 1) { - let tokenSearcher = tokenSearchers[i]; + for (var i = 0; i < tokenSearchers.length; i += 1) { + var tokenSearcher = tokenSearchers[i]; - this._log(`\nPattern: "${tokenSearcher.pattern}"`); // let tokenScores = [] + this._log("\nPattern: \"".concat(tokenSearcher.pattern, "\"")); // let tokenScores = [] - let hasMatchInText = false; + var hasMatchInText = false; - for (let j = 0; j < words.length; j += 1) { - let word = words[j]; - let tokenSearchResult = tokenSearcher.search(word); - let obj = {}; + for (var j = 0; j < words.length; j += 1) { + var word = words[j]; + var tokenSearchResult = tokenSearcher.search(word); + var obj = {}; - if (tokenSearchResult.isMatch) { - obj[word] = tokenSearchResult.score; - exists = true; - hasMatchInText = true; - scores.push(tokenSearchResult.score); - } else { - obj[word] = 1; + if (tokenSearchResult.isMatch) { + obj[word] = tokenSearchResult.score; + exists = true; + hasMatchInText = true; + scores.push(tokenSearchResult.score); + } else { + obj[word] = 1; - if (!this.options.matchAllTokens) { - scores.push(1); + if (!this.options.matchAllTokens) { + scores.push(1); + } } - } - this._log(`Token: "${word}", score: ${obj[word]}`); // tokenScores.push(obj) + this._log("Token: \"".concat(word, "\", score: ").concat(obj[word])); // tokenScores.push(obj) - } + } - if (hasMatchInText) { - numTextMatches += 1; + if (hasMatchInText) { + numTextMatches += 1; + } } - } - averageScore = scores[0]; - let scoresLen = scores.length; + averageScore = scores[0]; + var scoresLen = scores.length; - for (let i = 1; i < scoresLen; i += 1) { - averageScore += scores[i]; - } + for (var _i2 = 1; _i2 < scoresLen; _i2 += 1) { + averageScore += scores[_i2]; + } - averageScore = averageScore / scoresLen; + averageScore = averageScore / scoresLen; - this._log('Token score average:', averageScore); - } + this._log('Token score average:', averageScore); + } - let finalScore = mainSearchResult.score; + var finalScore = mainSearchResult.score; - if (averageScore > -1) { - finalScore = (finalScore + averageScore) / 2; - } + if (averageScore > -1) { + finalScore = (finalScore + averageScore) / 2; + } - this._log('Score average:', finalScore); + this._log('Score average:', finalScore); - let checkTextMatches = this.options.tokenize && this.options.matchAllTokens ? numTextMatches >= tokenSearchers.length : true; + var checkTextMatches = this.options.tokenize && this.options.matchAllTokens ? numTextMatches >= tokenSearchers.length : true; - this._log(`\nCheck Matches: ${checkTextMatches}`); // If a match is found, add the item to , including its score + this._log("\nCheck Matches: ".concat(checkTextMatches)); // If a match is found, add the item to , including its score - if ((exists || mainSearchResult.isMatch) && checkTextMatches) { - // Check if the item already exists in our results - let existingResult = resultMap[index]; + if ((exists || mainSearchResult.isMatch) && checkTextMatches) { + // Check if the item already exists in our results + var existingResult = resultMap[index]; - if (existingResult) { - // Use the lowest score - // existingResult.score, bitapResult.score - existingResult.output.push({ - key, - arrayIndex, - value, - score: finalScore, - matchedIndices: mainSearchResult.matchedIndices - }); - } else { - // Add it to the raw result list - resultMap[index] = { - item: record, - output: [{ - key, - arrayIndex, - value, + if (existingResult) { + // Use the lowest score + // existingResult.score, bitapResult.score + existingResult.output.push({ + key: key, + arrayIndex: arrayIndex, + value: value, score: finalScore, matchedIndices: mainSearchResult.matchedIndices - }] - }; - results.push(resultMap[index]); + }); + } else { + // Add it to the raw result list + resultMap[index] = { + item: record, + output: [{ + key: key, + arrayIndex: arrayIndex, + value: value, + score: finalScore, + matchedIndices: mainSearchResult.matchedIndices + }] + }; + results.push(resultMap[index]); + } + } + } else if (isArray(value)) { + for (var _i3 = 0, len = value.length; _i3 < len; _i3 += 1) { + this._analyze({ + key: key, + arrayIndex: _i3, + value: value[_i3], + record: record, + index: index + }, { + resultMap: resultMap, + results: results, + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher + }); } - } - } else if (isArray(value)) { - for (let i = 0, len = value.length; i < len; i += 1) { - this._analyze({ - key, - arrayIndex: i, - value: value[i], - record, - index - }, { - resultMap, - results, - tokenSearchers, - fullSearcher - }); } } - } - - _computeScore(weights, results) { - this._log('\n\nComputing score:\n'); - - for (let i = 0, len = results.length; i < len; i += 1) { - const output = results[i].output; - const scoreLen = output.length; - let currScore = 1; - let bestScore = 1; - - for (let j = 0; j < scoreLen; j += 1) { - let weight = weights ? weights[output[j].key].weight : 1; - let score = weight === 1 ? output[j].score : output[j].score || 0.001; - let nScore = score * weight; - - if (weight !== 1) { - bestScore = Math.min(bestScore, nScore); - } else { - output[j].nScore = nScore; - currScore *= nScore; + }, { + key: "_computeScore", + value: function _computeScore(weights, results) { + this._log('\n\nComputing score:\n'); + + for (var i = 0, len = results.length; i < len; i += 1) { + var output = results[i].output; + var scoreLen = output.length; + var currScore = 1; + var bestScore = 1; + + for (var j = 0; j < scoreLen; j += 1) { + var weight = weights ? weights[output[j].key].weight : 1; + var score = weight === 1 ? output[j].score : output[j].score || 0.001; + var nScore = score * weight; + + if (weight !== 1) { + bestScore = Math.min(bestScore, nScore); + } else { + output[j].nScore = nScore; + currScore *= nScore; + } } - } - results[i].score = bestScore === 1 ? currScore : bestScore; + results[i].score = bestScore === 1 ? currScore : bestScore; - this._log(results[i]); + this._log(results[i]); + } } - } - - _sort(results) { - this._log('\n\nSorting....'); + }, { + key: "_sort", + value: function _sort(results) { + this._log('\n\nSorting....'); - results.sort(this.options.sortFn); - } + results.sort(this.options.sortFn); + } + }, { + key: "_format", + value: function _format(results) { + var finalOutput = []; - _format(results) { - const finalOutput = []; + if (this.options.verbose) { + var cache = []; - if (this.options.verbose) { - let cache = []; + this._log('\n\nOutput:\n\n', JSON.stringify(results, function (key, value) { + if (_typeof(value) === 'object' && value !== null) { + if (cache.indexOf(value) !== -1) { + // Circular reference found, discard key + return; + } // Store value in our collection - this._log('\n\nOutput:\n\n', JSON.stringify(results, function (key, value) { - if (typeof value === 'object' && value !== null) { - if (cache.indexOf(value) !== -1) { - // Circular reference found, discard key - return; - } // Store value in our collection + cache.push(value); + } - cache.push(value); - } + return value; + })); - return value; - })); + cache = null; + } - cache = null; - } + var transformers = []; - let transformers = []; + if (this.options.includeMatches) { + transformers.push(function (result, data) { + var output = result.output; + data.matches = []; - if (this.options.includeMatches) { - transformers.push((result, data) => { - const output = result.output; - data.matches = []; + for (var i = 0, len = output.length; i < len; i += 1) { + var item = output[i]; - for (let i = 0, len = output.length; i < len; i += 1) { - let item = output[i]; + if (item.matchedIndices.length === 0) { + continue; + } - if (item.matchedIndices.length === 0) { - continue; - } + var obj = { + indices: item.matchedIndices, + value: item.value + }; - let obj = { - indices: item.matchedIndices, - value: item.value - }; + if (item.key) { + obj.key = item.key; + } - if (item.key) { - obj.key = item.key; - } + if (item.hasOwnProperty('arrayIndex') && item.arrayIndex > -1) { + obj.arrayIndex = item.arrayIndex; + } - if (item.hasOwnProperty('arrayIndex') && item.arrayIndex > -1) { - obj.arrayIndex = item.arrayIndex; + data.matches.push(obj); } + }); + } - data.matches.push(obj); - } - }); - } + if (this.options.includeScore) { + transformers.push(function (result, data) { + data.score = result.score; + }); + } - if (this.options.includeScore) { - transformers.push((result, data) => { - data.score = result.score; - }); - } + for (var i = 0, len = results.length; i < len; i += 1) { + var result = results[i]; - for (let i = 0, len = results.length; i < len; i += 1) { - const result = results[i]; + if (this.options.id) { + result.item = this.options.getFn(result.item, this.options.id)[0]; + } - if (this.options.id) { - result.item = this.options.getFn(result.item, this.options.id)[0]; - } + if (!transformers.length) { + finalOutput.push(result.item); + continue; + } - if (!transformers.length) { - finalOutput.push(result.item); - continue; - } + var data = { + item: result.item + }; - const data = { - item: result.item - }; + for (var j = 0, _len2 = transformers.length; j < _len2; j += 1) { + transformers[j](result, data); + } - for (let j = 0, len = transformers.length; j < len; j += 1) { - transformers[j](result, data); + finalOutput.push(data); } - finalOutput.push(data); + return finalOutput; } + }, { + key: "_log", + value: function _log() { + if (this.options.verbose) { + var _console; - return finalOutput; - } - - _log() { - if (this.options.verbose) { - console.log(...arguments); + (_console = console).log.apply(_console, arguments); + } } - } + }]); -} + return Fuse; +}(); module.exports = Fuse; diff --git a/dist/fuse.min.js b/dist/fuse.min.js index c60e2bd19..a058214a5 100644 --- a/dist/fuse.min.js +++ b/dist/fuse.min.js @@ -1,9 +1,9 @@ /*! - * Fuse.js v3.4.1 - Lightweight fuzzy-search (http://fusejs.io) + * Fuse.js v3.4.2 - Lightweight fuzzy-search (http://fusejs.io) * * Copyright (c) 2012-2017 Kirollos Risk (http://kiro.me) * All Rights Reserved. Apache Software License 2.0 * * http://www.apache.org/licenses/LICENSE-2.0 */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Fuse",[],t):"object"==typeof exports?exports.Fuse=t():e.Fuse=t()}(this,function(){var e=Math.min;return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(t){return e[t]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e){e.exports=(e=>Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e))},function(t,n,r){const o=r(2),s=r(8),i=r(0);t.exports=class{constructor(e,{location:t=0,distance:n=100,threshold:r=.6,maxPatternLength:o=32,caseSensitive:i=!1,tokenSeparator:l=/ +/g,findAllMatches:a=!1,minMatchCharLength:c=1,id:h=null,keys:u=[],shouldSort:p=!0,getFn:f=s,sortFn:d=((e,t)=>e.score-t.score),tokenize:g=!1,matchAllTokens:y=!1,includeMatches:m=!1,includeScore:x=!1,verbose:S=!1}){this.options={location:t,distance:n,threshold:r,maxPatternLength:o,isCaseSensitive:i,tokenSeparator:l,findAllMatches:a,minMatchCharLength:c,id:h,keys:u,includeMatches:m,includeScore:x,shouldSort:p,getFn:f,sortFn:d,verbose:S,tokenize:g,matchAllTokens:y},this.setCollection(e)}setCollection(e){return this.list=e,e}search(e,t={limit:!1}){this._log(`---------\nSearch pattern: "${e}"`);const{tokenSearchers:n,fullSearcher:r}=this._prepareSearchers(e);let{weights:o,results:s}=this._search(n,r);return this._computeScore(o,s),this.options.shouldSort&&this._sort(s),t.limit&&"number"==typeof t.limit&&(s=s.slice(0,t.limit)),this._format(s)}_prepareSearchers(e=""){const t=[];if(this.options.tokenize){const n=e.split(this.options.tokenSeparator);for(let e=0,r=n.length;e=n.weight||1 0 and <= 1");n=n.name}else s[n]={weight:1};this._analyze({key:n,value:this.options.getFn(i,n),record:i,index:l},{resultMap:r,results:o,tokenSearchers:e,fullSearcher:t})}}return{weights:s,results:o}}_analyze({key:e,arrayIndex:t=-1,value:n,record:r,index:o},{tokenSearchers:s=[],fullSearcher:l=[],resultMap:a={},results:c=[]}){if(null==n)return;let h=!1,u=-1,p=0;if("string"==typeof n){this._log(`\nKey: ${""===e?"-":e}`);let i=l.search(n);if(this._log(`Full text: "${n}", score: ${i.score}`),this.options.tokenize){let e=n.split(this.options.tokenSeparator),t=[];for(let n,r=0;r=s.length;if(this._log(`\nCheck Matches: ${d}`),(h||i.isMatch)&&d){let s=a[o];s?s.output.push({key:e,arrayIndex:t,value:n,score:f,matchedIndices:i.matchedIndices}):(a[o]={item:r,output:[{key:e,arrayIndex:t,value:n,score:f,matchedIndices:i.matchedIndices}]},c.push(a[o]))}}else if(i(n))for(let t=0,i=n.length;t{const n=e.output;t.matches=[];for(let e,r=0,o=n.length;r{t.score=e.score});for(let r=0,o=e.length;rt)return r(e,this.pattern,n);const{location:s,distance:i,threshold:l,findAllMatches:a,minMatchCharLength:c}=this.options;return o(e,this.pattern,this.patternAlphabet,{location:s,distance:i,threshold:l,findAllMatches:a,minMatchCharLength:c})}}},function(e){const t=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=((e,n,r=/ +/g)=>{let o=new RegExp(n.replace(t,"\\$&").replace(r,"|")),s=e.match(o),i=!!s,l=[];if(i)for(let t,n=0,r=s.length;n{var u=Math.max;const p=i,f=t.length;let d=a,g=t.indexOf(n,p);const y=n.length,m=[];for(let e=0;e=h;e-=1){let i=e-1,a=r[t.charAt(i)];if(a&&(m[i]=1),_[e]=(1|_[e+1]<<1)&a,0!=s&&(_[e]|=1|(x[e+1]|x[e])<<1|x[e+1]),_[e]&1<d)break;x=_}return{isMatch:0<=g,score:0===S?.001:S,matchedIndices:s(m,h)}})},function(e){e.exports=((e,{errors:t=0,currentLocation:n=0,expectedLocation:r=0,distance:o=100})=>{const s=t/e.length,i=Math.abs(r-n);return o?s+i/o:i?1:s})},function(e){e.exports=((e=[],t=1)=>{let n=[],r=-1,o=-1,s=0;for(let i,l=e.length;s=t&&n.push([r,o]),r=-1);return e[s-1]&&s-r>=t&&n.push([r,s-1]),n})},function(e){e.exports=(e=>{let t={},n=e.length;for(let r=0;r{if(t){const s=t.indexOf(".");let i=t,l=null;-1!==s&&(i=t.slice(0,s),l=t.slice(s+1));const a=e[i];if(null!=a)if(l||"string"!=typeof a&&"number"!=typeof a)if(r(a))for(let e=0,t=a.length;eo(e,t,[]))}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Fuse",[],t):"object"==typeof exports?exports.Fuse=t():e.Fuse=t()}(this,function(){var e=Math.min;return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(t){return e[t]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e){e.exports=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}},function(t,n,r){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n,r=0;r=u.weight||1 0 and <= 1");u=u.name}else c[u]={weight:1};this._analyze({key:u,value:this.options.getFn(s,u),record:s,index:h},{resultMap:r,results:o,tokenSearchers:e,fullSearcher:t})}}return{weights:c,results:o}}},{key:"_analyze",value:function(e,t){var n=e.key,r=e.arrayIndex,o=void 0===r?-1:r,i=e.value,a=e.record,s=e.index,h=t.tokenSearchers,l=void 0===h?[]:h,u=t.fullSearcher,f=void 0===u?[]:u,d=t.resultMap,p=void 0===d?{}:d,v=t.results,g=void 0===v?[]:v;if(null!=i){var y=!1,m=-1,k=0;if("string"==typeof i){this._log("\nKey: ".concat(""===n?"-":n));var S=f.search(i);if(this._log('Full text: "'.concat(i,'", score: ').concat(S.score)),this.options.tokenize){for(var x,b=i.split(this.options.tokenSeparator),M=[],_=0;_=l.length;if(this._log("\nCheck Matches: ".concat(F)),(y||S.isMatch)&&F){var T=p[s];T?T.output.push({key:n,arrayIndex:o,value:i,score:P,matchedIndices:S.matchedIndices}):(p[s]={item:a,output:[{key:n,arrayIndex:o,value:i,score:P,matchedIndices:S.matchedIndices}]},g.push(p[s]))}}else if(c(i))for(var z=0,E=i.length;zn)return o(e,this.pattern,r);var a=this.options,s=a.location,c=a.distance,h=a.threshold,l=a.findAllMatches,u=a.minMatchCharLength;return i(e,this.pattern,this.patternAlphabet,{location:s,distance:c,threshold:h,findAllMatches:l,minMatchCharLength:u})}}]),e}();e.exports=s},function(e){var t=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,n){var r=2=F;E-=1){var K=E-1,$=r[t.charAt(K)];if($&&(M[K]=1),z[E]=(1|z[E+1]<<1)&$,0!=O&&(z[E]|=1|(A[E+1]|A[E])<<1|A[E+1]),z[E]&1<S)break;A=z}return{isMatch:0<=x,score:0===C?.001:C,matchedIndices:i(M,y)}}},function(e){e.exports=function(e,t){var n=t.errors,r=void 0===n?0:n,o=t.currentLocation,i=void 0===o?0:o,a=t.expectedLocation,s=void 0===a?0:a,c=t.distance,h=void 0===c?100:c,l=r/e.length,u=Math.abs(s-i);return h?l+u/h:u?1:l}},function(e){e.exports=function(){for(var e,t=0=n&&r.push([o,i]),o=-1);return t[a-1]&&a-o>=n&&r.push([o,a-1]),r}},function(e){e.exports=function(e){for(var t={},n=e.length,r=0;r