perf: use quick-score instead of fuse.js #306

This commit is contained in:
WDaan 2022-11-15 14:27:14 +01:00
parent 67b1551b36
commit f9434c3756
3 changed files with 16 additions and 23 deletions

25
package-lock.json generated
View file

@ -11,8 +11,8 @@
"apexcharts": "^3.35.0",
"axios": "^0.26.1",
"dayjs": "^1.10.4",
"fuse.js": "^6.5.3",
"lodash": "^4.17.21",
"quick-score": "^0.2.0",
"typeface-roboto": "^1.1.13",
"typeface-roboto-mono": "^1.1.13",
"uuid": "^8.3.2",
@ -4382,14 +4382,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/fuse.js": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz",
"integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==",
"engines": {
"node": ">=10"
}
},
"node_modules/gensync": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
@ -5816,6 +5808,11 @@
}
]
},
"node_modules/quick-score": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/quick-score/-/quick-score-0.2.0.tgz",
"integrity": "sha512-y9PW9rl7BhjTykkGYi4wh0FsXWrWFv3IJVxtAI9FMargSOhqzRN3OjO2itpw63PoSu1FY07i8B2aCwpolQucOQ=="
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@ -10771,11 +10768,6 @@
"integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==",
"dev": true
},
"fuse.js": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz",
"integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA=="
},
"gensync": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
@ -11801,6 +11793,11 @@
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"dev": true
},
"quick-score": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/quick-score/-/quick-score-0.2.0.tgz",
"integrity": "sha512-y9PW9rl7BhjTykkGYi4wh0FsXWrWFv3IJVxtAI9FMargSOhqzRN3OjO2itpw63PoSu1FY07i8B2aCwpolQucOQ=="
},
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",

View file

@ -14,8 +14,8 @@
"apexcharts": "^3.35.0",
"axios": "^0.26.1",
"dayjs": "^1.10.4",
"fuse.js": "^6.5.3",
"lodash": "^4.17.21",
"quick-score": "^0.2.0",
"typeface-roboto": "^1.1.13",
"typeface-roboto-mono": "^1.1.13",
"uuid": "^8.3.2",

View file

@ -129,8 +129,8 @@
<script>
import { mapState, mapGetters } from 'vuex'
import Fuse from 'fuse.js'
import { mdiTextBoxSearch, mdiChevronLeftCircle, mdiMagnify, mdiCheckboxMarked, mdiCheckboxBlankOutline, mdiSort } from '@mdi/js'
import { QuickScore } from "quick-score"
import Torrent from '@/components/Torrent/Torrent.vue'
import TorrentRightClickMenu from '@/components/Torrent/TorrentRightClickMenu.vue'
@ -171,14 +171,10 @@ export default {
torrents() {
if (!this.hasSearchFilter) return this.getTorrents()
const options = {
threshold: 0.25,
shouldSort: false,
keys: ['name', 'size', 'state', 'hash', 'savePath', 'tags', 'category']
}
const fuse = new Fuse(this.getTorrents(), options)
// return this.getTorrents()
return fuse.search(this.input).map(el => el.item)
const qs = new QuickScore(this.getTorrents(), ['name', 'size', 'state', 'hash', 'savePath', 'tags', 'category'])
return qs.search(this.input).map(el => el.item)
},
pageNumber: {
get() {