mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 20:40:15 +02:00
add fuse search utils
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
import Fuse from 'fuse.js';
|
||||
|
||||
import { QueueSong } from '/@/shared/types/domain-types';
|
||||
|
||||
export const searchSongs = (songs: QueueSong[], searchTerm: string) => {
|
||||
const fuse = new Fuse(songs, {
|
||||
fieldNormWeight: 1,
|
||||
ignoreLocation: true,
|
||||
keys: [
|
||||
'name',
|
||||
'album',
|
||||
{
|
||||
getFn: (song) => song.artists.map((artist) => artist.name),
|
||||
name: 'artist',
|
||||
},
|
||||
],
|
||||
threshold: 0,
|
||||
});
|
||||
return fuse.search(searchTerm).map((item) => item.item);
|
||||
};
|
||||
Reference in New Issue
Block a user