Socket
Socket
Sign inDemoInstall

fuse.js

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuse.js - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0-alpha.0

dist/fuse.basic.common.js

1037

dist/fuse.common.js
/**
* Fuse.js v5.1.0 - Lightweight fuzzy-search (http://fusejs.io)
* Fuse.js v5.2.0-alpha.0 - Lightweight fuzzy-search (http://fusejs.io)
*

@@ -83,2 +83,112 @@ * Copyright (c) 2020 Kiro Risk (http://kiro.me)

function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (_isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function bitapScore(pattern, _ref) {

@@ -136,15 +246,139 @@ var _ref$errors = _ref.errors,

function bitapSearch(text, pattern, patternAlphabet, _ref) {
var _ref$location = _ref.location,
location = _ref$location === void 0 ? 0 : _ref$location,
var INFINITY = 1 / 0;
var isArray = function isArray(value) {
return !Array.isArray ? Object.prototype.toString.call(value) === '[object Array]' : Array.isArray(value);
}; // Adapted from:
// https://github.com/lodash/lodash/blob/f4ca396a796435422bd4fd41fadbd225edddf175/.internal/baseToString.js
var baseToString = function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
};
var toString = function toString(value) {
return value == null ? '' : baseToString(value);
};
var isString = function isString(value) {
return typeof value === 'string';
};
var isNumber = function isNumber(value) {
return typeof value === 'number';
};
var isDefined = function isDefined(value) {
return value !== undefined && value !== null;
};
function get(obj, path) {
var list = [];
var arr = false;
var _get = function _get(obj, path) {
if (!path) {
// If there's no path left, we've gotten to the object we care about.
list.push(obj);
} else {
var dotIndex = path.indexOf('.');
var key = path;
var remaining = null;
if (dotIndex !== -1) {
key = path.slice(0, dotIndex);
remaining = path.slice(dotIndex + 1);
}
var value = obj[key];
if (isDefined(value)) {
if (!remaining && (isString(value) || isNumber(value))) {
list.push(toString(value));
} else if (isArray(value)) {
arr = true; // Search each item in the array.
for (var i = 0, len = value.length; i < len; i += 1) {
_get(value[i], remaining);
}
} else if (remaining) {
// An object. Recurse further.
_get(value, remaining);
}
}
}
};
_get(obj, path);
if (arr) {
return list;
}
return list[0];
}
var MatchOptions = {
// Whether the matches should be included in the result set. When true, each record in the result
// set will include the indices of the matched characters.
// These can consequently be used for highlighting purposes.
includeMatches: false,
// When true, the matching function will continue to the end of a search pattern even if
// a perfect match has already been located in the string.
findAllMatches: false,
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1
};
var BasicOptions = {
// 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.
isCaseSensitive: false,
// When true, the matching function will continue to the end of a search pattern even if
includeScore: false,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Whether to sort the result list, by score
shouldSort: true,
// Default sort function
sortFn: function sortFn(a, b) {
return a.score - b.score;
}
};
var FuzzyOptions = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// 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,
// 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
};
var AdvancedOptions = {
// When true, it enables the use of unix-like search commands
useExtendedSearch: false,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: get
};
var Config = _objectSpread2({}, BasicOptions, {}, MatchOptions, {}, FuzzyOptions, {}, AdvancedOptions);
function bitapSearch(text, pattern, patternAlphabet) {
var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
_ref$location = _ref.location,
location = _ref$location === void 0 ? Config.location : _ref$location,
_ref$distance = _ref.distance,
distance = _ref$distance === void 0 ? 100 : _ref$distance,
distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
_ref$threshold = _ref.threshold,
threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold,
threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
_ref$findAllMatches = _ref.findAllMatches,
findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches,
findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
_ref$minMatchCharLeng = _ref.minMatchCharLength,
minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng,
minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
_ref$includeMatches = _ref.includeMatches,
includeMatches = _ref$includeMatches === void 0 ? false : _ref$includeMatches;
includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches;
var patternLen = pattern.length; // Set starting location at beginning text and initialize the alphabet.

@@ -314,29 +548,10 @@

var BitapSearch = /*#__PURE__*/function () {
function BitapSearch(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$isCaseSensitive = _ref.isCaseSensitive,
isCaseSensitive = _ref$isCaseSensitive === void 0 ? false : _ref$isCaseSensitive,
_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$includeMatches = _ref.includeMatches,
includeMatches = _ref$includeMatches === void 0 ? false : _ref$includeMatches;
function BitapSearch(pattern) {
var _ref, _ref$location, _ref$threshold, _ref$distance, _ref$includeMatches, _ref$findAllMatches, _ref$minMatchCharLeng, _ref$isCaseSensitive;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$location = _ref.location, location = _ref$location === void 0 ? Config.location : _ref$location, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref$distance = _ref.distance, distance = _ref$distance === void 0 ? Config.distance : _ref$distance, _ref$includeMatches = _ref.includeMatches, includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches, _ref$findAllMatches = _ref.findAllMatches, findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches, _ref$minMatchCharLeng = _ref.minMatchCharLength, minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng, _ref$isCaseSensitive = _ref.isCaseSensitive, isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive, _ref);
_classCallCheck(this, BitapSearch);
this.options = {
location: location,
distance: distance,
threshold: threshold,
isCaseSensitive: isCaseSensitive,
findAllMatches: findAllMatches,
includeMatches: includeMatches,
minMatchCharLength: minMatchCharLength
};
this.options = options;

@@ -347,3 +562,3 @@ if (pattern.length > MAX_BITS) {

this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
this.pattern = this.options.isCaseSensitive ? pattern : pattern.toLowerCase();
this.patternAlphabet = patternAlphabet(this.pattern);

@@ -404,195 +619,380 @@ }

// Token: 'file
// Match type: exact-match
// Description: Items that include `file`
var isForPattern = function isForPattern(pattern) {
return pattern.charAt(0) == "'";
};
var Match = /*#__PURE__*/function () {
function Match(pattern) {
_classCallCheck(this, Match);
var sanitize = function sanitize(pattern) {
return pattern.substr(1);
};
this.pattern = pattern;
}
var match = function match(pattern, text) {
var sanitizedPattern = sanitize(pattern);
var index = text.indexOf(sanitizedPattern);
var isMatch = index > -1;
return {
isMatch: isMatch,
score: 0
};
};
_createClass(Match, [{
key: "search",
value: function search()
/*text*/
{}
}], [{
key: "isLiteralMatch",
value: function isLiteralMatch(pattern) {
return getMatch(pattern, this.literal);
}
}, {
key: "isRegMatch",
value: function isRegMatch(pattern) {
return getMatch(pattern, this.re);
}
}]);
var exactMatch = {
isForPattern: isForPattern,
sanitize: sanitize,
match: match
};
return Match;
}();
// Token: !fire
// Match type: inverse-exact-match
// Description: Items that do not include `fire`
var isForPattern$1 = function isForPattern(pattern) {
return pattern.charAt(0) == '!';
};
function getMatch(pattern, exp) {
var matches = pattern.match(exp);
return matches ? matches[1] : null;
}
var sanitize$1 = function sanitize(pattern) {
return pattern.substr(1);
};
var ExactMatch = /*#__PURE__*/function (_Match) {
_inherits(ExactMatch, _Match);
var match$1 = function match(pattern, text) {
var sanitizedPattern = sanitize$1(pattern);
var isMatch = text.indexOf(sanitizedPattern) === -1;
return {
isMatch: isMatch,
score: 0
};
};
var _super = _createSuper(ExactMatch);
var inverseExactMatch = {
isForPattern: isForPattern$1,
sanitize: sanitize$1,
match: match$1
};
function ExactMatch(pattern) {
_classCallCheck(this, ExactMatch);
// Token: ^file
// Match type: prefix-exact-match
// Description: Items that start with `file`
var isForPattern$2 = function isForPattern(pattern) {
return pattern.charAt(0) == '^';
};
return _super.call(this, pattern);
}
var sanitize$2 = function sanitize(pattern) {
return pattern.substr(1);
};
_createClass(ExactMatch, [{
key: "search",
value: function search(text) {
var index = text.indexOf(this.pattern);
var isMatch = index > -1;
return {
isMatch: isMatch,
score: isMatch ? 1 : 0,
matchedIndices: [index, index + this.pattern.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'exact';
}
}, {
key: "literal",
get: function get() {
return /^'"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^'(.*)$/;
}
}]);
var match$2 = function match(pattern, text) {
var sanitizedPattern = sanitize$2(pattern);
var isMatch = text.startsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
return ExactMatch;
}(Match);
var prefixExactMatch = {
isForPattern: isForPattern$2,
sanitize: sanitize$2,
match: match$2
};
var InverseExactMatch = /*#__PURE__*/function (_Match) {
_inherits(InverseExactMatch, _Match);
// Token: !^fire
// Match type: inverse-prefix-exact-match
// Description: Items that do not start with `fire`
var isForPattern$3 = function isForPattern(pattern) {
return pattern.charAt(0) == '!' && pattern.charAt(1) == '^';
};
var _super = _createSuper(InverseExactMatch);
var sanitize$3 = function sanitize(pattern) {
return pattern.substr(2);
};
function InverseExactMatch(pattern) {
_classCallCheck(this, InverseExactMatch);
var match$3 = function match(pattern, text) {
var sanitizedPattern = sanitize$3(pattern);
var isMatch = !text.startsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
return _super.call(this, pattern);
}
var inversePrefixExactMatch = {
isForPattern: isForPattern$3,
sanitize: sanitize$3,
match: match$3
};
_createClass(InverseExactMatch, [{
key: "search",
value: function search(text) {
var index = text.indexOf(this.pattern);
var isMatch = index === -1;
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'inverse-exact';
}
}, {
key: "literal",
get: function get() {
return /^!"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^!(.*)$/;
}
}]);
// Token: .file$
// Match type: suffix-exact-match
// Description: Items that end with `.file`
var isForPattern$4 = function isForPattern(pattern) {
return pattern.charAt(pattern.length - 1) == '$';
};
return InverseExactMatch;
}(Match);
var sanitize$4 = function sanitize(pattern) {
return pattern.substr(0, pattern.length - 1);
};
var PrefixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(PrefixExactMatch, _Match);
var match$4 = function match(pattern, text) {
var sanitizedPattern = sanitize$4(pattern);
var isMatch = text.endsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
var _super = _createSuper(PrefixExactMatch);
var suffixExactMatch = {
isForPattern: isForPattern$4,
sanitize: sanitize$4,
match: match$4
};
function PrefixExactMatch(pattern) {
_classCallCheck(this, PrefixExactMatch);
// Token: !.file$
// Match type: inverse-suffix-exact-match
// Description: Items that do not end with `.file`
var isForPattern$5 = function isForPattern(pattern) {
return pattern.charAt(0) == '!' && pattern.charAt(pattern.length - 1) == '$';
};
return _super.call(this, pattern);
}
var sanitize$5 = function sanitize(pattern) {
return pattern.substring(1, pattern.length - 1);
};
_createClass(PrefixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = text.startsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, this.pattern.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'prefix-exact';
}
}, {
key: "literal",
get: function get() {
return /^\^"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^\^(.*)$/;
}
}]);
var match$5 = function match(pattern, text) {
var sanitizedPattern = sanitize$5(pattern);
var isMatch = !text.endsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
return PrefixExactMatch;
}(Match);
var inverseSuffixExactMatch = {
isForPattern: isForPattern$5,
sanitize: sanitize$5,
match: match$5
};
var InversePrefixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(InversePrefixExactMatch, _Match);
var INFINITY = 1 / 0;
var isArray = function isArray(value) {
return !Array.isArray ? Object.prototype.toString.call(value) === '[object Array]' : Array.isArray(value);
}; // Adapted from:
// https://github.com/lodash/lodash/blob/f4ca396a796435422bd4fd41fadbd225edddf175/.internal/baseToString.js
var _super = _createSuper(InversePrefixExactMatch);
var baseToString = function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
function InversePrefixExactMatch(pattern) {
_classCallCheck(this, InversePrefixExactMatch);
return _super.call(this, pattern);
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
};
var toString = function toString(value) {
return value == null ? '' : baseToString(value);
};
var isString = function isString(value) {
return typeof value === 'string';
};
var isNumber = function isNumber(value) {
return typeof value === 'number';
};
var isDefined = function isDefined(value) {
return value !== undefined && value !== null;
};
_createClass(InversePrefixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = !text.startsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'inverse-prefix-exact';
}
}, {
key: "literal",
get: function get() {
return /^!\^"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^!\^(.*)$/;
}
}]);
return InversePrefixExactMatch;
}(Match);
var SuffixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(SuffixExactMatch, _Match);
var _super = _createSuper(SuffixExactMatch);
function SuffixExactMatch(pattern) {
_classCallCheck(this, SuffixExactMatch);
return _super.call(this, pattern);
}
_createClass(SuffixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = text.endsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [text.length - this.pattern.length, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'suffix-exact';
}
}, {
key: "literal",
get: function get() {
return /^"(.*)"\$$/;
}
}, {
key: "re",
get: function get() {
return /^(.*)\$$/;
}
}]);
return SuffixExactMatch;
}(Match);
var InverseSuffixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(InverseSuffixExactMatch, _Match);
var _super = _createSuper(InverseSuffixExactMatch);
function InverseSuffixExactMatch(pattern) {
_classCallCheck(this, InverseSuffixExactMatch);
return _super.call(this, pattern);
}
_createClass(InverseSuffixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = !text.endsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'inverse-suffix-exact';
}
}, {
key: "literal",
get: function get() {
return /^!"(.*)"\$$/;
}
}, {
key: "re",
get: function get() {
return /^!(.*)\$$/;
}
}]);
return InverseSuffixExactMatch;
}(Match);
var FuzzyMatch = /*#__PURE__*/function (_Match) {
_inherits(FuzzyMatch, _Match);
var _super = _createSuper(FuzzyMatch);
function FuzzyMatch(pattern) {
var _ref, _ref$location, _ref$threshold, _ref$distance, _ref$includeMatches, _ref$findAllMatches, _ref$minMatchCharLeng, _ref$isCaseSensitive;
var _this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$location = _ref.location, location = _ref$location === void 0 ? Config.location : _ref$location, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref$distance = _ref.distance, distance = _ref$distance === void 0 ? Config.distance : _ref$distance, _ref$includeMatches = _ref.includeMatches, includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches, _ref$findAllMatches = _ref.findAllMatches, findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches, _ref$minMatchCharLeng = _ref.minMatchCharLength, minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng, _ref$isCaseSensitive = _ref.isCaseSensitive, isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive, _ref);
_classCallCheck(this, FuzzyMatch);
_this = _super.call(this, pattern);
_this._bitapSearch = new BitapSearch(pattern, options);
return _this;
}
_createClass(FuzzyMatch, [{
key: "search",
value: function search(text) {
return this._bitapSearch.searchInString(text);
}
}], [{
key: "type",
get: function get() {
return 'fuzzy';
}
}, {
key: "literal",
get: function get() {
return /^"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^(.*)$/;
}
}]);
return FuzzyMatch;
}(Match);
var searchers = [ExactMatch, PrefixExactMatch, InversePrefixExactMatch, InverseSuffixExactMatch, SuffixExactMatch, InverseExactMatch, FuzzyMatch];
var searchersLen = searchers.length; // Regex to split by spaces, but keep anything in quotes together
var SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;
var OR_TOKEN = '|'; // Return a 2D array representation of the query, for simpler parsing.
// Example:
// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
var queryfy = function queryfy(pattern) {
return pattern.split('|').map(function (item) {
return item.trim().split(/ +/g);
function parseQuery(pattern, options) {
return pattern.split(OR_TOKEN).map(function (item) {
var query = item.trim().split(SPACE_RE).filter(function (item) {
return item && !!item.trim();
});
var results = [];
for (var i = 0, len = query.length; i < len; i += 1) {
var queryItem = query[i]; // 1. Handle literal queries (i.e, once that are quotes "hello world")
var found = false;
var idx = -1;
while (!found && ++idx < searchersLen) {
var searcher = searchers[idx];
var token = searcher.isLiteralMatch(queryItem);
if (token) {
results.push(new searcher(token, options));
found = true;
}
}
if (found) {
continue;
} // 2. Handle regular queries
idx = -1;
while (++idx < searchersLen) {
var _searcher = searchers[idx];
var _token = _searcher.isRegMatch(queryItem);
if (_token) {
results.push(new _searcher(_token, options));
break;
}
}
}
return results;
});
};
}
/**

@@ -626,17 +1026,14 @@ * Command-like searching

var ExtendedSearch = /*#__PURE__*/function () {
function ExtendedSearch(pattern) {
var _ref, _ref$isCaseSensitive, _ref$includeMatches, _ref$minMatchCharLeng, _ref$findAllMatches, _ref$location, _ref$threshold, _ref$distance, _ref$includeMatches2;
var ExtendedSearch = /*#__PURE__*/function () {
function ExtendedSearch(pattern, options) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$isCaseSensitive = _ref.isCaseSensitive, isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive, _ref$includeMatches = _ref.includeMatches, includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches, _ref$minMatchCharLeng = _ref.minMatchCharLength, minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng, _ref$findAllMatches = _ref.findAllMatches, findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches, _ref$location = _ref.location, location = _ref$location === void 0 ? Config.location : _ref$location, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref$distance = _ref.distance, distance = _ref$distance === void 0 ? Config.distance : _ref$distance, _ref$includeMatches2 = _ref.includeMatches, includeMatches = _ref$includeMatches2 === void 0 ? Config.includeMatches : _ref$includeMatches2, _ref);
_classCallCheck(this, ExtendedSearch);
var isCaseSensitive = options.isCaseSensitive;
this.query = null;
this.options = options; // A <pattern>:<BitapSearch> key-value pair for optimizing searching
this._fuzzyCache = {};
if (isString(pattern) && pattern.trim().length > 0) {
this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
this.query = queryfy(this.pattern);
}
this.options = options;
this.pattern = options.isCaseSensitive ? pattern : pattern.toLowerCase();
this.query = parseQuery(this.pattern, options);
}

@@ -649,3 +1046,3 @@

if (!this.query) {
if (!query) {
return {

@@ -658,17 +1055,36 @@ isMatch: false,

var text = value.$;
text = this.options.isCaseSensitive ? text : text.toLowerCase();
var matchFound = false;
var _this$options = this.options,
includeMatches = _this$options.includeMatches,
isCaseSensitive = _this$options.isCaseSensitive;
text = isCaseSensitive ? text : text.toLowerCase();
var numMatches = 0;
var indices = []; // ORs
for (var i = 0, qLen = query.length; i < qLen; i += 1) {
var parts = query[i];
var result = null;
matchFound = true;
var searchers = query[i]; // Reset indices
for (var j = 0, pLen = parts.length; j < pLen; j += 1) {
var token = parts[j];
result = this._search(token, text);
indices.length = 0;
numMatches = 0; // ANDs
if (!result.isMatch) {
// AND condition, short-circuit and move on to next part
matchFound = false;
for (var j = 0, pLen = searchers.length; j < pLen; j += 1) {
var searcher = searchers[j];
var _searcher$search = searcher.search(text),
isMatch = _searcher$search.isMatch,
matchedIndices = _searcher$search.matchedIndices;
if (isMatch) {
numMatches += 1;
if (includeMatches) {
if (searcher.constructor.type === FuzzyMatch.type) {
// FuzzyMatch returns is a 2D array
indices = [].concat(_toConsumableArray(indices), _toConsumableArray(matchedIndices));
} else {
indices.push(matchedIndices);
}
}
} else {
numMatches = 0;
indices.length = 0;
break;

@@ -679,3 +1095,12 @@ }

if (matchFound) {
if (numMatches) {
var result = {
isMatch: true,
score: 0
};
if (includeMatches) {
result.matchedIndices = indices;
}
return result;

@@ -691,27 +1116,6 @@ }

}
}, {
key: "_search",
value: function _search(pattern, text) {
if (exactMatch.isForPattern(pattern)) {
return exactMatch.match(pattern, text);
} else if (prefixExactMatch.isForPattern(pattern)) {
return prefixExactMatch.match(pattern, text);
} else if (inversePrefixExactMatch.isForPattern(pattern)) {
return inversePrefixExactMatch.match(pattern, text);
} else if (inverseSuffixExactMatch.isForPattern(pattern)) {
return inverseSuffixExactMatch.match(pattern, text);
} else if (suffixExactMatch.isForPattern(pattern)) {
return suffixExactMatch.match(pattern, text);
} else if (inverseExactMatch.isForPattern(pattern)) {
return inverseExactMatch.match(pattern, text);
} else {
var searcher = this._fuzzyCache[pattern];
if (!searcher) {
searcher = new BitapSearch(pattern, this.options);
this._fuzzyCache[pattern] = searcher;
}
return searcher.searchInString(text);
}
}], [{
key: "condition",
value: function condition(_, options) {
return options.useExtendedSearch;
}

@@ -833,6 +1237,6 @@ }]);

function NGramSearch(pattern) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
threshold: 0.6
};
var _ref, _ref$threshold;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref);
_classCallCheck(this, NGramSearch);

@@ -866,2 +1270,7 @@

}
}], [{
key: "condition",
value: function condition(pattern) {
return pattern.length > MAX_BITS;
}
}]);

@@ -872,48 +1281,2 @@

function get(obj, path) {
var list = [];
var arr = false;
var _get = function _get(obj, path) {
if (!path) {
// If there's no path left, we've gotten to the object we care about.
list.push(obj);
} else {
var dotIndex = path.indexOf('.');
var key = path;
var remaining = null;
if (dotIndex !== -1) {
key = path.slice(0, dotIndex);
remaining = path.slice(dotIndex + 1);
}
var value = obj[key];
if (isDefined(value)) {
if (!remaining && (isString(value) || isNumber(value))) {
list.push(toString(value));
} else if (isArray(value)) {
arr = true; // Search each item in the array.
for (var i = 0, len = value.length; i < len; i += 1) {
_get(value[i], remaining);
}
} else if (remaining) {
// An object. Recurse further.
_get(value, remaining);
}
}
}
};
_get(obj, path);
if (arr) {
return list;
}
return list[0];
}
function createIndex(keys, list) {

@@ -1156,47 +1519,7 @@ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},

var BasicOptions = {
// 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.
isCaseSensitive: false,
// Minimum number of characters that must be matched before a result is considered a match
findAllMatches: false,
includeMatches: false,
includeScore: false,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1,
// Whether to sort the result list, by score
shouldSort: true,
// Default sort function
sortFn: function sortFn(a, b) {
return a.score - b.score;
}
};
var FuzzyOptions = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// 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,
// 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
};
var AdvancedOptions = {
// Enabled extended-searching
useExtendedSearch: false,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: get
};
var registeredSearchers = [];
var defaultOptions = _objectSpread2({}, BasicOptions, {}, FuzzyOptions, {}, AdvancedOptions);
var Fuse = /*#__PURE__*/function () {
function Fuse(list) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

@@ -1206,7 +1529,4 @@

this.options = _objectSpread2({}, defaultOptions, {}, options); // `caseSensitive` is deprecated, use `isCaseSensitive` instead
this.options = _objectSpread2({}, Config, {}, options);
this.options.isCaseSensitive = options.caseSensitive;
delete this.options.caseSensitive;
this._processKeys(this.options.keys);

@@ -1253,12 +1573,15 @@

};
var _this$options = this.options,
useExtendedSearch = _this$options.useExtendedSearch,
shouldSort = _this$options.shouldSort;
var shouldSort = this.options.shouldSort;
var searcher = null;
if (useExtendedSearch) {
searcher = new ExtendedSearch(pattern, this.options);
} else if (pattern.length > MAX_BITS) {
searcher = new NGramSearch(pattern, this.options);
} else {
for (var i = 0, len = registeredSearchers.length; i < len; i += 1) {
var searcherClass = registeredSearchers[i];
if (searcherClass.condition(pattern, this.options)) {
searcher = new searcherClass(pattern, this.options);
break;
}
}
if (!searcher) {
searcher = new BitapSearch(pattern, this.options);

@@ -1449,8 +1772,8 @@ }

var finalOutput = [];
var _this$options2 = this.options,
includeMatches = _this$options2.includeMatches,
includeScore = _this$options2.includeScore;
var _this$options = this.options,
includeMatches = _this$options.includeMatches,
includeScore = _this$options.includeScore;
var transformers = [];
if (includeMatches) { transformers.push(transformMatches); }
if (includeScore) { transformers.push(transformScore); }
if (includeMatches) transformers.push(transformMatches);
if (includeScore) transformers.push(transformScore);

@@ -1476,2 +1799,7 @@ for (var i = 0, len = results.length; i < len; i += 1) {

}
}], [{
key: "register",
value: function register() {
registeredSearchers.push.apply(registeredSearchers, arguments);
}
}]);

