Skip to content

Commit

Permalink
upgrade fuse.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed May 24, 2024
1 parent 9a7a829 commit 93fb193
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function DocumentsByOperator({ groupedByCategory, searchText, user, id, intl, ..
const fuse = new Fuse(documents, {
keys: ['title'],
threshold: 0.4,
minMatchCharLength: 2,
minMatchCharLength: 1,
ignoreLocation: true,
findAllMatches: true
});

const exactSearchResults = searchText.length > 2 ? documents.filter(exactSearch) : [];
const fuseSearchResults = fuse.search(searchText);
const fuseSearchResults = fuse.search(searchText).map(r => r.item);
return uniq([...exactSearchResults, ...fuseSearchResults]);
}

Expand Down
2 changes: 1 addition & 1 deletion components/operators/table-expanded-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const TableExpandedRow = ({ operator, fmuSearch, intl }) => {
distance: 100,
threshold: 0.15
});
fmus = fuse.search(fmuSearch);
fmus = fuse.search(fmuSearch).map(r => r.item);
}

return (
Expand Down
2 changes: 1 addition & 1 deletion components/ui/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Search extends React.Component {
this.setState({
index: 0,
value: searchText,
results: result.slice(0, 8),
results: result.map(r => r.item).slice(0, 8),
active: searchText !== ''
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"eventemitter3": "^5.0.1",
"express": "^4.19.2",
"foundation-sites": "^6.8.1",
"fuse.js": "^3.0.5",
"fuse.js": "^7.0.0",
"globalthis": "^1.0.4",
"html-react-parser": "^5.1.10",
"jsona": "^1.12.1",
Expand Down
4 changes: 2 additions & 2 deletions selectors/operators-ranking/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export const getTable = createSelector(

if (activeOperatorSearch) {
const fuse = new Fuse(operatorsTable || _data, SEARCH_OPTIONS);
operatorsTable = fuse.search(activeOperatorSearch);
operatorsTable = fuse.search(activeOperatorSearch).map(r => r.item);
}

if (activeFMUSearch) {
Expand All @@ -321,7 +321,7 @@ export const getTable = createSelector(
distance: 100,
threshold: 0.15
});
operatorsTable = fuse.search(activeFMUSearch);
operatorsTable = fuse.search(activeFMUSearch).map(r => r.item);
}

operatorsTable = (operatorsTable || _data).map(o => ({
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2626,10 +2626,10 @@ functions-have-names@^1.2.3:
resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834"
integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==

fuse.js@^3.0.5:
version "3.6.1"
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-3.6.1.tgz#7de85fdd6e1b3377c23ce010892656385fd9b10c"
integrity sha512-hT9yh/tiinkmirKrlv4KWOjztdoZo1mx9Qh4KvWqC7isoXwdUY3PNWUxceF4/qO9R6riA2C29jdTOeQOIROjgw==
fuse.js@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-7.0.0.tgz#6573c9fcd4c8268e403b4fc7d7131ffcf99a9eb2"
integrity sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==

geojson-vt@^3.2.1:
version "3.2.1"
Expand Down

0 comments on commit 93fb193

Please sign in to comment.