把 QuickScore 整体打包到一个文件
<script src="quicksore.js"></script>
<script>
var qs = new QuickScore(["poerlang" , "客服CRM", "cr_GitHub_m","crm客服", "hello_m_r"]);
var results = qs.search("crm");
console.log(results);
</script>
output:
[{
"item": "crm客服",
"score": 0.96,
"matches": [
[0, 3]
],
"_": "crm客服"
}, {
"item": "客服CRM",
"score": 0.9399999999999998,
"matches": [
[2, 5]
],
"_": "客服crm"
}, {
"item": "cr_GitHub_m",
"score": 0.827272727272727,
"matches": [
[0, 2],
[10, 11]
],
"_": "cr_github_m"
}]
qs.setItems(['abc', 'add']);
results = qs.search("a");
console.log(results)
var lists = [
{name:'crm',objref:1,title:'a crm client'},
{name:'good',objref:1,title:'things'}
]
var qs = new QuickScore(lists,['name','title']);
var results = qs.search("cr");
console.log(results);