@@ -1482,6 +1810,7 @@

Fuse.version = '5.1.0';
Fuse.register(ExtendedSearch, NGramSearch);
Fuse.version = '5.2.0-alpha.0';
Fuse.createIndex = createIndex;
Fuse.defaultOptions = defaultOptions;
Fuse.config = Config;
module.exports = Fuse;

@@ -1,2 +0,2 @@

// Type definitions for Fuse.js v5.1.0
// Type definitions for Fuse.js v5.2.0-alpha.0
// TypeScript v3.8.3

@@ -3,0 +3,0 @@

/**
* Fuse.js v5.1.0 - Lightweight fuzzy-search (http://fusejs.io)
* Fuse.js v5.2.0-alpha.0 - Lightweight fuzzy-search (http://fusejs.io)
*

@@ -52,2 +52,130 @@ * Copyright (c) 2020 Kiro Risk (http://kiro.me)

const INFINITY = 1 / 0;
const isArray = (value) =>
!Array.isArray
? Object.prototype.toString.call(value) === '[object Array]'
: Array.isArray(value);
// Adapted from:
// https://github.com/lodash/lodash/blob/f4ca396a796435422bd4fd41fadbd225edddf175/.internal/baseToString.js
const baseToString = (value) => {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value
}
let result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result
};
const toString = (value) => (value == null ? '' : baseToString(value));
const isString = (value) => typeof value === 'string';
const isNumber = (value) => typeof value === 'number';
const isDefined = (value) => value !== undefined && value !== null;
function get(obj, path) {
let list = [];
let arr = false;
const _get = (obj, path) => {
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 key = path;
let remaining = null;
if (dotIndex !== -1) {
key = path.slice(0, dotIndex);
remaining = path.slice(dotIndex + 1);
}
const value = obj[key];
if (isDefined(value)) {
if (!remaining && (isString(value) || isNumber(value))) {
list.push(toString(value));
} else if (isArray(value)) {
arr = true;
// Search each item in the array.
for (let i = 0, len = value.length; i < len; i += 1) {
_get(value[i], remaining);
}
} else if (remaining) {
// An object. Recurse further.
_get(value, remaining);
}
}
}
};
_get(obj, path);
if (arr) {
return list
}
return list[0]
}
const MatchOptions = {
// Whether the matches should be included in the result set. When true, each record in the result
// set will include the indices of the matched characters.
// These can consequently be used for highlighting purposes.
includeMatches: false,
// When true, the matching function will continue to the end of a search pattern even if
// a perfect match has already been located in the string.
findAllMatches: false,
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1
};
const BasicOptions = {
// 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.
isCaseSensitive: false,
// When true, the matching function will continue to the end of a search pattern even if
includeScore: false,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Whether to sort the result list, by score
shouldSort: true,
// Default sort function
sortFn: (a, b) => a.score - b.score
};
const FuzzyOptions = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// 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,
// 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
};
const AdvancedOptions = {
// When true, it enables the use of unix-like search commands
useExtendedSearch: false,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: get
};
var Config = {
...BasicOptions,
...MatchOptions,
...FuzzyOptions,
...AdvancedOptions
};
function bitapSearch(

@@ -58,9 +186,9 @@ text,

{
location = 0,
distance = 100,
threshold = 0.6,
findAllMatches = false,
minMatchCharLength = 1,
includeMatches = false
}
location = Config.location,
distance = Config.distance,
threshold = Config.threshold,
findAllMatches = Config.findAllMatches,
minMatchCharLength = Config.minMatchCharLength,
includeMatches = Config.includeMatches
} = {}
) {

@@ -244,34 +372,20 @@ const patternLen = pattern.length;

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,
// Indicates whether comparisons should be case sensitive.
isCaseSensitive = false,
// 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,
// Deconstructed in this fashion purely for speed-up, since a new instance
// of this class is created every time a pattern is created. Otherwise, a spread
// operation would be performed directly withing the contructor, which may slow
// done searches.
includeMatches = false
}
options = ({
/*eslint-disable no-undef*/
location = Config.location,
threshold = Config.threshold,
distance = Config.distance,
includeMatches = Config.includeMatches,
findAllMatches = Config.findAllMatches,
minMatchCharLength = Config.minMatchCharLength,
isCaseSensitive = Config.isCaseSensitive
/*eslint-enable no-undef*/
} = {})
) {
this.options = {
location,
distance,
threshold,
isCaseSensitive,
findAllMatches,
includeMatches,
minMatchCharLength
};
this.options = options;

@@ -282,3 +396,5 @@ if (pattern.length > MAX_BITS) {

this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
this.pattern = this.options.isCaseSensitive
? pattern
: pattern.toLowerCase();
this.patternAlphabet = patternAlphabet(this.pattern);

@@ -332,181 +448,271 @@ }

// Token: 'file
// Match type: exact-match
// Description: Items that include `file`
class Match {
constructor(pattern) {
this.pattern = pattern;
}
static isLiteralMatch(pattern) {
return getMatch(pattern, this.literal)
}
static isRegMatch(pattern) {
return getMatch(pattern, this.re)
}
search(/*text*/) {}
}
const isForPattern = (pattern) => pattern.charAt(0) == "'";
function getMatch(pattern, exp) {
const matches = pattern.match(exp);
return matches ? matches[1] : null
}
const sanitize = (pattern) => pattern.substr(1);
// Token: 'file
const match = (pattern, text) => {
const sanitizedPattern = sanitize(pattern);
const index = text.indexOf(sanitizedPattern);
const isMatch = index > -1;
class ExactMatch extends Match {
constructor(pattern) {
super(pattern);
}
static get type() {
return 'exact'
}
static get literal() {
return /^'"(.*)"$/
}
static get re() {
return /^'(.*)$/
}
search(text) {
const index = text.indexOf(this.pattern);
const isMatch = index > -1;
return {
isMatch,
score: 0
return {
isMatch,
score: isMatch ? 1 : 0,
matchedIndices: [index, index + this.pattern.length - 1]
}
}
};
}
var exactMatch = {
isForPattern,
sanitize,
match
};
// Token: !fire
// Match type: inverse-exact-match
// Description: Items that do not include `fire`
const isForPattern$1 = (pattern) => pattern.charAt(0) == '!';
class InverseExactMatch extends Match {
constructor(pattern) {
super(pattern);
}
static get type() {
return 'inverse-exact'
}
static get literal() {
return /^!"(.*)"$/
}
static get re() {
return /^!(.*)$/
}
search(text) {
const index = text.indexOf(this.pattern);
const isMatch = index === -1;
const sanitize$1 = (pattern) => pattern.substr(1);
const match$1 = (pattern, text) => {
const sanitizedPattern = sanitize$1(pattern);
const isMatch = text.indexOf(sanitizedPattern) === -1;
return {
isMatch,
score: 0
return {
isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
}
}
};
}
var inverseExactMatch = {
isForPattern: isForPattern$1,
sanitize: sanitize$1,
match: match$1
};
// Token: ^file
// Match type: prefix-exact-match
// Description: Items that start with `file`
const isForPattern$2 = (pattern) => pattern.charAt(0) == '^';
class PrefixExactMatch extends Match {
constructor(pattern) {
super(pattern);
}
static get type() {
return 'prefix-exact'
}
static get literal() {
return /^\^"(.*)"$/
}
static get re() {
return /^\^(.*)$/
}
search(text) {
const isMatch = text.startsWith(this.pattern);
const sanitize$2 = (pattern) => pattern.substr(1);
const match$2 = (pattern, text) => {
const sanitizedPattern = sanitize$2(pattern);
const isMatch = text.startsWith(sanitizedPattern);
return {
isMatch,
score: 0
return {
isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, this.pattern.length - 1]
}
}
};
}
var prefixExactMatch = {
isForPattern: isForPattern$2,
sanitize: sanitize$2,
match: match$2
};
// Token: !^fire
// Match type: inverse-prefix-exact-match
// Description: Items that do not start with `fire`
const isForPattern$3 = (pattern) =>
pattern.charAt(0) == '!' && pattern.charAt(1) == '^';
class InversePrefixExactMatch extends Match {
constructor(pattern) {
super(pattern);
}
static get type() {
return 'inverse-prefix-exact'
}
static get literal() {
return /^!\^"(.*)"$/
}
static get re() {
return /^!\^(.*)$/
}
search(text) {
const isMatch = !text.startsWith(this.pattern);
const sanitize$3 = (pattern) => pattern.substr(2);
const match$3 = (pattern, text) => {
const sanitizedPattern = sanitize$3(pattern);
const isMatch = !text.startsWith(sanitizedPattern);
return {
isMatch,
score: 0
return {
isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
}
}
};
}
var inversePrefixExactMatch = {
isForPattern: isForPattern$3,
sanitize: sanitize$3,
match: match$3
};
// Token: .file$
// Match type: suffix-exact-match
// Description: Items that end with `.file`
const isForPattern$4 = (pattern) => pattern.charAt(pattern.length - 1) == '$';
class SuffixExactMatch extends Match {
constructor(pattern) {
super(pattern);
}
static get type() {
return 'suffix-exact'
}
static get literal() {
return /^"(.*)"\$$/
}
static get re() {
return /^(.*)\$$/
}
search(text) {
const isMatch = text.endsWith(this.pattern);
const sanitize$4 = (pattern) => pattern.substr(0, pattern.length - 1);
const match$4 = (pattern, text) => {
const sanitizedPattern = sanitize$4(pattern);
const isMatch = text.endsWith(sanitizedPattern);
return {
isMatch,
score: 0
return {
isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [text.length - this.pattern.length, text.length - 1]
}
}
};
}
var suffixExactMatch = {
isForPattern: isForPattern$4,
sanitize: sanitize$4,
match: match$4
};
// Token: !.file$
// Match type: inverse-suffix-exact-match
// Description: Items that do not end with `.file`
const isForPattern$5 = (pattern) =>
pattern.charAt(0) == '!' && pattern.charAt(pattern.length - 1) == '$';
class InverseSuffixExactMatch extends Match {
constructor(pattern) {
super(pattern);
}
static get type() {
return 'inverse-suffix-exact'
}
static get literal() {
return /^!"(.*)"\$$/
}
static get re() {
return /^!(.*)\$$/
}
search(text) {
const isMatch = !text.endsWith(this.pattern);
return {
isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
}
}
}
const sanitize$5 = (pattern) => pattern.substring(1, pattern.length - 1);
const match$5 = (pattern, text) => {
const sanitizedPattern = sanitize$5(pattern);
const isMatch = !text.endsWith(sanitizedPattern);
return {
isMatch,
score: 0
class FuzzyMatch extends Match {
constructor(
pattern,
options = ({
/*eslint-disable no-undef*/
location = Config.location,
threshold = Config.threshold,
distance = Config.distance,
includeMatches = Config.includeMatches,
findAllMatches = Config.findAllMatches,
minMatchCharLength = Config.minMatchCharLength,
isCaseSensitive = Config.isCaseSensitive
/*eslint-enable no-undef*/
} = {})
) {
super(pattern);
this._bitapSearch = new BitapSearch(pattern, options);
}
};
static get type() {
return 'fuzzy'
}
static get literal() {
return /^"(.*)"$/
}
static get re() {
return /^(.*)$/
}
search(text) {
return this._bitapSearch.searchInString(text)
}
}
var inverseSuffixExactMatch = {
isForPattern: isForPattern$5,
sanitize: sanitize$5,
match: match$5
};
// ❗Order is important. DO NOT CHANGE.
const searchers = [
ExactMatch,
PrefixExactMatch,
InversePrefixExactMatch,
InverseSuffixExactMatch,
SuffixExactMatch,
InverseExactMatch,
FuzzyMatch
];
const searchersLen = searchers.length;
const INFINITY = 1 / 0;
// Regex to split by spaces, but keep anything in quotes together
const SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;
const OR_TOKEN = '|';
const isArray = (value) =>
!Array.isArray
? Object.prototype.toString.call(value) === '[object Array]'
: Array.isArray(value);
// Return a 2D array representation of the query, for simpler parsing.
// Example:
// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
function parseQuery(pattern, options) {
return pattern.split(OR_TOKEN).map((item) => {
let query = item
.trim()
.split(SPACE_RE)
.filter((item) => item && !!item.trim());
// Adapted from:
// https://github.com/lodash/lodash/blob/f4ca396a796435422bd4fd41fadbd225edddf175/.internal/baseToString.js
const baseToString = (value) => {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value
}
let result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result
};
let results = [];
for (let i = 0, len = query.length; i < len; i += 1) {
const queryItem = query[i];
const toString = (value) => (value == null ? '' : baseToString(value));
// 1. Handle literal queries (i.e, once that are quotes "hello world")
let found = false;
let idx = -1;
while (!found && ++idx < searchersLen) {
const searcher = searchers[idx];
let token = searcher.isLiteralMatch(queryItem);
if (token) {
results.push(new searcher(token, options));
found = true;
}
}
const isString = (value) => typeof value === 'string';
if (found) {
continue
}
const isNumber = (value) => typeof value === 'number';
// 2. Handle regular queries
idx = -1;
while (++idx < searchersLen) {
const searcher = searchers[idx];
let token = searcher.isRegMatch(queryItem);
if (token) {
results.push(new searcher(token, options));
break
}
}
}
const isDefined = (value) => value !== undefined && value !== null;
return results
})
}
// Return a 2D array representation of the query, for simpler parsing.
// Example:
// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
const queryfy = (pattern) =>
pattern.split('|').map((item) => item.trim().split(/ +/g));
/**

@@ -540,19 +746,32 @@ * Command-like searching

class ExtendedSearch {
constructor(pattern, options) {
const { isCaseSensitive } = options;
constructor(
pattern,
options = ({
/*eslint-disable no-undef*/
isCaseSensitive = Config.isCaseSensitive,
includeMatches = Config.includeMatches,
minMatchCharLength = Config.minMatchCharLength,
findAllMatches = Config.findAllMatches,
location = Config.location,
threshold = Config.threshold,
distance = Config.distance,
includeMatches = Config.includeMatches
/*eslint-enable no-undef*/
} = {})
) {
this.query = null;
this.options = options;
// A <pattern>:<BitapSearch> key-value pair for optimizing searching
this._fuzzyCache = {};
if (isString(pattern) && pattern.trim().length > 0) {
this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
this.query = queryfy(this.pattern);
}
this.pattern = options.isCaseSensitive ? pattern : pattern.toLowerCase();
this.query = parseQuery(this.pattern, options);
}
static condition(_, options) {
return options.useExtendedSearch
}
searchIn(value) {
const query = this.query;
if (!this.query) {
if (!query) {
return {

@@ -566,17 +785,35 @@ isMatch: false,

text = this.options.isCaseSensitive ? text : text.toLowerCase();
const { includeMatches, isCaseSensitive } = this.options;
let matchFound = false;
text = isCaseSensitive ? text : text.toLowerCase();
let numMatches = 0;
let indices = [];
// ORs
for (let i = 0, qLen = query.length; i < qLen; i += 1) {
const parts = query[i];
let result = null;
matchFound = true;
const searchers = query[i];
for (let j = 0, pLen = parts.length; j < pLen; j += 1) {
let token = parts[j];
result = this._search(token, text);
if (!result.isMatch) {
// AND condition, short-circuit and move on to next part
matchFound = false;
// Reset indices
indices.length = 0;
numMatches = 0;
// ANDs
for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
const searcher = searchers[j];
const { isMatch, matchedIndices } = searcher.search(text);
if (isMatch) {
numMatches += 1;
if (includeMatches) {
if (searcher.constructor.type === FuzzyMatch.type) {
// FuzzyMatch returns is a 2D array
indices = [...indices, ...matchedIndices];
} else {
indices.push(matchedIndices);
}
}
} else {
numMatches = 0;
indices.length = 0;
break

@@ -587,3 +824,12 @@ }

// OR condition, so if TRUE, return
if (matchFound) {
if (numMatches) {
let result = {
isMatch: true,
score: 0
};
if (includeMatches) {
result.matchedIndices = indices;
}
return result

@@ -599,25 +845,2 @@ }

}
_search(pattern, text) {
if (exactMatch.isForPattern(pattern)) {
return exactMatch.match(pattern, text)
} else if (prefixExactMatch.isForPattern(pattern)) {
return prefixExactMatch.match(pattern, text)
} else if (inversePrefixExactMatch.isForPattern(pattern)) {
return inversePrefixExactMatch.match(pattern, text)
} else if (inverseSuffixExactMatch.isForPattern(pattern)) {
return inverseSuffixExactMatch.match(pattern, text)
} else if (suffixExactMatch.isForPattern(pattern)) {
return suffixExactMatch.match(pattern, text)
} else if (inverseExactMatch.isForPattern(pattern)) {
return inverseExactMatch.match(pattern, text)
} else {
let searcher = this._fuzzyCache[pattern];
if (!searcher) {
searcher = new BitapSearch(pattern, this.options);
this._fuzzyCache[pattern] = searcher;
}
return searcher.searchInString(text)
}
}
}

@@ -729,3 +952,10 @@

class NGramSearch {
constructor(pattern, options = { threshold: 0.6 }) {
constructor(
pattern,
options = ({
/*eslint-disable no-undef*/
threshold = Config.threshold
/*eslint-enable no-undef*/
} = {})
) {
// Create the ngram, and sort it

@@ -735,2 +965,5 @@ this.options = options;

}
static condition(pattern) {
return pattern.length > MAX_BITS
}
searchIn(value) {

@@ -754,49 +987,2 @@ let textNgram = value.ng;

function get(obj, path) {
let list = [];
let arr = false;
const _get = (obj, path) => {
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 key = path;
let remaining = null;
if (dotIndex !== -1) {
key = path.slice(0, dotIndex);
remaining = path.slice(dotIndex + 1);
}
const value = obj[key];
if (isDefined(value)) {
if (!remaining && (isString(value) || isNumber(value))) {
list.push(toString(value));
} else if (isArray(value)) {
arr = true;
// Search each item in the array.
for (let i = 0, len = value.length; i < len; i += 1) {
_get(value[i], remaining);
}
} else if (remaining) {
// An object. Recurse further.
_get(value, remaining);
}
}
}
};
_get(obj, path);
if (arr) {
return list
}
return list[0]
}
function createIndex(

@@ -1010,54 +1196,7 @@ keys,

const BasicOptions = {
// 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.
isCaseSensitive: false,
// Minimum number of characters that must be matched before a result is considered a match
findAllMatches: false,
includeMatches: false,
includeScore: false,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1,
// Whether to sort the result list, by score
shouldSort: true,
// Default sort function
sortFn: (a, b) => a.score - b.score
};
const registeredSearchers = [];
const FuzzyOptions = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// 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,
// 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
};
const AdvancedOptions = {
// Enabled extended-searching
useExtendedSearch: false,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: get
};
const defaultOptions = {
...BasicOptions,
...FuzzyOptions,
...AdvancedOptions
};
class Fuse {
constructor(list, options = defaultOptions, index = null) {
this.options = { ...defaultOptions, ...options };
// `caseSensitive` is deprecated, use `isCaseSensitive` instead
this.options.isCaseSensitive = options.caseSensitive;
delete this.options.caseSensitive;
constructor(list, options = {}, index = null) {
this.options = { ...Config, ...options };

@@ -1068,2 +1207,6 @@ this._processKeys(this.options.keys);

static register(...args) {
registeredSearchers.push(...args);
}
setCollection(list, index = null) {

@@ -1095,11 +1238,15 @@ this.list = list;

search(pattern, opts = { limit: false }) {
const { useExtendedSearch, shouldSort } = this.options;
const { shouldSort } = this.options;
let searcher = null;
if (useExtendedSearch) {
searcher = new ExtendedSearch(pattern, this.options);
} else if (pattern.length > MAX_BITS) {
searcher = new NGramSearch(pattern, this.options);
} else {
for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
let searcherClass = registeredSearchers[i];
if (searcherClass.condition(pattern, this.options)) {
searcher = new searcherClass(pattern, this.options);
break
}
}
if (!searcher) {
searcher = new BitapSearch(pattern, this.options);

@@ -1300,6 +1447,8 @@ }

Fuse.version = '5.1.0';
Fuse.register(ExtendedSearch, NGramSearch);
Fuse.version = '5.2.0-alpha.0';
Fuse.createIndex = createIndex;
Fuse.defaultOptions = defaultOptions;
Fuse.config = Config;
export default Fuse;
/**
* Fuse.js v5.1.0 - Lightweight fuzzy-search (http://fusejs.io)
* Fuse.js v5.2.0-alpha.0 - Lightweight fuzzy-search (http://fusejs.io)
*

@@ -87,2 +87,112 @@ * Copyright (c) 2020 Kiro Risk (http://kiro.me)

function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (_isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function bitapScore(pattern, _ref) {

@@ -140,15 +250,139 @@ var _ref$errors = _ref.errors,

function bitapSearch(text, pattern, patternAlphabet, _ref) {
var _ref$location = _ref.location,
location = _ref$location === void 0 ? 0 : _ref$location,
var INFINITY = 1 / 0;
var isArray = function isArray(value) {
return !Array.isArray ? Object.prototype.toString.call(value) === '[object Array]' : Array.isArray(value);
}; // Adapted from:
// https://github.com/lodash/lodash/blob/f4ca396a796435422bd4fd41fadbd225edddf175/.internal/baseToString.js
var baseToString = function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
};
var toString = function toString(value) {
return value == null ? '' : baseToString(value);
};
var isString = function isString(value) {
return typeof value === 'string';
};
var isNumber = function isNumber(value) {
return typeof value === 'number';
};
var isDefined = function isDefined(value) {
return value !== undefined && value !== null;
};
function get(obj, path) {
var list = [];
var arr = false;
var _get = function _get(obj, path) {
if (!path) {
// If there's no path left, we've gotten to the object we care about.
list.push(obj);
} else {
var dotIndex = path.indexOf('.');
var key = path;
var remaining = null;
if (dotIndex !== -1) {
key = path.slice(0, dotIndex);
remaining = path.slice(dotIndex + 1);
}
var value = obj[key];
if (isDefined(value)) {
if (!remaining && (isString(value) || isNumber(value))) {
list.push(toString(value));
} else if (isArray(value)) {
arr = true; // Search each item in the array.
for (var i = 0, len = value.length; i < len; i += 1) {
_get(value[i], remaining);
}
} else if (remaining) {
// An object. Recurse further.
_get(value, remaining);
}
}
}
};
_get(obj, path);
if (arr) {
return list;
}
return list[0];
}
var MatchOptions = {
// Whether the matches should be included in the result set. When true, each record in the result
// set will include the indices of the matched characters.
// These can consequently be used for highlighting purposes.
includeMatches: false,
// When true, the matching function will continue to the end of a search pattern even if
// a perfect match has already been located in the string.
findAllMatches: false,
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1
};
var BasicOptions = {
// 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.
isCaseSensitive: false,
// When true, the matching function will continue to the end of a search pattern even if
includeScore: false,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Whether to sort the result list, by score
shouldSort: true,
// Default sort function
sortFn: function sortFn(a, b) {
return a.score - b.score;
}
};
var FuzzyOptions = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// 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,
// 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
};
var AdvancedOptions = {
// When true, it enables the use of unix-like search commands
useExtendedSearch: false,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: get
};
var Config = _objectSpread2({}, BasicOptions, {}, MatchOptions, {}, FuzzyOptions, {}, AdvancedOptions);
function bitapSearch(text, pattern, patternAlphabet) {
var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
_ref$location = _ref.location,
location = _ref$location === void 0 ? Config.location : _ref$location,
_ref$distance = _ref.distance,
distance = _ref$distance === void 0 ? 100 : _ref$distance,
distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
_ref$threshold = _ref.threshold,
threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold,
threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
_ref$findAllMatches = _ref.findAllMatches,
findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches,
findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
_ref$minMatchCharLeng = _ref.minMatchCharLength,
minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng,
minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
_ref$includeMatches = _ref.includeMatches,
includeMatches = _ref$includeMatches === void 0 ? false : _ref$includeMatches;
includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches;
var patternLen = pattern.length; // Set starting location at beginning text and initialize the alphabet.

@@ -318,29 +552,10 @@

var BitapSearch = /*#__PURE__*/function () {
function BitapSearch(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$isCaseSensitive = _ref.isCaseSensitive,
isCaseSensitive = _ref$isCaseSensitive === void 0 ? false : _ref$isCaseSensitive,
_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$includeMatches = _ref.includeMatches,
includeMatches = _ref$includeMatches === void 0 ? false : _ref$includeMatches;
function BitapSearch(pattern) {
var _ref, _ref$location, _ref$threshold, _ref$distance, _ref$includeMatches, _ref$findAllMatches, _ref$minMatchCharLeng, _ref$isCaseSensitive;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$location = _ref.location, location = _ref$location === void 0 ? Config.location : _ref$location, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref$distance = _ref.distance, distance = _ref$distance === void 0 ? Config.distance : _ref$distance, _ref$includeMatches = _ref.includeMatches, includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches, _ref$findAllMatches = _ref.findAllMatches, findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches, _ref$minMatchCharLeng = _ref.minMatchCharLength, minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng, _ref$isCaseSensitive = _ref.isCaseSensitive, isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive, _ref);
_classCallCheck(this, BitapSearch);
this.options = {
location: location,
distance: distance,
threshold: threshold,
isCaseSensitive: isCaseSensitive,
findAllMatches: findAllMatches,
includeMatches: includeMatches,
minMatchCharLength: minMatchCharLength
};
this.options = options;

@@ -351,3 +566,3 @@ if (pattern.length > MAX_BITS) {

this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
this.pattern = this.options.isCaseSensitive ? pattern : pattern.toLowerCase();
this.patternAlphabet = patternAlphabet(this.pattern);

@@ -408,195 +623,380 @@ }

// Token: 'file
// Match type: exact-match
// Description: Items that include `file`
var isForPattern = function isForPattern(pattern) {
return pattern.charAt(0) == "'";
};
var Match = /*#__PURE__*/function () {
function Match(pattern) {
_classCallCheck(this, Match);
var sanitize = function sanitize(pattern) {
return pattern.substr(1);
};
this.pattern = pattern;
}
var match = function match(pattern, text) {
var sanitizedPattern = sanitize(pattern);
var index = text.indexOf(sanitizedPattern);
var isMatch = index > -1;
return {
isMatch: isMatch,
score: 0
};
};
_createClass(Match, [{
key: "search",
value: function search()
/*text*/
{}
}], [{
key: "isLiteralMatch",
value: function isLiteralMatch(pattern) {
return getMatch(pattern, this.literal);
}
}, {
key: "isRegMatch",
value: function isRegMatch(pattern) {
return getMatch(pattern, this.re);
}
}]);
var exactMatch = {
isForPattern: isForPattern,
sanitize: sanitize,
match: match
};
return Match;
}();
// Token: !fire
// Match type: inverse-exact-match
// Description: Items that do not include `fire`
var isForPattern$1 = function isForPattern(pattern) {
return pattern.charAt(0) == '!';
};
function getMatch(pattern, exp) {
var matches = pattern.match(exp);
return matches ? matches[1] : null;
}
var sanitize$1 = function sanitize(pattern) {
return pattern.substr(1);
};
var ExactMatch = /*#__PURE__*/function (_Match) {
_inherits(ExactMatch, _Match);
var match$1 = function match(pattern, text) {
var sanitizedPattern = sanitize$1(pattern);
var isMatch = text.indexOf(sanitizedPattern) === -1;
return {
isMatch: isMatch,
score: 0
};
};
var _super = _createSuper(ExactMatch);
var inverseExactMatch = {
isForPattern: isForPattern$1,
sanitize: sanitize$1,
match: match$1
};
function ExactMatch(pattern) {
_classCallCheck(this, ExactMatch);
// Token: ^file
// Match type: prefix-exact-match
// Description: Items that start with `file`
var isForPattern$2 = function isForPattern(pattern) {
return pattern.charAt(0) == '^';
};
return _super.call(this, pattern);
}
var sanitize$2 = function sanitize(pattern) {
return pattern.substr(1);
};
_createClass(ExactMatch, [{
key: "search",
value: function search(text) {
var index = text.indexOf(this.pattern);
var isMatch = index > -1;
return {
isMatch: isMatch,
score: isMatch ? 1 : 0,
matchedIndices: [index, index + this.pattern.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'exact';
}
}, {
key: "literal",
get: function get() {
return /^'"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^'(.*)$/;
}
}]);
var match$2 = function match(pattern, text) {
var sanitizedPattern = sanitize$2(pattern);
var isMatch = text.startsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
return ExactMatch;
}(Match);
var prefixExactMatch = {
isForPattern: isForPattern$2,
sanitize: sanitize$2,
match: match$2
};
var InverseExactMatch = /*#__PURE__*/function (_Match) {
_inherits(InverseExactMatch, _Match);
// Token: !^fire
// Match type: inverse-prefix-exact-match
// Description: Items that do not start with `fire`
var isForPattern$3 = function isForPattern(pattern) {
return pattern.charAt(0) == '!' && pattern.charAt(1) == '^';
};
var _super = _createSuper(InverseExactMatch);
var sanitize$3 = function sanitize(pattern) {
return pattern.substr(2);
};
function InverseExactMatch(pattern) {
_classCallCheck(this, InverseExactMatch);
var match$3 = function match(pattern, text) {
var sanitizedPattern = sanitize$3(pattern);
var isMatch = !text.startsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
return _super.call(this, pattern);
}
var inversePrefixExactMatch = {
isForPattern: isForPattern$3,
sanitize: sanitize$3,
match: match$3
};
_createClass(InverseExactMatch, [{
key: "search",
value: function search(text) {
var index = text.indexOf(this.pattern);
var isMatch = index === -1;
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'inverse-exact';
}
}, {
key: "literal",
get: function get() {
return /^!"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^!(.*)$/;
}
}]);
// Token: .file$
// Match type: suffix-exact-match
// Description: Items that end with `.file`
var isForPattern$4 = function isForPattern(pattern) {
return pattern.charAt(pattern.length - 1) == '$';
};
return InverseExactMatch;
}(Match);
var sanitize$4 = function sanitize(pattern) {
return pattern.substr(0, pattern.length - 1);
};
var PrefixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(PrefixExactMatch, _Match);
var match$4 = function match(pattern, text) {
var sanitizedPattern = sanitize$4(pattern);
var isMatch = text.endsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
var _super = _createSuper(PrefixExactMatch);
var suffixExactMatch = {
isForPattern: isForPattern$4,
sanitize: sanitize$4,
match: match$4
};
function PrefixExactMatch(pattern) {
_classCallCheck(this, PrefixExactMatch);
// Token: !.file$
// Match type: inverse-suffix-exact-match
// Description: Items that do not end with `.file`
var isForPattern$5 = function isForPattern(pattern) {
return pattern.charAt(0) == '!' && pattern.charAt(pattern.length - 1) == '$';
};
return _super.call(this, pattern);
}
var sanitize$5 = function sanitize(pattern) {
return pattern.substring(1, pattern.length - 1);
};
_createClass(PrefixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = text.startsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, this.pattern.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'prefix-exact';
}
}, {
key: "literal",
get: function get() {
return /^\^"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^\^(.*)$/;
}
}]);
var match$5 = function match(pattern, text) {
var sanitizedPattern = sanitize$5(pattern);
var isMatch = !text.endsWith(sanitizedPattern);
return {
isMatch: isMatch,
score: 0
};
};
return PrefixExactMatch;
}(Match);
var inverseSuffixExactMatch = {
isForPattern: isForPattern$5,
sanitize: sanitize$5,
match: match$5
};
var InversePrefixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(InversePrefixExactMatch, _Match);
var INFINITY = 1 / 0;
var isArray = function isArray(value) {
return !Array.isArray ? Object.prototype.toString.call(value) === '[object Array]' : Array.isArray(value);
}; // Adapted from:
// https://github.com/lodash/lodash/blob/f4ca396a796435422bd4fd41fadbd225edddf175/.internal/baseToString.js
var _super = _createSuper(InversePrefixExactMatch);
var baseToString = function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
function InversePrefixExactMatch(pattern) {
_classCallCheck(this, InversePrefixExactMatch);
return _super.call(this, pattern);
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
};
var toString = function toString(value) {
return value == null ? '' : baseToString(value);
};
var isString = function isString(value) {
return typeof value === 'string';
};
var isNumber = function isNumber(value) {
return typeof value === 'number';
};
var isDefined = function isDefined(value) {
return value !== undefined && value !== null;
};
_createClass(InversePrefixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = !text.startsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'inverse-prefix-exact';
}
}, {
key: "literal",
get: function get() {
return /^!\^"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^!\^(.*)$/;
}
}]);
return InversePrefixExactMatch;
}(Match);
var SuffixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(SuffixExactMatch, _Match);
var _super = _createSuper(SuffixExactMatch);
function SuffixExactMatch(pattern) {
_classCallCheck(this, SuffixExactMatch);
return _super.call(this, pattern);
}
_createClass(SuffixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = text.endsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [text.length - this.pattern.length, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'suffix-exact';
}
}, {
key: "literal",
get: function get() {
return /^"(.*)"\$$/;
}
}, {
key: "re",
get: function get() {
return /^(.*)\$$/;
}
}]);
return SuffixExactMatch;
}(Match);
var InverseSuffixExactMatch = /*#__PURE__*/function (_Match) {
_inherits(InverseSuffixExactMatch, _Match);
var _super = _createSuper(InverseSuffixExactMatch);
function InverseSuffixExactMatch(pattern) {
_classCallCheck(this, InverseSuffixExactMatch);
return _super.call(this, pattern);
}
_createClass(InverseSuffixExactMatch, [{
key: "search",
value: function search(text) {
var isMatch = !text.endsWith(this.pattern);
return {
isMatch: isMatch,
score: isMatch ? 0 : 1,
matchedIndices: [0, text.length - 1]
};
}
}], [{
key: "type",
get: function get() {
return 'inverse-suffix-exact';
}
}, {
key: "literal",
get: function get() {
return /^!"(.*)"\$$/;
}
}, {
key: "re",
get: function get() {
return /^!(.*)\$$/;
}
}]);
return InverseSuffixExactMatch;
}(Match);
var FuzzyMatch = /*#__PURE__*/function (_Match) {
_inherits(FuzzyMatch, _Match);
var _super = _createSuper(FuzzyMatch);
function FuzzyMatch(pattern) {
var _ref, _ref$location, _ref$threshold, _ref$distance, _ref$includeMatches, _ref$findAllMatches, _ref$minMatchCharLeng, _ref$isCaseSensitive;
var _this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$location = _ref.location, location = _ref$location === void 0 ? Config.location : _ref$location, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref$distance = _ref.distance, distance = _ref$distance === void 0 ? Config.distance : _ref$distance, _ref$includeMatches = _ref.includeMatches, includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches, _ref$findAllMatches = _ref.findAllMatches, findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches, _ref$minMatchCharLeng = _ref.minMatchCharLength, minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng, _ref$isCaseSensitive = _ref.isCaseSensitive, isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive, _ref);
_classCallCheck(this, FuzzyMatch);
_this = _super.call(this, pattern);
_this._bitapSearch = new BitapSearch(pattern, options);
return _this;
}
_createClass(FuzzyMatch, [{
key: "search",
value: function search(text) {
return this._bitapSearch.searchInString(text);
}
}], [{
key: "type",
get: function get() {
return 'fuzzy';
}
}, {
key: "literal",
get: function get() {
return /^"(.*)"$/;
}
}, {
key: "re",
get: function get() {
return /^(.*)$/;
}
}]);
return FuzzyMatch;
}(Match);
var searchers = [ExactMatch, PrefixExactMatch, InversePrefixExactMatch, InverseSuffixExactMatch, SuffixExactMatch, InverseExactMatch, FuzzyMatch];
var searchersLen = searchers.length; // Regex to split by spaces, but keep anything in quotes together
var SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;
var OR_TOKEN = '|'; // Return a 2D array representation of the query, for simpler parsing.
// Example:
// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
var queryfy = function queryfy(pattern) {
return pattern.split('|').map(function (item) {
return item.trim().split(/ +/g);
function parseQuery(pattern, options) {
return pattern.split(OR_TOKEN).map(function (item) {
var query = item.trim().split(SPACE_RE).filter(function (item) {
return item && !!item.trim();
});
var results = [];
for (var i = 0, len = query.length; i < len; i += 1) {
var queryItem = query[i]; // 1. Handle literal queries (i.e, once that are quotes "hello world")
var found = false;
var idx = -1;
while (!found && ++idx < searchersLen) {
var searcher = searchers[idx];
var token = searcher.isLiteralMatch(queryItem);
if (token) {
results.push(new searcher(token, options));
found = true;
}
}
if (found) {
continue;
} // 2. Handle regular queries
idx = -1;
while (++idx < searchersLen) {
var _searcher = searchers[idx];
var _token = _searcher.isRegMatch(queryItem);
if (_token) {
results.push(new _searcher(_token, options));
break;
}
}
}
return results;
});
};
}
/**

@@ -630,17 +1030,14 @@ * Command-like searching

var ExtendedSearch = /*#__PURE__*/function () {
function ExtendedSearch(pattern) {
var _ref, _ref$isCaseSensitive, _ref$includeMatches, _ref$minMatchCharLeng, _ref$findAllMatches, _ref$location, _ref$threshold, _ref$distance, _ref$includeMatches2;
var ExtendedSearch = /*#__PURE__*/function () {
function ExtendedSearch(pattern, options) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$isCaseSensitive = _ref.isCaseSensitive, isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive, _ref$includeMatches = _ref.includeMatches, includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches, _ref$minMatchCharLeng = _ref.minMatchCharLength, minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng, _ref$findAllMatches = _ref.findAllMatches, findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches, _ref$location = _ref.location, location = _ref$location === void 0 ? Config.location : _ref$location, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref$distance = _ref.distance, distance = _ref$distance === void 0 ? Config.distance : _ref$distance, _ref$includeMatches2 = _ref.includeMatches, includeMatches = _ref$includeMatches2 === void 0 ? Config.includeMatches : _ref$includeMatches2, _ref);
_classCallCheck(this, ExtendedSearch);
var isCaseSensitive = options.isCaseSensitive;
this.query = null;
this.options = options; // A <pattern>:<BitapSearch> key-value pair for optimizing searching
this._fuzzyCache = {};
if (isString(pattern) && pattern.trim().length > 0) {
this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
this.query = queryfy(this.pattern);
}
this.options = options;
this.pattern = options.isCaseSensitive ? pattern : pattern.toLowerCase();
this.query = parseQuery(this.pattern, options);
}

@@ -653,3 +1050,3 @@

if (!this.query) {
if (!query) {
return {

@@ -662,17 +1059,36 @@ isMatch: false,

var text = value.$;
text = this.options.isCaseSensitive ? text : text.toLowerCase();
var matchFound = false;
var _this$options = this.options,
includeMatches = _this$options.includeMatches,
isCaseSensitive = _this$options.isCaseSensitive;
text = isCaseSensitive ? text : text.toLowerCase();
var numMatches = 0;
var indices = []; // ORs
for (var i = 0, qLen = query.length; i < qLen; i += 1) {
var parts = query[i];
var result = null;
matchFound = true;
var searchers = query[i]; // Reset indices
for (var j = 0, pLen = parts.length; j < pLen; j += 1) {
var token = parts[j];
result = this._search(token, text);
indices.length = 0;
numMatches = 0; // ANDs
if (!result.isMatch) {
// AND condition, short-circuit and move on to next part
matchFound = false;
for (var j = 0, pLen = searchers.length; j < pLen; j += 1) {
var searcher = searchers[j];
var _searcher$search = searcher.search(text),
isMatch = _searcher$search.isMatch,
matchedIndices = _searcher$search.matchedIndices;
if (isMatch) {
numMatches += 1;
if (includeMatches) {
if (searcher.constructor.type === FuzzyMatch.type) {
// FuzzyMatch returns is a 2D array
indices = [].concat(_toConsumableArray(indices), _toConsumableArray(matchedIndices));
} else {
indices.push(matchedIndices);
}
}
} else {
numMatches = 0;
indices.length = 0;
break;

@@ -683,3 +1099,12 @@ }

if (matchFound) {
if (numMatches) {
var result = {
isMatch: true,
score: 0
};
if (includeMatches) {
result.matchedIndices = indices;
}
return result;

@@ -695,27 +1120,6 @@ }

}
}, {
key: "_search",
value: function _search(pattern, text) {
if (exactMatch.isForPattern(pattern)) {
return exactMatch.match(pattern, text);
} else if (prefixExactMatch.isForPattern(pattern)) {
return prefixExactMatch.match(pattern, text);
} else if (inversePrefixExactMatch.isForPattern(pattern)) {
return inversePrefixExactMatch.match(pattern, text);
} else if (inverseSuffixExactMatch.isForPattern(pattern)) {
return inverseSuffixExactMatch.match(pattern, text);
} else if (suffixExactMatch.isForPattern(pattern)) {
return suffixExactMatch.match(pattern, text);
} else if (inverseExactMatch.isForPattern(pattern)) {
return inverseExactMatch.match(pattern, text);
} else {
var searcher = this._fuzzyCache[pattern];
if (!searcher) {
searcher = new BitapSearch(pattern, this.options);
this._fuzzyCache[pattern] = searcher;
}
return searcher.searchInString(text);
}
}], [{
key: "condition",
value: function condition(_, options) {
return options.useExtendedSearch;
}

@@ -837,6 +1241,6 @@ }]);

function NGramSearch(pattern) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
threshold: 0.6
};
var _ref, _ref$threshold;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_ref = {}, _ref$threshold = _ref.threshold, threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold, _ref);
_classCallCheck(this, NGramSearch);

@@ -870,2 +1274,7 @@

}
}], [{
key: "condition",
value: function condition(pattern) {
return pattern.length > MAX_BITS;
}
}]);

@@ -876,48 +1285,2 @@

function get(obj, path) {
var list = [];
var arr = false;
var _get = function _get(obj, path) {
if (!path) {
// If there's no path left, we've gotten to the object we care about.
list.push(obj);
} else {
var dotIndex = path.indexOf('.');
var key = path;
var remaining = null;
if (dotIndex !== -1) {
key = path.slice(0, dotIndex);
remaining = path.slice(dotIndex + 1);
}
var value = obj[key];
if (isDefined(value)) {
if (!remaining && (isString(value) || isNumber(value))) {
list.push(toString(value));
} else if (isArray(value)) {
arr = true; // Search each item in the array.
for (var i = 0, len = value.length; i < len; i += 1) {
_get(value[i], remaining);
}
} else if (remaining) {
// An object. Recurse further.
_get(value, remaining);
}
}
}
};
_get(obj, path);
if (arr) {
return list;
}
return list[0];
}
function createIndex(keys, list) {

@@ -1160,47 +1523,7 @@ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},

var BasicOptions = {
// 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.
isCaseSensitive: false,
// Minimum number of characters that must be matched before a result is considered a match
findAllMatches: false,
includeMatches: false,
includeScore: false,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1,
// Whether to sort the result list, by score
shouldSort: true,
// Default sort function
sortFn: function sortFn(a, b) {
return a.score - b.score;
}
};
var FuzzyOptions = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// 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,
// 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
};
var AdvancedOptions = {
// Enabled extended-searching
useExtendedSearch: false,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: get
};
var registeredSearchers = [];
var defaultOptions = _objectSpread2({}, BasicOptions, {}, FuzzyOptions, {}, AdvancedOptions);
var Fuse = /*#__PURE__*/function () {
function Fuse(list) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

@@ -1210,7 +1533,4 @@

this.options = _objectSpread2({}, defaultOptions, {}, options); // `caseSensitive` is deprecated, use `isCaseSensitive` instead
this.options = _objectSpread2({}, Config, {}, options);
this.options.isCaseSensitive = options.caseSensitive;
delete this.options.caseSensitive;
this._processKeys(this.options.keys);

@@ -1257,12 +1577,15 @@

};
var _this$options = this.options,
useExtendedSearch = _this$options.useExtendedSearch,
shouldSort = _this$options.shouldSort;
var shouldSort = this.options.shouldSort;
var searcher = null;
if (useExtendedSearch) {
searcher = new ExtendedSearch(pattern, this.options);
} else if (pattern.length > MAX_BITS) {
searcher = new NGramSearch(pattern, this.options);
} else {
for (var i = 0, len = registeredSearchers.length; i < len; i += 1) {
var searcherClass = registeredSearchers[i];
if (searcherClass.condition(pattern, this.options)) {
searcher = new searcherClass(pattern, this.options);
break;
}
}
if (!searcher) {
searcher = new BitapSearch(pattern, this.options);

@@ -1453,8 +1776,8 @@ }

var finalOutput = [];
var _this$options2 = this.options,
includeMatches = _this$options2.includeMatches,
includeScore = _this$options2.includeScore;
var _this$options = this.options,
includeMatches = _this$options.includeMatches,
includeScore = _this$options.includeScore;
var transformers = [];
if (includeMatches) { transformers.push(transformMatches); }
if (includeScore) { transformers.push(transformScore); }
if (includeMatches) transformers.push(transformMatches);
if (includeScore) transformers.push(transformScore);

@@ -1480,2 +1803,7 @@ for (var i = 0, len = results.length; i < len; i += 1) {

}
}], [{
key: "register",
value: function register() {
registeredSearchers.push.apply(registeredSearchers, arguments);
}
}]);

@@ -1486,5 +1814,6 @@

Fuse.version = '5.1.0';
Fuse.register(ExtendedSearch, NGramSearch);
Fuse.version = '5.2.0-alpha.0';
Fuse.createIndex = createIndex;
Fuse.defaultOptions = defaultOptions;
Fuse.config = Config;

@@ -1491,0 +1820,0 @@ return Fuse;

/**
* Fuse.js v5.1.0 - Lightweight fuzzy-search (http://fusejs.io)
* Fuse.js v5.2.0-alpha.0 - Lightweight fuzzy-search (http://fusejs.io)
*

@@ -9,2 +9,2 @@ * Copyright (c) 2020 Kiro Risk (http://kiro.me)

*/
var t,e;t=this,e=function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){var r=e.errors,n=void 0===r?0:r,i=e.currentLocation,s=void 0===i?0:i,o=e.expectedLocation,a=void 0===o?0:o,h=e.distance,c=void 0===h?100:h,u=n/t.length,f=Math.abs(a-s);return c?u+f/c:f?1:u}var a=function(){function e(r,n){var i=n.location,s=void 0===i?0:i,o=n.distance,a=void 0===o?100:o,h=n.threshold,c=void 0===h?.6:h,u=n.isCaseSensitive,f=void 0!==u&&u,l=n.findAllMatches,v=void 0!==l&&l,d=n.minMatchCharLength,p=void 0===d?1:d,g=n.includeMatches,y=void 0!==g&&g;if(t(this,e),this.options={location:s,distance:a,threshold:c,isCaseSensitive:f,findAllMatches:v,includeMatches:y,minMatchCharLength:p},r.length>32)throw new Error("Pattern length exceeds max of ".concat(32,"."));this.pattern=f?r:r.toLowerCase(),this.patternAlphabet=function(t){for(var e={},r=t.length,n=0;n<r;n+=1)e[t.charAt(n)]=0;for(var i=0;i<r;i+=1)e[t.charAt(i)]|=1<<r-i-1;return e}(this.pattern)}return r(e,[{key:"searchIn",value:function(t){var e=t.$;return this.searchInString(e)}},{key:"searchInString",value:function(t){var e=this.options,r=e.isCaseSensitive,n=e.includeMatches;if(r||(t=t.toLowerCase()),this.pattern===t){var i={isMatch:!0,score:0};return n&&(i.matchedIndices=[[0,t.length-1]]),i}var s=this.options,a=s.location,h=s.distance,c=s.threshold,u=s.findAllMatches,f=s.minMatchCharLength;return function(t,e,r,n){for(var i=n.location,s=void 0===i?0:i,a=n.distance,h=void 0===a?100:a,c=n.threshold,u=void 0===c?.6:c,f=n.findAllMatches,l=void 0!==f&&f,v=n.minMatchCharLength,d=void 0===v?1:v,p=n.includeMatches,g=void 0!==p&&p,y=e.length,m=t.length,k=Math.max(0,Math.min(s,m)),M=u,b=t.indexOf(e,k),x=[],_=0;_<m;_+=1)x[_]=0;if(-1!==b){var w=o(e,{errors:0,currentLocation:b,expectedLocation:k,distance:h});if(M=Math.min(w,M),-1!==(b=t.lastIndexOf(e,k+y))){var O=o(e,{errors:0,currentLocation:b,expectedLocation:k,distance:h});M=Math.min(O,M)}}b=-1;for(var S=[],I=1,A=y+m,L=1<<(y<=31?y-1:30),C=0;C<y;C+=1){for(var j=0,$=A;j<$;)o(e,{errors:C,currentLocation:k+$,expectedLocation:k,distance:h})<=M?j=$:A=$,$=Math.floor((A-j)/2+j);A=$;var P=Math.max(1,k-$+1),N=l?m:Math.min(k+$,m)+y,E=Array(N+2);E[N+1]=(1<<C)-1;for(var F=N;F>=P;F-=1){var z=F-1,q=r[t.charAt(z)];if(q&&(x[z]=1),E[F]=(E[F+1]<<1|1)&q,0!==C&&(E[F]|=(S[F+1]|S[F])<<1|1|S[F+1]),E[F]&L&&(I=o(e,{errors:C,currentLocation:z,expectedLocation:k,distance:h}))<=M){if(M=I,(b=z)<=k)break;P=Math.max(1,2*k-b)}}if(o(e,{errors:C+1,currentLocation:k,expectedLocation:k,distance:h})>M)break;S=E}var D={isMatch:b>=0,score:I||.001};return g&&(D.matchedIndices=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=[],n=-1,i=-1,s=0,o=t.length;s<o;s+=1){var a=t[s];a&&-1===n?n=s:a||-1===n||((i=s-1)-n+1>=e&&r.push([n,i]),n=-1)}return t[s-1]&&s-n>=e&&r.push([n,s-1]),r}(x,d)),D}(t,this.pattern,this.patternAlphabet,{location:a,distance:h,threshold:c,findAllMatches:u,minMatchCharLength:f,includeMatches:n})}}]),e}(),h=function(t){return t.substr(1)},c=function(t){return"'"==t.charAt(0)},u=function(t,e){var r=h(t);return{isMatch:e.indexOf(r)>-1,score:0}},f=function(t){return t.substr(1)},l=function(t){return"!"==t.charAt(0)},v=function(t,e){var r=f(t);return{isMatch:-1===e.indexOf(r),score:0}},d=function(t){return t.substr(1)},p=function(t){return"^"==t.charAt(0)},g=function(t,e){var r=d(t);return{isMatch:e.startsWith(r),score:0}},y=function(t){return t.substr(2)},m=function(t){return"!"==t.charAt(0)&&"^"==t.charAt(1)},k=function(t,e){var r=y(t);return{isMatch:!e.startsWith(r),score:0}},M=function(t){return t.substr(0,t.length-1)},b=function(t){return"$"==t.charAt(t.length-1)},x=function(t,e){var r=M(t);return{isMatch:e.endsWith(r),score:0}},_=function(t){return t.substring(1,t.length-1)},w=function(t){return"!"==t.charAt(0)&&"$"==t.charAt(t.length-1)},O=function(t,e){var r=_(t);return{isMatch:!e.endsWith(r),score:0}},S=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},I=function(t){return"string"==typeof t},A=function(t){return"number"==typeof t},L=function(t){return null!=t},C=function(){function e(r,n){t(this,e);var i=n.isCaseSensitive;this.query=null,this.options=n,this._fuzzyCache={},I(r)&&r.trim().length>0&&(this.pattern=i?r:r.toLowerCase(),this.query=function(t){return t.split("|").map((function(t){return t.trim().split(/ +/g)}))}(this.pattern))}return r(e,[{key:"searchIn",value:function(t){var e=this.query;if(!this.query)return{isMatch:!1,score:1};var r=t.$;r=this.options.isCaseSensitive?r:r.toLowerCase();for(var n=!1,i=0,s=e.length;i<s;i+=1){var o=e[i],a=null;n=!0;for(var h=0,c=o.length;h<c;h+=1){var u=o[h];if(!(a=this._search(u,r)).isMatch){n=!1;break}}if(n)return a}return{isMatch:!1,score:1}}},{key:"_search",value:function(t,e){if(c(t))return u(t,e);if(p(t))return g(t,e);if(m(t))return k(t,e);if(w(t))return O(t,e);if(b(t))return x(t,e);if(l(t))return v(t,e);var r=this._fuzzyCache[t];return r||(r=new a(t,this.options),this._fuzzyCache[t]=r),r.searchInString(e)}}]),e}();function j(t,e){var r=e.n,n=void 0===r?3:r,i=e.pad,s=void 0===i||i,o=e.sort,a=void 0!==o&&o,h=[];if(null==t)return h;t=t.toLowerCase(),s&&(t=" ".concat(t," "));var c=t.length-n+1;if(c<1)return h;for(;c--;)h[c]=t.substr(c,n);return a&&h.sort((function(t,e){return t==e?0:t<e?-1:1})),h}var $=function(){function e(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{threshold:.6};t(this,e),this.options=n,this.patternNgram=j(r,{sort:!0})}return r(e,[{key:"searchIn",value:function(t){var e=t.ng;e||(e=j(t.$,{sort:!0}),t.ng=e);var r,n,i,s=(r=this.patternNgram,i=function(t,e){for(var r=[],n=0,i=0;n<t.length&&i<e.length;){var s=t[n],o=e[i];s<o?(r.push(s),n+=1):o<s?(r.push(o),i+=1):(r.push(o),n+=1,i+=1)}for(;n<t.length;)r.push(t[n]),n+=1;for(;i<e.length;)r.push(e[i]),i+=1;return r}(r,n=e),1-function(t,e){for(var r=[],n=0,i=0;n<t.length&&i<e.length;){var s=t[n],o=e[i];s==o?(r.push(s),n+=1,i+=1):s<o?n+=1:(s>o||(n+=1),i+=1)}return r}(r,n).length/i.length),o=s<this.options.threshold;return{score:o?s:1,isMatch:o}}}]),e}();function P(t,e){var r=[],n=!1;return function t(e,i){if(i){var s=i.indexOf("."),o=i,a=null;-1!==s&&(o=i.slice(0,s),a=i.slice(s+1));var h=e[o];if(L(h))if(a||!I(h)&&!A(h))if(S(h)){n=!0;for(var c=0,u=h.length;c<u;c+=1)t(h[c],a)}else a&&t(h,a);else r.push(function(t){return null==t?"":function(t){if("string"==typeof t)return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}(h))}else r.push(e)}(t,e),n?r:r[0]}function N(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.getFn,i=void 0===n?P:n,s=r.ngrams,o=void 0!==s&&s,a=[];if(I(e[0]))for(var h=0,c=e.length;h<c;h+=1){var u=e[h];if(L(u)){var f={$:u,idx:h};o&&(f.ng=j(u,{sort:!0})),a.push(f)}}else for(var l=t.length,v=0,d=e.length;v<d;v+=1){for(var p=e[v],g={idx:v,$:{}},y=0;y<l;y+=1){var m=t[y],k=i(p,m);if(L(k))if(S(k)){for(var M=[],b=[{arrayIndex:-1,value:k}];b.length;){var x=b.pop(),_=x.arrayIndex,w=x.value;if(L(w))if(I(w)){var O={$:w,idx:_};o&&(O.ng=j(w,{sort:!0})),M.push(O)}else if(S(w))for(var A=0,C=w.length;A<C;A+=1)b.push({arrayIndex:A,value:w[A]})}g.$[m]=M}else{var $={$:k};o&&($.ng=j(k,{sort:!0})),g.$[m]=$}}a.push(g)}return a}var E=function(){function e(r){if(t(this,e),this._keys={},this._keyNames=[],this._length=r.length,r.length&&I(r[0]))for(var n=0;n<this._length;n+=1){var i=r[n];this._keys[i]={weight:1},this._keyNames.push(i)}else{for(var s=0,o=0;o<this._length;o+=1){var a=r[o];if(!Object.prototype.hasOwnProperty.call(a,"name"))throw new Error('Missing "name" property in key object');var h=a.name;if(this._keyNames.push(h),!Object.prototype.hasOwnProperty.call(a,"weight"))throw new Error('Missing "weight" property in key object');var c=a.weight;if(c<=0||c>=1)throw new Error('"weight" property in key must be in the range of (0, 1)');this._keys[h]={weight:c},s+=c}for(var u=0;u<this._length;u+=1){var f=this._keyNames[u],l=this._keys[f].weight;this._keys[f].weight=l/s}}}return r(e,[{key:"get",value:function(t,e){return this._keys[t]?this._keys[t][e]:-1}},{key:"keys",value:function(){return this._keyNames}},{key:"count",value:function(){return this._length}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function F(t,e){var r=t.matches;if(e.matches=[],L(r))for(var n=0,i=r.length;n<i;n+=1){var s=r[n];if(L(s.indices)&&0!==s.indices.length){var o={indices:s.indices,value:s.value};s.key&&(o.key=s.key),s.idx>-1&&(o.refIndex=s.idx),e.matches.push(o)}}}function z(t,e){e.score=t.score}var q=s({},{isCaseSensitive:!1,findAllMatches:!1,includeMatches:!1,includeScore:!1,keys:[],minMatchCharLength:1,shouldSort:!0,sortFn:function(t,e){return t.score-e.score}},{},{location:0,threshold:.6,distance:100},{},{useExtendedSearch:!1,getFn:P}),D=function(){function e(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:q,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t(this,e),this.options=s({},q,{},n),this.options.isCaseSensitive=n.caseSensitive,delete this.options.caseSensitive,this._processKeys(this.options.keys),this.setCollection(r,i)}return r(e,[{key:"setCollection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.list=t,this.listIsStringArray=I(t[0]),e?this.setIndex(e):this.setIndex(this._createIndex())}},{key:"setIndex",value:function(t){this._indexedList=t}},{key:"_processKeys",value:function(t){this._keyStore=new E(t)}},{key:"_createIndex",value:function(){return N(this._keyStore.keys(),this.list,{getFn:this.options.getFn})}},{key:"search",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{limit:!1},r=this.options,n=r.useExtendedSearch,i=r.shouldSort,s=null;s=n?new C(t,this.options):t.length>32?new $(t,this.options):new a(t,this.options);var o=this._searchUsing(s);return this._computeScore(o),i&&this._sort(o),e.limit&&A(e.limit)&&(o=o.slice(0,e.limit)),this._format(o)}},{key:"_searchUsing",value:function(t){var e=this._indexedList,r=[],n=this.options.includeMatches;if(this.listIsStringArray)for(var i=0,s=e.length;i<s;i+=1){var o=e[i],a=o.$,h=o.idx;if(L(a)){var c=t.searchIn(o),u=c.isMatch,f=c.score;if(u){var l={score:f,value:a};n&&(l.indices=c.matchedIndices),r.push({item:a,idx:h,matches:[l]})}}}else for(var v=this._keyStore.keys(),d=this._keyStore.count(),p=0,g=e.length;p<g;p+=1){var y=e[p],m=y.$,k=y.idx;if(L(m)){for(var M=[],b=0;b<d;b+=1){var x=v[b],_=m[x];if(L(_))if(S(_))for(var w=0,O=_.length;w<O;w+=1){var I=_[w],A=I.$,C=I.idx;if(L(A)){var j=t.searchIn(I),$=j.isMatch,P=j.score;if($){var N={score:P,key:x,value:A,idx:C};n&&(N.indices=j.matchedIndices),M.push(N)}}}else{var E=_.$,F=t.searchIn(_),z=F.isMatch,q=F.score;if(!z)continue;var D={score:q,key:x,value:E};n&&(D.indices=F.matchedIndices),M.push(D)}}M.length&&r.push({idx:k,item:m,matches:M})}}return r}},{key:"_computeScore",value:function(t){for(var e=0,r=t.length;e<r;e+=1){for(var n=t[e],i=n.matches,s=i.length,o=1,a=0;a<s;a+=1){var h=i[a],c=h.key,u=this._keyStore.get(c,"weight"),f=u>-1?u:1,l=0===h.score&&u>-1?Number.EPSILON:h.score;o*=Math.pow(l,f)}n.score=o}}},{key:"_sort",value:function(t){t.sort(this.options.sortFn)}},{key:"_format",value:function(t){var e=[],r=this.options,n=r.includeMatches,i=r.includeScore,s=[];n&&s.push(F),i&&s.push(z);for(var o=0,a=t.length;o<a;o+=1){var h=t[o],c=h.idx,u={item:this.list[c],refIndex:c};if(s.length)for(var f=0,l=s.length;f<l;f+=1)s[f](h,u);e.push(u)}return e}}]),e}();return D.version="5.1.0",D.createIndex=N,D.defaultOptions=q,D},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Fuse=e();
var t,e;t=this,e=function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function o(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function l(t){return function(){var e,n=s(t);if(h()){var r=s(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return u(this,e)}}function f(t){return function(t){if(Array.isArray(t))return v(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return v(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function d(t,e){var n=e.errors,r=void 0===n?0:n,i=e.currentLocation,o=void 0===i?0:i,a=e.expectedLocation,s=void 0===a?0:a,c=e.distance,h=void 0===c?100:c,u=r/t.length,l=Math.abs(s-o);return h?u+l/h:l?1:u}function p(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=[],r=-1,i=-1,o=0,a=t.length;o<a;o+=1){var s=t[o];s&&-1===r?r=o:s||-1===r||((i=o-1)-r+1>=e&&n.push([r,i]),r=-1)}return t[o-1]&&o-r>=e&&n.push([r,o-1]),n}var y=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},g=function(t){return"string"==typeof t},m=function(t){return"number"==typeof t},k=function(t){return null!=t};function M(t,e){var n=[],r=!1;return function t(e,i){if(i){var o=i.indexOf("."),a=i,s=null;-1!==o&&(a=i.slice(0,o),s=i.slice(o+1));var c=e[a];if(k(c))if(s||!g(c)&&!m(c))if(y(c)){r=!0;for(var h=0,u=c.length;h<u;h+=1)t(c[h],s)}else s&&t(c,s);else n.push(function(t){return null==t?"":function(t){if("string"==typeof t)return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}(c))}else n.push(e)}(t,e),r?n:n[0]}var b=o({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(t,e){return t.score-e.score}},{},{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},{},{location:0,threshold:.6,distance:100},{},{useExtendedSearch:!1,getFn:M});function x(t){for(var e={},n=t.length,r=0;r<n;r+=1)e[t.charAt(r)]=0;for(var i=0;i<n;i+=1)e[t.charAt(i)]|=1<<n-i-1;return e}var w=function(){function e(n){var r,i,o,a,s,c,h,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(i=(r={}).location,location=void 0===i?b.location:i,o=r.threshold,threshold=void 0===o?b.threshold:o,a=r.distance,distance=void 0===a?b.distance:a,s=r.includeMatches,includeMatches=void 0===s?b.includeMatches:s,c=r.findAllMatches,findAllMatches=void 0===c?b.findAllMatches:c,h=r.minMatchCharLength,minMatchCharLength=void 0===h?b.minMatchCharLength:h,u=r.isCaseSensitive,isCaseSensitive=void 0===u?b.isCaseSensitive:u,r);if(t(this,e),this.options=l,n.length>32)throw new Error("Pattern length exceeds max of ".concat(32,"."));this.pattern=this.options.isCaseSensitive?n:n.toLowerCase(),this.patternAlphabet=x(this.pattern)}return n(e,[{key:"searchIn",value:function(t){var e=t.$;return this.searchInString(e)}},{key:"searchInString",value:function(t){var e=this.options,n=e.isCaseSensitive,r=e.includeMatches;if(n||(t=t.toLowerCase()),this.pattern===t){var i={isMatch:!0,score:0};return r&&(i.matchedIndices=[[0,t.length-1]]),i}var o=this.options,a=o.location,s=o.distance,c=o.threshold,h=o.findAllMatches,u=o.minMatchCharLength;return function(t,e,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?b.location:i,a=r.distance,s=void 0===a?b.distance:a,c=r.threshold,h=void 0===c?b.threshold:c,u=r.findAllMatches,l=void 0===u?b.findAllMatches:u,f=r.minMatchCharLength,v=void 0===f?b.minMatchCharLength:f,y=r.includeMatches,g=void 0===y?b.includeMatches:y,m=e.length,k=t.length,M=Math.max(0,Math.min(o,k)),x=h,w=t.indexOf(e,M),S=[],_=0;_<k;_+=1)S[_]=0;if(-1!==w){var O=d(e,{errors:0,currentLocation:w,expectedLocation:M,distance:s});if(x=Math.min(O,x),-1!==(w=t.lastIndexOf(e,M+m))){var I=d(e,{errors:0,currentLocation:w,expectedLocation:M,distance:s});x=Math.min(I,x)}}w=-1;for(var C=[],L=1,A=m+k,$=1<<(m<=31?m-1:30),j=0;j<m;j+=1){for(var P=0,E=A;P<E;){var N=d(e,{errors:j,currentLocation:M+E,expectedLocation:M,distance:s});N<=x?P=E:A=E,E=Math.floor((A-P)/2+P)}A=E;var R=Math.max(1,M-E+1),F=l?k:Math.min(M+E,k)+m,D=Array(F+2);D[F+1]=(1<<j)-1;for(var W=F;W>=R;W-=1){var q=W-1,T=n[t.charAt(q)];if(T&&(S[q]=1),D[W]=(D[W+1]<<1|1)&T,0!==j&&(D[W]|=(C[W+1]|C[W])<<1|1|C[W+1]),D[W]&$&&(L=d(e,{errors:j,currentLocation:q,expectedLocation:M,distance:s}))<=x){if(x=L,(w=q)<=M)break;R=Math.max(1,2*M-w)}}var U=d(e,{errors:j+1,currentLocation:M,expectedLocation:M,distance:s});if(U>x)break;C=D}var z={isMatch:w>=0,score:L||.001};return g&&(z.matchedIndices=p(S,v)),z}(t,this.pattern,this.patternAlphabet,{location:a,distance:s,threshold:c,findAllMatches:h,minMatchCharLength:u,includeMatches:r})}}]),e}(),S=function(){function e(n){t(this,e),this.pattern=n}return n(e,[{key:"search",value:function(){}}],[{key:"isLiteralMatch",value:function(t){return _(t,this.literal)}},{key:"isRegMatch",value:function(t){return _(t,this.re)}}]),e}();function _(t,e){var n=t.match(e);return n?n[1]:null}var O=function(e){a(i,e);var r=l(i);function i(e){return t(this,i),r.call(this,e)}return n(i,[{key:"search",value:function(t){var e=t.indexOf(this.pattern),n=e>-1;return{isMatch:n,score:n?1:0,matchedIndices:[e,e+this.pattern.length-1]}}}],[{key:"type",get:function(){return"exact"}},{key:"literal",get:function(){return/^'"(.*)"$/}},{key:"re",get:function(){return/^'(.*)$/}}]),i}(S),I=function(e){a(i,e);var r=l(i);function i(e){return t(this,i),r.call(this,e)}return n(i,[{key:"search",value:function(t){var e=-1===t.indexOf(this.pattern);return{isMatch:e,score:e?0:1,matchedIndices:[0,t.length-1]}}}],[{key:"type",get:function(){return"inverse-exact"}},{key:"literal",get:function(){return/^!"(.*)"$/}},{key:"re",get:function(){return/^!(.*)$/}}]),i}(S),C=function(e){a(i,e);var r=l(i);function i(e){return t(this,i),r.call(this,e)}return n(i,[{key:"search",value:function(t){var e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,matchedIndices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"prefix-exact"}},{key:"literal",get:function(){return/^\^"(.*)"$/}},{key:"re",get:function(){return/^\^(.*)$/}}]),i}(S),L=function(e){a(i,e);var r=l(i);function i(e){return t(this,i),r.call(this,e)}return n(i,[{key:"search",value:function(t){var e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,matchedIndices:[0,t.length-1]}}}],[{key:"type",get:function(){return"inverse-prefix-exact"}},{key:"literal",get:function(){return/^!\^"(.*)"$/}},{key:"re",get:function(){return/^!\^(.*)$/}}]),i}(S),A=function(e){a(i,e);var r=l(i);function i(e){return t(this,i),r.call(this,e)}return n(i,[{key:"search",value:function(t){var e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,matchedIndices:[t.length-this.pattern.length,t.length-1]}}}],[{key:"type",get:function(){return"suffix-exact"}},{key:"literal",get:function(){return/^"(.*)"\$$/}},{key:"re",get:function(){return/^(.*)\$$/}}]),i}(S),$=function(e){a(i,e);var r=l(i);function i(e){return t(this,i),r.call(this,e)}return n(i,[{key:"search",value:function(t){var e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,matchedIndices:[0,t.length-1]}}}],[{key:"type",get:function(){return"inverse-suffix-exact"}},{key:"literal",get:function(){return/^!"(.*)"\$$/}},{key:"re",get:function(){return/^!(.*)\$$/}}]),i}(S),j=function(e){a(i,e);var r=l(i);function i(e){var n,o,a,s,c,h,u,l,f,v=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(o=(n={}).location,location=void 0===o?b.location:o,a=n.threshold,threshold=void 0===a?b.threshold:a,s=n.distance,distance=void 0===s?b.distance:s,c=n.includeMatches,includeMatches=void 0===c?b.includeMatches:c,h=n.findAllMatches,findAllMatches=void 0===h?b.findAllMatches:h,u=n.minMatchCharLength,minMatchCharLength=void 0===u?b.minMatchCharLength:u,l=n.isCaseSensitive,isCaseSensitive=void 0===l?b.isCaseSensitive:l,n);return t(this,i),(f=r.call(this,e))._bitapSearch=new w(e,v),f}return n(i,[{key:"search",value:function(t){return this._bitapSearch.searchInString(t)}}],[{key:"type",get:function(){return"fuzzy"}},{key:"literal",get:function(){return/^"(.*)"$/}},{key:"re",get:function(){return/^(.*)$/}}]),i}(S),P=[O,C,L,$,A,I,j],E=P.length,N=/ +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;function R(t,e){return t.split("|").map((function(t){for(var n=t.trim().split(N).filter((function(t){return t&&!!t.trim()})),r=[],i=0,o=n.length;i<o;i+=1){for(var a=n[i],s=!1,c=-1;!s&&++c<E;){var h=P[c],u=h.isLiteralMatch(a);u&&(r.push(new h(u,e)),s=!0)}if(!s)for(c=-1;++c<E;){var l=P[c],f=l.isRegMatch(a);if(f){r.push(new l(f,e));break}}}return r}))}var F=function(){function e(n){var r,i,o,a,s,c,h,u,l,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(i=(r={}).isCaseSensitive,isCaseSensitive=void 0===i?b.isCaseSensitive:i,o=r.includeMatches,includeMatches=void 0===o?b.includeMatches:o,a=r.minMatchCharLength,minMatchCharLength=void 0===a?b.minMatchCharLength:a,s=r.findAllMatches,findAllMatches=void 0===s?b.findAllMatches:s,c=r.location,location=void 0===c?b.location:c,h=r.threshold,threshold=void 0===h?b.threshold:h,u=r.distance,distance=void 0===u?b.distance:u,l=r.includeMatches,includeMatches=void 0===l?b.includeMatches:l,r);t(this,e),this.query=null,this.options=f,this.pattern=f.isCaseSensitive?n:n.toLowerCase(),this.query=R(this.pattern,f)}return n(e,[{key:"searchIn",value:function(t){var e=this.query;if(!e)return{isMatch:!1,score:1};var n=t.$,r=this.options,i=r.includeMatches;n=r.isCaseSensitive?n:n.toLowerCase();for(var o=0,a=[],s=0,c=e.length;s<c;s+=1){var h=e[s];a.length=0,o=0;for(var u=0,l=h.length;u<l;u+=1){var v=h[u],d=v.search(n),p=d.isMatch,y=d.matchedIndices;if(!p){o=0,a.length=0;break}o+=1,i&&(v.constructor.type===j.type?a=[].concat(f(a),f(y)):a.push(y))}if(o){var g={isMatch:!0,score:0};return i&&(g.matchedIndices=a),g}}return{isMatch:!1,score:1}}}],[{key:"condition",value:function(t,e){return e.useExtendedSearch}}]),e}();function D(t,e){var n=e.n,r=void 0===n?3:n,i=e.pad,o=void 0===i||i,a=e.sort,s=void 0!==a&&a,c=[];if(null==t)return c;t=t.toLowerCase(),o&&(t=" ".concat(t," "));var h=t.length-r+1;if(h<1)return c;for(;h--;)c[h]=t.substr(h,r);return s&&c.sort((function(t,e){return t==e?0:t<e?-1:1})),c}var W=function(){function e(n){var r,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(i=(r={}).threshold,threshold=void 0===i?b.threshold:i,r);t(this,e),this.options=o,this.patternNgram=D(n,{sort:!0})}return n(e,[{key:"searchIn",value:function(t){var e=t.ng;e||(e=D(t.$,{sort:!0}),t.ng=e);var n,r,i,o=(n=this.patternNgram,i=function(t,e){for(var n=[],r=0,i=0;r<t.length&&i<e.length;){var o=t[r],a=e[i];o<a?(n.push(o),r+=1):a<o?(n.push(a),i+=1):(n.push(a),r+=1,i+=1)}for(;r<t.length;)n.push(t[r]),r+=1;for(;i<e.length;)n.push(e[i]),i+=1;return n}(n,r=e),1-function(t,e){for(var n=[],r=0,i=0;r<t.length&&i<e.length;){var o=t[r],a=e[i];o==a?(n.push(o),r+=1,i+=1):o<a?r+=1:(o>a||(r+=1),i+=1)}return n}(n,r).length/i.length),a=o<this.options.threshold;return{score:a?o:1,isMatch:a}}}],[{key:"condition",value:function(t){return t.length>32}}]),e}();function q(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?M:r,o=n.ngrams,a=void 0!==o&&o,s=[];if(g(e[0]))for(var c=0,h=e.length;c<h;c+=1){var u=e[c];if(k(u)){var l={$:u,idx:c};a&&(l.ng=D(u,{sort:!0})),s.push(l)}}else for(var f=t.length,v=0,d=e.length;v<d;v+=1){for(var p=e[v],m={idx:v,$:{}},b=0;b<f;b+=1){var x=t[b],w=i(p,x);if(k(w))if(y(w)){for(var S=[],_=[{arrayIndex:-1,value:w}];_.length;){var O=_.pop(),I=O.arrayIndex,C=O.value;if(k(C))if(g(C)){var L={$:C,idx:I};a&&(L.ng=D(C,{sort:!0})),S.push(L)}else if(y(C))for(var A=0,$=C.length;A<$;A+=1)_.push({arrayIndex:A,value:C[A]})}m.$[x]=S}else{var j={$:w};a&&(j.ng=D(w,{sort:!0})),m.$[x]=j}}s.push(m)}return s}var T=function(){function e(n){if(t(this,e),this._keys={},this._keyNames=[],this._length=n.length,n.length&&g(n[0]))for(var r=0;r<this._length;r+=1){var i=n[r];this._keys[i]={weight:1},this._keyNames.push(i)}else{for(var o=0,a=0;a<this._length;a+=1){var s=n[a];if(!Object.prototype.hasOwnProperty.call(s,"name"))throw new Error('Missing "name" property in key object');var c=s.name;if(this._keyNames.push(c),!Object.prototype.hasOwnProperty.call(s,"weight"))throw new Error('Missing "weight" property in key object');var h=s.weight;if(h<=0||h>=1)throw new Error('"weight" property in key must be in the range of (0, 1)');this._keys[c]={weight:h},o+=h}for(var u=0;u<this._length;u+=1){var l=this._keyNames[u],f=this._keys[l].weight;this._keys[l].weight=f/o}}}return n(e,[{key:"get",value:function(t,e){return this._keys[t]?this._keys[t][e]:-1}},{key:"keys",value:function(){return this._keyNames}},{key:"count",value:function(){return this._length}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function U(t,e){var n=t.matches;if(e.matches=[],k(n))for(var r=0,i=n.length;r<i;r+=1){var o=n[r];if(k(o.indices)&&0!==o.indices.length){var a={indices:o.indices,value:o.value};o.key&&(a.key=o.key),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)}}}function z(t,e){e.score=t.score}var J=[],K=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t(this,e),this.options=o({},b,{},r),this._processKeys(this.options.keys),this.setCollection(n,i)}return n(e,[{key:"setCollection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.list=t,this.listIsStringArray=g(t[0]),e?this.setIndex(e):this.setIndex(this._createIndex())}},{key:"setIndex",value:function(t){this._indexedList=t}},{key:"_processKeys",value:function(t){this._keyStore=new T(t)}},{key:"_createIndex",value:function(){return q(this._keyStore.keys(),this.list,{getFn:this.options.getFn})}},{key:"search",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{limit:!1},n=this.options.shouldSort,r=null,i=0,o=J.length;i<o;i+=1){var a=J[i];if(a.condition(t,this.options)){r=new a(t,this.options);break}}r||(r=new w(t,this.options));var s=this._searchUsing(r);return this._computeScore(s),n&&this._sort(s),e.limit&&m(e.limit)&&(s=s.slice(0,e.limit)),this._format(s)}},{key:"_searchUsing",value:function(t){var e=this._indexedList,n=[],r=this.options.includeMatches;if(this.listIsStringArray)for(var i=0,o=e.length;i<o;i+=1){var a=e[i],s=a.$,c=a.idx;if(k(s)){var h=t.searchIn(a),u=h.isMatch,l=h.score;if(u){var f={score:l,value:s};r&&(f.indices=h.matchedIndices),n.push({item:s,idx:c,matches:[f]})}}}else for(var v=this._keyStore.keys(),d=this._keyStore.count(),p=0,g=e.length;p<g;p+=1){var m=e[p],M=m.$,b=m.idx;if(k(M)){for(var x=[],w=0;w<d;w+=1){var S=v[w],_=M[S];if(k(_))if(y(_))for(var O=0,I=_.length;O<I;O+=1){var C=_[O],L=C.$,A=C.idx;if(k(L)){var $=t.searchIn(C),j=$.isMatch,P=$.score;if(j){var E={score:P,key:S,value:L,idx:A};r&&(E.indices=$.matchedIndices),x.push(E)}}}else{var N=_.$,R=t.searchIn(_),F=R.isMatch,D=R.score;if(!F)continue;var W={score:D,key:S,value:N};r&&(W.indices=R.matchedIndices),x.push(W)}}x.length&&n.push({idx:b,item:M,matches:x})}}return n}},{key:"_computeScore",value:function(t){for(var e=0,n=t.length;e<n;e+=1){for(var r=t[e],i=r.matches,o=i.length,a=1,s=0;s<o;s+=1){var c=i[s],h=c.key,u=this._keyStore.get(h,"weight"),l=u>-1?u:1,f=0===c.score&&u>-1?Number.EPSILON:c.score;a*=Math.pow(f,l)}r.score=a}}},{key:"_sort",value:function(t){t.sort(this.options.sortFn)}},{key:"_format",value:function(t){var e=[],n=this.options,r=n.includeMatches,i=n.includeScore,o=[];r&&o.push(U),i&&o.push(z);for(var a=0,s=t.length;a<s;a+=1){var c=t[a],h=c.idx,u={item:this.list[h],refIndex:h};if(o.length)for(var l=0,f=o.length;l<f;l+=1)o[l](c,u);e.push(u)}return e}}],[{key:"register",value:function(){J.push.apply(J,arguments)}}]),e}();return K.register(F,W),K.version="5.2.0-alpha.0",K.createIndex=q,K.config=b,K},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Fuse=e();

@@ -16,3 +16,3 @@ {

],
"version": "5.1.0",
"version": "5.2.0-alpha.0",
"description": "Lightweight fuzzy-search",

@@ -31,5 +31,5 @@ "license": "Apache-2.0",

"scripts": {
"dev": "rollup -w -c scripts/configs.js --environment TARGET:umd-dev",
"dev:cjs": "rollup -w -c scripts/configs.js --environment TARGET:commonjs",
"dev:esm": "rollup -w -c scripts/configs.js --environment TARGET:esm",
"dev": "rollup -w -c scripts/configs.js --environment TARGET:umd-dev-full",
"dev:cjs": "rollup -w -c scripts/configs.js --environment TARGET:commonjs-full",
"dev:esm": "rollup -w -c scripts/configs.js --environment TARGET:esm-dev-full",
"build": "node scripts/build.main.js",

@@ -36,0 +36,0 @@ "test": "jest",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc