Skip to content

Commit

Permalink
chore(release): 6.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
krisk committed Jan 5, 2021
1 parent 94766b2 commit 36f1185
Show file tree
Hide file tree
Showing 13 changed files with 553 additions and 520 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [6.4.6](https://github.com/krisk/Fuse/compare/v6.4.5...v6.4.6) (2021-01-05)


### Bug Fixes

* **typescript:** fix search typings ([94766b2](https://github.com/krisk/Fuse/commit/94766b2ffcc2be0e5f15daa9a29cd92adbe2647a)), closes [#527](https://github.com/krisk/Fuse/issues/527)

### [6.4.5](https://github.com/krisk/Fuse/compare/v6.4.4...v6.4.5) (2021-01-01)


Expand Down
169 changes: 86 additions & 83 deletions dist/fuse.basic.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Fuse.js v6.4.5 - Lightweight fuzzy-search (http://fusejs.io)
* Fuse.js v6.4.6 - Lightweight fuzzy-search (http://fusejs.io)
*
* Copyright (c) 2021 Kiro Risk (http://kiro.me)
* All Rights Reserved. Apache Software License 2.0
Expand Down Expand Up @@ -384,6 +384,7 @@ var SPACE = /[^ ]+/g; // Field-length norm: the shorter the field, the higher th
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;
Expand All @@ -392,7 +393,9 @@ function norm() {
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;
},
Expand Down Expand Up @@ -614,42 +617,6 @@ function parseIndex(data) {
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,
Expand Down Expand Up @@ -1146,6 +1113,85 @@ function parse(query, options) {
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] : {};
Expand Down Expand Up @@ -1401,52 +1447,9 @@ var Fuse = /*#__PURE__*/function () {
}]);

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.5';
Fuse.version = '6.4.6';
Fuse.createIndex = createIndex;
Fuse.parseIndex = parseIndex;
Fuse.config = Config;
Expand Down

0 comments on commit 36f1185

Please sign in to comment.