mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-12-22 09:05:07 +01:00
update fuse.js to v6.4.6
credits: https://github.com/krisk/Fuse/releases/tag/v6.4.6
This commit is contained in:
parent
3b5c7faaec
commit
09de369d2f
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Fuse.js v6.4.3 - Lightweight fuzzy-search (http://fusejs.io)
|
||||
* Fuse.js v6.4.6 - Lightweight fuzzy-search (http://fusejs.io)
|
||||
*
|
||||
* Copyright (c) 2020 Kiro Risk (http://kiro.me)
|
||||
* Copyright (c) 2021 Kiro Risk (http://kiro.me)
|
||||
* All Rights Reserved. Apache Software License 2.0
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
@ -466,6 +466,7 @@
|
||||
function norm() {
|
||||
var mantissa = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3;
|
||||
var cache = new Map();
|
||||
var m = Math.pow(10, mantissa);
|
||||
return {
|
||||
get: function get(value) {
|
||||
var numTokens = value.match(SPACE).length;
|
||||
@ -474,7 +475,9 @@
|
||||
return cache.get(numTokens);
|
||||
}
|
||||
|
||||
var n = parseFloat((1 / Math.sqrt(numTokens)).toFixed(mantissa));
|
||||
var norm = 1 / Math.sqrt(numTokens); // In place of `toFixed(mantissa)`, for faster computation
|
||||
|
||||
var n = parseFloat(Math.round(norm * m) / m);
|
||||
cache.set(numTokens, n);
|
||||
return n;
|
||||
},
|
||||
@ -696,42 +699,6 @@
|
||||
return myIndex;
|
||||
}
|
||||
|
||||
function transformMatches(result, data) {
|
||||
var matches = result.matches;
|
||||
data.matches = [];
|
||||
|
||||
if (!isDefined(matches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
matches.forEach(function (match) {
|
||||
if (!isDefined(match.indices) || !match.indices.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var indices = match.indices,
|
||||
value = match.value;
|
||||
var obj = {
|
||||
indices: indices,
|
||||
value: value
|
||||
};
|
||||
|
||||
if (match.key) {
|
||||
obj.key = match.key.src;
|
||||
}
|
||||
|
||||
if (match.idx > -1) {
|
||||
obj.refIndex = match.idx;
|
||||
}
|
||||
|
||||
data.matches.push(obj);
|
||||
});
|
||||
}
|
||||
|
||||
function transformScore(result, data) {
|
||||
data.score = result.score;
|
||||
}
|
||||
|
||||
function computeScore(pattern) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
_ref$errors = _ref.errors,
|
||||
@ -1503,7 +1470,7 @@
|
||||
var isMatch = !!indices.length;
|
||||
return {
|
||||
isMatch: isMatch,
|
||||
score: isMatch ? 1 : 0,
|
||||
score: isMatch ? 0 : 1,
|
||||
indices: indices
|
||||
};
|
||||
}
|
||||
@ -1838,6 +1805,85 @@
|
||||
return next(query);
|
||||
}
|
||||
|
||||
function computeScore$1(results, _ref) {
|
||||
var _ref$ignoreFieldNorm = _ref.ignoreFieldNorm,
|
||||
ignoreFieldNorm = _ref$ignoreFieldNorm === void 0 ? Config.ignoreFieldNorm : _ref$ignoreFieldNorm;
|
||||
results.forEach(function (result) {
|
||||
var totalScore = 1;
|
||||
result.matches.forEach(function (_ref2) {
|
||||
var key = _ref2.key,
|
||||
norm = _ref2.norm,
|
||||
score = _ref2.score;
|
||||
var weight = key ? key.weight : null;
|
||||
totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
|
||||
});
|
||||
result.score = totalScore;
|
||||
});
|
||||
}
|
||||
|
||||
function transformMatches(result, data) {
|
||||
var matches = result.matches;
|
||||
data.matches = [];
|
||||
|
||||
if (!isDefined(matches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
matches.forEach(function (match) {
|
||||
if (!isDefined(match.indices) || !match.indices.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var indices = match.indices,
|
||||
value = match.value;
|
||||
var obj = {
|
||||
indices: indices,
|
||||
value: value
|
||||
};
|
||||
|
||||
if (match.key) {
|
||||
obj.key = match.key.src;
|
||||
}
|
||||
|
||||
if (match.idx > -1) {
|
||||
obj.refIndex = match.idx;
|
||||
}
|
||||
|
||||
data.matches.push(obj);
|
||||
});
|
||||
}
|
||||
|
||||
function transformScore(result, data) {
|
||||
data.score = result.score;
|
||||
}
|
||||
|
||||
function format(results, docs) {
|
||||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
||||
_ref$includeMatches = _ref.includeMatches,
|
||||
includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
|
||||
_ref$includeScore = _ref.includeScore,
|
||||
includeScore = _ref$includeScore === void 0 ? Config.includeScore : _ref$includeScore;
|
||||
|
||||
var transformers = [];
|
||||
if (includeMatches) transformers.push(transformMatches);
|
||||
if (includeScore) transformers.push(transformScore);
|
||||
return results.map(function (result) {
|
||||
var idx = result.idx;
|
||||
var data = {
|
||||
item: docs[idx],
|
||||
refIndex: idx
|
||||
};
|
||||
|
||||
if (transformers.length) {
|
||||
transformers.forEach(function (transformer) {
|
||||
transformer(result, data);
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
var Fuse = /*#__PURE__*/function () {
|
||||
function Fuse(docs) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
@ -2189,52 +2235,9 @@
|
||||
}]);
|
||||
|
||||
return Fuse;
|
||||
}(); // Practical scoring function
|
||||
}();
|
||||
|
||||
function computeScore$1(results, _ref8) {
|
||||
var _ref8$ignoreFieldNorm = _ref8.ignoreFieldNorm,
|
||||
ignoreFieldNorm = _ref8$ignoreFieldNorm === void 0 ? Config.ignoreFieldNorm : _ref8$ignoreFieldNorm;
|
||||
results.forEach(function (result) {
|
||||
var totalScore = 1;
|
||||
result.matches.forEach(function (_ref9) {
|
||||
var key = _ref9.key,
|
||||
norm = _ref9.norm,
|
||||
score = _ref9.score;
|
||||
var weight = key ? key.weight : null;
|
||||
totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
|
||||
});
|
||||
result.score = totalScore;
|
||||
});
|
||||
}
|
||||
|
||||
function format(results, docs) {
|
||||
var _ref10 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
||||
_ref10$includeMatches = _ref10.includeMatches,
|
||||
includeMatches = _ref10$includeMatches === void 0 ? Config.includeMatches : _ref10$includeMatches,
|
||||
_ref10$includeScore = _ref10.includeScore,
|
||||
includeScore = _ref10$includeScore === void 0 ? Config.includeScore : _ref10$includeScore;
|
||||
|
||||
var transformers = [];
|
||||
if (includeMatches) transformers.push(transformMatches);
|
||||
if (includeScore) transformers.push(transformScore);
|
||||
return results.map(function (result) {
|
||||
var idx = result.idx;
|
||||
var data = {
|
||||
item: docs[idx],
|
||||
refIndex: idx
|
||||
};
|
||||
|
||||
if (transformers.length) {
|
||||
transformers.forEach(function (transformer) {
|
||||
transformer(result, data);
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
Fuse.version = '6.4.3';
|
||||
Fuse.version = '6.4.6';
|
||||
Fuse.createIndex = createIndex;
|
||||
Fuse.parseIndex = parseIndex;
|
||||
Fuse.config = Config;
|
||||
|
Loading…
Reference in New Issue
Block a user