Comparing version 2.0.2 to 2.1.0-beta
{ | ||
"name": "fuse.js", | ||
"author": "Kirollos Risk", | ||
"version": "2.0.2", | ||
"version": "2.1.0-beta", | ||
"description": "Lightweight fuzzy-search", | ||
@@ -6,0 +6,0 @@ "license": "Apache", |
@@ -7,3 +7,3 @@ # Fuse | ||
Fuse is a full JavaScript fuzzy-search implementation that searches accross the keys of every record in a list. | ||
Fuse is a full JavaScript fuzzy-search implementation that searches across the keys of every record in a list. | ||
@@ -155,2 +155,20 @@ - [Demo & usage](http://kiro.me/exp/fuse.html) | ||
## Weighted Search | ||
In some cases you may want certain keys to be weighted differently: | ||
```javascript | ||
var fuse = new Fuse(books, { | ||
keys: [{ | ||
name: 'title', | ||
weight: 0.3 | ||
}, { | ||
name: 'author', | ||
weight: 0.7 | ||
}], | ||
}); | ||
``` | ||
Where `0 < weight <= 1` | ||
## Coding conventions | ||
@@ -157,0 +175,0 @@ |
@@ -102,3 +102,3 @@ /** | ||
Fuse.VERSION = '2.0.1' | ||
Fuse.VERSION = '2.1.0' | ||
@@ -117,3 +117,3 @@ /** | ||
Fuse.prototype.search = function (pattern) { | ||
if (this.options.verbose) log('=====================\n', 'Search term:', pattern) | ||
if (this.options.verbose) log('\nSearch term:', pattern, '\n') | ||
@@ -123,2 +123,3 @@ this.pattern = pattern | ||
this.resultMap = {} | ||
this._keyMap = null | ||
@@ -158,2 +159,4 @@ this._prepareSearchers() | ||
var keysLen = keys.length | ||
var key | ||
var weight | ||
var item = null | ||
@@ -168,5 +171,6 @@ var i | ||
for (i = 0; i < listLen; i++) { | ||
this._analyze(list[i], i, i) | ||
this._analyze('', list[i], i, i) | ||
} | ||
} else { | ||
this._keyMap = {} | ||
// Otherwise, the first item is an Object (hopefully), and thus the searching | ||
@@ -179,3 +183,18 @@ // is done on the values of the keys of each item. | ||
for (j = 0; j < keysLen; j++) { | ||
this._analyze(getFn(item, keys[j], []), item, i) | ||
key = keys[j] | ||
if (typeof key !== 'string') { | ||
weight = (1 - key.weight) || 1 | ||
this._keyMap[key.name] = { | ||
weight: weight | ||
} | ||
if (key.weight <= 0 || key.weight > 1) { | ||
throw new Error('Key weight has to be > 0 and <= 1') | ||
} | ||
key = key.name | ||
} else { | ||
this._keyMap[key] = { | ||
weight: 1 | ||
} | ||
} | ||
this._analyze(key, getFn(item, key, []), item, i) | ||
} | ||
@@ -186,3 +205,3 @@ } | ||
Fuse.prototype._analyze = function (text, entity, index) { | ||
Fuse.prototype._analyze = function (key, text, entity, index) { | ||
var options = this.options | ||
@@ -216,3 +235,4 @@ var words | ||
if (options.verbose) log('---------\n', 'Record:', words) | ||
if (options.verbose) log('---------\nKey:', key) | ||
if (options.verbose) log('Record:', words) | ||
@@ -238,3 +258,3 @@ if (this.options.tokenize) { | ||
} | ||
if (options.verbose) log('Score for "' + tokenSearcher.pattern + '":', termScores) | ||
if (options.verbose) log('Token scores:', termScores) | ||
} | ||
@@ -249,4 +269,3 @@ | ||
if (options.verbose) log('Individual word score average:', averageScore) | ||
if (options.verbose) log('Token score average:', averageScore) | ||
} | ||
@@ -263,3 +282,3 @@ | ||
if (options.verbose) log('Average', finalScore) | ||
if (options.verbose) log('Score average:', finalScore) | ||
@@ -270,11 +289,18 @@ // If a match is found, add the item to <rawResults>, including its score | ||
existingResult = this.resultMap[index] | ||
if (existingResult) { | ||
// Use the lowest score | ||
// existingResult.score, bitapResult.score | ||
existingResult.scores.push(finalScore) | ||
existingResult.scores.push({ | ||
key: key, | ||
score: finalScore | ||
}) | ||
} else { | ||
// Add it to the raw result list | ||
// Add it to the raw result listå | ||
this.resultMap[index] = { | ||
item: entity, | ||
scores: [finalScore] | ||
scores: [{ | ||
key: key, | ||
score: finalScore | ||
}] | ||
} | ||
@@ -286,3 +312,3 @@ this.results.push(this.resultMap[index]) | ||
for (i = 0; i < text.length; i++) { | ||
this._analyze(text[i], entity, index) | ||
this._analyze(key, text[i], entity, index) | ||
} | ||
@@ -295,7 +321,14 @@ } | ||
var j | ||
var keyMap = this._keyMap | ||
var totalScore | ||
var currScore | ||
var scoreLen | ||
var score | ||
var weight | ||
var results = this.results | ||
var bestScore | ||
var nScore | ||
if (this.options.verbose) log('\n\nComputing score:\n') | ||
for (i = 0; i < results.length; i++) { | ||
@@ -305,6 +338,26 @@ totalScore = 0 | ||
scoreLen = currScore.length | ||
bestScore = 1 | ||
for (j = 0; j < scoreLen; j++) { | ||
totalScore += currScore[j] | ||
score = currScore[j].score | ||
weight = keyMap ? keyMap[currScore[j].key].weight : 1 | ||
nScore = score * weight | ||
if (weight !== 1) { | ||
bestScore = Math.min(bestScore, nScore) | ||
} else { | ||
totalScore += nScore | ||
currScore[j].nScore = nScore | ||
} | ||
} | ||
results[i].score = totalScore / scoreLen | ||
if (bestScore === 1) { | ||
results[i].score = totalScore / scoreLen | ||
} else { | ||
results[i].score = bestScore | ||
} | ||
if (this.options.verbose) log(results[i]) | ||
} | ||
@@ -316,3 +369,3 @@ } | ||
if (options.shouldSort) { | ||
if (options.verbose) log('Sorting....') | ||
if (options.verbose) log('\n\nSorting....') | ||
this.results.sort(options.sortFn) | ||
@@ -333,3 +386,3 @@ } | ||
if (options.verbose) log('------------\n', 'Output:\n', results) | ||
if (options.verbose) log('\n\nOutput:\n\n', results) | ||
@@ -543,3 +596,2 @@ // Helper function, here for speed-up, which replaces the item with its value, | ||
if (this.pattern === text) { | ||
// console.log("EXACT") | ||
// Exact match | ||
@@ -614,3 +666,2 @@ return { | ||
charMatch = this.patternAlphabet[text.charAt(j - 1)] | ||
// console.log('charMatch', charMatch, text.charAt(j - 1)) | ||
@@ -617,0 +668,0 @@ if (i === 0) { |
@@ -20,2 +20,2 @@ /** | ||
*/ | ||
!function(t){"use strict";function e(){console.log.apply(console,arguments)}function s(t,e){var s,n,r,i;for(this.list=t,this.options=e=e||{},s=0,i=["sort","shouldSort","verbose","tokenize"],n=i.length;n>s;s++)r=i[s],this.options[r]=r in e?e[r]:h[r];for(s=0,i=["searchFn","sortFn","keys","getFn","include"],n=i.length;n>s;s++)r=i[s],this.options[r]=e[r]||h[r]}function n(t,e,s){var i,o,h,a,p,c;if(e){if(h=e.indexOf("."),-1!==h?(i=e.slice(0,h),o=e.slice(h+1)):i=e,a=t[i],null!==a&&void 0!==a)if(o||"string"!=typeof a&&"number"!=typeof a)if(r(a))for(p=0,c=a.length;c>p;p++)n(a[p],o,s);else o&&n(a,o,s);else s.push(a)}else s.push(t);return s}function r(t){return"[object Array]"===Object.prototype.toString.call(t)}function i(t,e){e=e||{},this.options=e,this.options.location=e.location||i.defaultOptions.location,this.options.distance="distance"in e?e.distance:i.defaultOptions.distance,this.options.threshold="threshold"in e?e.threshold:i.defaultOptions.threshold,this.options.maxPatternLength=e.maxPatternLength||i.defaultOptions.maxPatternLength,this.pattern=e.caseSensitive?t:t.toLowerCase(),this.patternLen=t.length,this.patternLen<=this.options.maxPatternLength&&(this.matchmask=1<<this.patternLen-1,this.patternAlphabet=this._calculatePatternAlphabet())}var o=/ +/g,h={id:null,caseSensitive:!1,include:[],shouldSort:!0,searchFn:i,sortFn:function(t,e){return t.score-e.score},getFn:n,keys:[],verbose:!1,tokenize:!1};s.VERSION="2.0.1",s.prototype.set=function(t){return this.list=t,t},s.prototype.search=function(t){this.options.verbose&&e("=====================\n","Search term:",t),this.pattern=t,this.results=[],this.resultMap={},this._prepareSearchers(),this._startSearch(),this._computeScore(),this._sort();var s=this._format();return s},s.prototype._prepareSearchers=function(){var t=this.options,e=this.pattern,s=t.searchFn,n=e.split(o),r=0,i=n.length;if(this.options.tokenize)for(this.tokenSearchers=[];i>r;r++)this.tokenSearchers.push(new s(n[r],t));this.fullSeacher=new s(e,t)},s.prototype._startSearch=function(){var t,e,s=this.options,n=s.getFn,r=this.list,i=r.length,o=this.options.keys,h=o.length,a=null;if("string"==typeof r[0])for(t=0;i>t;t++)this._analyze(r[t],t,t);else for(t=0;i>t;t++)for(a=r[t],e=0;h>e;e++)this._analyze(n(a,o[e],[]),a,t)},s.prototype._analyze=function(t,s,n){var i,h,a,p,c,l,u,f,d,g,v,m,S,y,b,_=this.options,L=!1;if(void 0!==t&&null!==t)if(h=[],"string"==typeof t){if(i=t.split(o),_.verbose&&e("---------\n","Record:",i),this.options.tokenize){for(a=this.tokenSearchers,p=a.length,y=0;y<this.tokenSearchers.length;y++){for(g=this.tokenSearchers[y],v=[],b=0;b<i.length;b++)m=i[b],S=g.search(m),S.isMatch?(L=!0,v.push(S.score),h.push(S.score)):(v.push(1),h.push(1));_.verbose&&e('Score for "'+g.pattern+'":',v)}for(l=h[0],f=h.length,y=1;f>y;y++)l+=h[y];l/=f,_.verbose&&e("Individual word score average:",l)}d=this.fullSeacher.search(t),_.verbose&&e("Full text score:",d.score),u=d.score,void 0!==l&&(u=(u+l)/2),_.verbose&&e("Average",u),(L||d.isMatch)&&(c=this.resultMap[n],c?c.scores.push(u):(this.resultMap[n]={item:s,scores:[u]},this.results.push(this.resultMap[n])))}else if(r(t))for(y=0;y<t.length;y++)this._analyze(t[y],s,n)},s.prototype._computeScore=function(){var t,e,s,n,r,i=this.results;for(t=0;t<i.length;t++){for(s=0,n=i[t].scores,r=n.length,e=0;r>e;e++)s+=n[e];i[t].score=s/r}},s.prototype._sort=function(){var t=this.options;t.shouldSort&&(t.verbose&&e("Sorting...."),this.results.sort(t.sortFn))},s.prototype._format=function(){var t,s,n,r,i,o=this.options,h=o.getFn,a=[],p=this.results;for(o.verbose&&e("------------\n","Output:\n",p),r=o.id?function(t){p[t].item=h(p[t].item,o.id,[])[0]}:function(){},i=function(t){var e,s,n;if(o.include.length>0)for(e={item:p[t].item},n=0;n<o.include.length;n++)s=o.include[n],e[s]=p[t][s];else e=p[t].item;return e},s=0,n=p.length;n>s;s++)r(s),t=i(s),a.push(t);return a},i.defaultOptions={location:0,distance:100,threshold:.6,maxPatternLength:32},i.prototype._calculatePatternAlphabet=function(){var t={},e=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]|=1<<this.pattern.length-e-1;return t},i.prototype._bitapScore=function(t,e){var s=t/this.patternLen,n=Math.abs(this.options.location-e);return this.options.distance?s+n/this.options.distance:n?1:s},i.prototype.search=function(t){var e,s,n,r,i,h,a,p,c,l,u,f,d,g,v,m,S,y,b=this.options;if(t=b.caseSensitive?t:t.toLowerCase(),this.pattern===t)return{isMatch:!0,score:0};if(this.patternLen>b.maxPatternLength)return S=t.match(new RegExp(this.pattern.replace(o,"|"))),y=!!S,{isMatch:y,score:y?.5:1};for(r=b.location,n=t.length,i=b.threshold,h=t.indexOf(this.pattern,r),-1!=h&&(i=Math.min(this._bitapScore(0,h),i),h=t.lastIndexOf(this.pattern,r+this.patternLen),-1!=h&&(i=Math.min(this._bitapScore(0,h),i))),h=-1,v=1,m=[],c=this.patternLen+n,e=0;e<this.patternLen;e++){for(a=0,p=c;p>a;)this._bitapScore(e,r+p)<=i?a=p:c=p,p=Math.floor((c-a)/2+a);for(c=p,l=Math.max(1,r-p+1),u=Math.min(r+p,n)+this.patternLen,f=Array(u+2),f[u+1]=(1<<e)-1,s=u;s>=l;s--)if(g=this.patternAlphabet[t.charAt(s-1)],0===e?f[s]=(f[s+1]<<1|1)&g:f[s]=(f[s+1]<<1|1)&g|((d[s+1]|d[s])<<1|1)|d[s+1],f[s]&this.matchmask&&(v=this._bitapScore(e,s-1),i>=v)){if(i=v,h=s-1,m.push(h),!(h>r))break;l=Math.max(1,2*r-h)}if(this._bitapScore(e+1,r)>i)break;d=f}return{isMatch:h>=0,score:0===v?.001:v}},"object"==typeof exports?module.exports=s:"function"==typeof define&&define.amd?define(function(){return s}):t.Fuse=s}(this); | ||
!function(t){"use strict";function e(){console.log.apply(console,arguments)}function s(t,e){var s,n,i,o;for(this.list=t,this.options=e=e||{},s=0,o=["sort","shouldSort","verbose","tokenize"],n=o.length;n>s;s++)i=o[s],this.options[i]=i in e?e[i]:h[i];for(s=0,o=["searchFn","sortFn","keys","getFn","include"],n=o.length;n>s;s++)i=o[s],this.options[i]=e[i]||h[i]}function n(t,e,s){var o,r,h,a,p,c;if(e){if(h=e.indexOf("."),-1!==h?(o=e.slice(0,h),r=e.slice(h+1)):o=e,a=t[o],null!==a&&void 0!==a)if(r||"string"!=typeof a&&"number"!=typeof a)if(i(a))for(p=0,c=a.length;c>p;p++)n(a[p],r,s);else r&&n(a,r,s);else s.push(a)}else s.push(t);return s}function i(t){return"[object Array]"===Object.prototype.toString.call(t)}function o(t,e){e=e||{},this.options=e,this.options.location=e.location||o.defaultOptions.location,this.options.distance="distance"in e?e.distance:o.defaultOptions.distance,this.options.threshold="threshold"in e?e.threshold:o.defaultOptions.threshold,this.options.maxPatternLength=e.maxPatternLength||o.defaultOptions.maxPatternLength,this.pattern=e.caseSensitive?t:t.toLowerCase(),this.patternLen=t.length,this.patternLen<=this.options.maxPatternLength&&(this.matchmask=1<<this.patternLen-1,this.patternAlphabet=this._calculatePatternAlphabet())}var r=/ +/g,h={id:null,caseSensitive:!1,include:[],shouldSort:!0,searchFn:o,sortFn:function(t,e){return t.score-e.score},getFn:n,keys:[],verbose:!1,tokenize:!1};s.VERSION="2.1.0",s.prototype.set=function(t){return this.list=t,t},s.prototype.search=function(t){this.options.verbose&&e("\nSearch term:",t,"\n"),this.pattern=t,this.results=[],this.resultMap={},this._keyMap=null,this._prepareSearchers(),this._startSearch(),this._computeScore(),this._sort();var s=this._format();return s},s.prototype._prepareSearchers=function(){var t=this.options,e=this.pattern,s=t.searchFn,n=e.split(r),i=0,o=n.length;if(this.options.tokenize)for(this.tokenSearchers=[];o>i;i++)this.tokenSearchers.push(new s(n[i],t));this.fullSeacher=new s(e,t)},s.prototype._startSearch=function(){var t,e,s,n,i=this.options,o=i.getFn,r=this.list,h=r.length,a=this.options.keys,p=a.length,c=null;if("string"==typeof r[0])for(s=0;h>s;s++)this._analyze("",r[s],s,s);else for(this._keyMap={},s=0;h>s;s++)for(c=r[s],n=0;p>n;n++){if(t=a[n],"string"!=typeof t){if(e=1-t.weight||1,this._keyMap[t.name]={weight:e},t.weight<=0||t.weight>1)throw new Error("Key weight has to be > 0 and <= 1");t=t.name}else this._keyMap[t]={weight:1};this._analyze(t,o(c,t,[]),c,s)}},s.prototype._analyze=function(t,s,n,o){var h,a,p,c,l,u,f,g,d,y,m,v,b,S,_,k=this.options,M=!1;if(void 0!==s&&null!==s)if(a=[],"string"==typeof s){if(h=s.split(r),k.verbose&&e("---------\nKey:",t),k.verbose&&e("Record:",h),this.options.tokenize){for(p=this.tokenSearchers,c=p.length,S=0;S<this.tokenSearchers.length;S++){for(y=this.tokenSearchers[S],m=[],_=0;_<h.length;_++)v=h[_],b=y.search(v),b.isMatch?(M=!0,m.push(b.score),a.push(b.score)):(m.push(1),a.push(1));k.verbose&&e("Token scores:",m)}for(u=a[0],g=a.length,S=1;g>S;S++)u+=a[S];u/=g,k.verbose&&e("Token score average:",u)}d=this.fullSeacher.search(s),k.verbose&&e("Full text score:",d.score),f=d.score,void 0!==u&&(f=(f+u)/2),k.verbose&&e("Score average:",f),(M||d.isMatch)&&(l=this.resultMap[o],l?l.scores.push({key:t,score:f}):(this.resultMap[o]={item:n,scores:[{key:t,score:f}]},this.results.push(this.resultMap[o])))}else if(i(s))for(S=0;S<s.length;S++)this._analyze(t,s[S],n,o)},s.prototype._computeScore=function(){var t,s,n,i,o,r,h,a,p,c=this._keyMap,l=this.results;for(this.options.verbose&&e("\n\nComputing score:\n"),t=0;t<l.length;t++){for(n=0,i=l[t].scores,o=i.length,a=1,s=0;o>s;s++)r=i[s].score,h=c?c[i[s].key].weight:1,p=r*h,1!==h?a=Math.min(a,p):(n+=p,i[s].nScore=p);1===a?l[t].score=n/o:l[t].score=a,this.options.verbose&&e(l[t])}},s.prototype._sort=function(){var t=this.options;t.shouldSort&&(t.verbose&&e("\n\nSorting...."),this.results.sort(t.sortFn))},s.prototype._format=function(){var t,s,n,i,o,r=this.options,h=r.getFn,a=[],p=this.results;for(r.verbose&&e("\n\nOutput:\n\n",p),i=r.id?function(t){p[t].item=h(p[t].item,r.id,[])[0]}:function(){},o=function(t){var e,s,n;if(r.include.length>0)for(e={item:p[t].item},n=0;n<r.include.length;n++)s=r.include[n],e[s]=p[t][s];else e=p[t].item;return e},s=0,n=p.length;n>s;s++)i(s),t=o(s),a.push(t);return a},o.defaultOptions={location:0,distance:100,threshold:.6,maxPatternLength:32},o.prototype._calculatePatternAlphabet=function(){var t={},e=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]|=1<<this.pattern.length-e-1;return t},o.prototype._bitapScore=function(t,e){var s=t/this.patternLen,n=Math.abs(this.options.location-e);return this.options.distance?s+n/this.options.distance:n?1:s},o.prototype.search=function(t){var e,s,n,i,o,h,a,p,c,l,u,f,g,d,y,m,v,b,S=this.options;if(t=S.caseSensitive?t:t.toLowerCase(),this.pattern===t)return{isMatch:!0,score:0};if(this.patternLen>S.maxPatternLength)return v=t.match(new RegExp(this.pattern.replace(r,"|"))),b=!!v,{isMatch:b,score:b?.5:1};for(i=S.location,n=t.length,o=S.threshold,h=t.indexOf(this.pattern,i),-1!=h&&(o=Math.min(this._bitapScore(0,h),o),h=t.lastIndexOf(this.pattern,i+this.patternLen),-1!=h&&(o=Math.min(this._bitapScore(0,h),o))),h=-1,y=1,m=[],c=this.patternLen+n,e=0;e<this.patternLen;e++){for(a=0,p=c;p>a;)this._bitapScore(e,i+p)<=o?a=p:c=p,p=Math.floor((c-a)/2+a);for(c=p,l=Math.max(1,i-p+1),u=Math.min(i+p,n)+this.patternLen,f=Array(u+2),f[u+1]=(1<<e)-1,s=u;s>=l;s--)if(d=this.patternAlphabet[t.charAt(s-1)],0===e?f[s]=(f[s+1]<<1|1)&d:f[s]=(f[s+1]<<1|1)&d|((g[s+1]|g[s])<<1|1)|g[s+1],f[s]&this.matchmask&&(y=this._bitapScore(e,s-1),o>=y)){if(o=y,h=s-1,m.push(h),!(h>i))break;l=Math.max(1,2*i-h)}if(this._bitapScore(e+1,i)>o)break;g=f}return{isMatch:h>=0,score:0===y?.001:y}},"object"==typeof exports?module.exports=s:"function"==typeof define&&define.amd?define(function(){return s}):t.Fuse=s}(this); |
@@ -618,2 +618,3 @@ var assert = require('assert'), | ||
'Boma hamlet'] | ||
var fuse = new Fuse(items, { | ||
@@ -659,3 +660,3 @@ include: ['score'], | ||
}, | ||
'whose first value is { title: "HTML5 ", author: "Remy Sharp" }': function (result) { | ||
'whose first value is { title: "HTML5", author: "Remy Sharp" }': function (result) { | ||
assert.deepEqual(result[0], { | ||
@@ -669,1 +670,81 @@ title: 'HTML5', | ||
}).export(module) | ||
vows.describe('Weighted search').addBatch({ | ||
'Books:': { | ||
topic: function () { | ||
var items = [{ | ||
title: "Old Man's War fiction", | ||
author: 'John X', | ||
tags: ['war'] | ||
}, { | ||
title: 'Right Ho Jeeves', | ||
author: 'P.D. Mans', | ||
tags: ['fiction', 'war'] | ||
}] | ||
return items | ||
}, | ||
'When searching for the term "Man", where the author is weighted higher than title': { | ||
topic: function (items) { | ||
var options = { | ||
keys: [{ | ||
name: 'title', | ||
weight: 0.3 | ||
}, { | ||
name: 'author', | ||
weight: 0.7 | ||
}], | ||
verbose: verbose | ||
} | ||
var fuse = new Fuse(items, options) | ||
var result = fuse.search('Man') | ||
return result | ||
}, | ||
'We get the value { title: "Right Ho Jeeves", author: "P.D. Mans" }': function (result) { | ||
assert.deepEqual(result[0].title, 'Right Ho Jeeves') | ||
}, | ||
}, | ||
'When searching for the term "Man", where the title is weighted higher than author': { | ||
topic: function (items) { | ||
var options = { | ||
keys: [{ | ||
name: 'title', | ||
weight: 0.7 | ||
}, { | ||
name: 'author', | ||
weight: 0.3 | ||
}], | ||
verbose: verbose | ||
} | ||
var fuse = new Fuse(items, options) | ||
var result = fuse.search('Man') | ||
return result | ||
}, | ||
'We get the value for "John X"': function (result) { | ||
assert.deepEqual(result[0].author, 'John X') | ||
}, | ||
}, | ||
'When searching for the term "war", where tags are weighted higher than all other keys': { | ||
topic: function (items) { | ||
var options = { | ||
keys: [{ | ||
name: 'title', | ||
weight: 0.8 | ||
}, { | ||
name: 'author', | ||
weight: 0.3 | ||
}, { | ||
name: 'tags', | ||
weight: 0.2 | ||
}], | ||
verbose: verbose | ||
} | ||
var fuse = new Fuse(items, options) | ||
var result = fuse.search('fiction') | ||
return result | ||
}, | ||
'We get the value for "P.D. Mans"': function (result) { | ||
assert.deepEqual(result[0].author, 'P.D. Mans') | ||
}, | ||
} | ||
} | ||
}).export(module) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2006145
88794
181
2