Fuzzy Search with fuse.js demo
const Fetch = require('node-fetch');
const Fuse = require('fuse.js');
const fruits = [
{
name: "Apple",
color: "red"
},
{
name: "Orange",
color: "orange"
},
{
name: "Banana",
color: "yellow"
}
]
const options = {
isCaseSensitive: false,
findAllMatches: true,
includeMatches: false,
includeScore: true,
useExtendedSearch: false,
threshold: 0.4,
location: 0,
distance: 2,
maxPatternLength: 32,
minMatchCharLength: 2,
keys: ["name"]
};
const fuse = new Fuse(fruits, options)
let input = "banna"
let result = fuse.search(input)
console.log(result)
no comments