Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lunr

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lunr - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

build/component.json.template

11

component.json

@@ -1,1 +0,10 @@

{"name": "lunr.js", "version": "0.2.0", "main": "./lunr.js"}
{
"name": "lunr.js",
"version": "0.2.1",
"main": "lunr.js",
"ignore": [
"tests/",
"build/",
"docs/"
]
}

2

example/mustache.js

@@ -231,3 +231,3 @@ /*

}
// silently ignore unkown variables
// silently ignore unknown variables
return "";

@@ -234,0 +234,0 @@ },

@@ -49,3 +49,3 @@ /*!

/**
* Sets the property used to uniquely indetify documents added to the index,
* Sets the property used to uniquely identify documents added to the index,
* by default this property is 'id'.

@@ -111,3 +111,3 @@ *

* The document passed only needs to have the same ref property value as the
* document that was added to the index, they could be completly different
* document that was added to the index, they could be completely different
* objects.

@@ -174,3 +174,3 @@ *

* All query tokens are passed through the same pipeline that document tokens
* are passed through, so any lanugage processing involved will be run on every
* are passed through, so any language processing involved will be run on every
* query term.

@@ -177,0 +177,0 @@ *

@@ -1,13 +0,13 @@

/*!
/**
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - @VERSION
* Copyright (C) @YEAR Oliver Nightingale
* MIT Licensed
* @license
*/
;
/**
* Convinience function for instantiating a new lunr index and configuring it
* Convenience function for instantiating a new lunr index and configuring it
* with the default pipeline functions and the passed config function.
*
* When using this convinience function a new index will be created with the
* When using this convenience function a new index will be created with the
* following functions already in the pipeline:

@@ -30,3 +30,3 @@ *

* this.pipeline.add(function () {
* // some custome pipeline function
* // some custom pipeline function
* })

@@ -56,1 +56,4 @@ *

if (typeof module !== 'undefined') {
module.exports = lunr
}

@@ -87,3 +87,3 @@ /*!

lunr.SortedSet.prototype.indexOf = function (elem, startIndex) {
return this.elements.indexOf(elem)
return this.elements.indexOf(elem, startIndex)
}

@@ -90,0 +90,0 @@

@@ -68,4 +68,3 @@ /*!

re3,
re4,
origword = w;
re4;

@@ -72,0 +71,0 @@ if (w.length < 3) { return w; }

@@ -10,3 +10,3 @@ /*!

*
* This is intented to be used in the Pipeline. If the token does not pass the
* This is intended to be used in the Pipeline. If the token does not pass the
* filter then undefined will be returned.

@@ -13,0 +13,0 @@ *

@@ -109,3 +109,3 @@ /*!

lunr.TokenStore.prototype.get = function (token, root) {
return this.getNode(token).docs || {}
return this.getNode(token, root).docs || {}
}

@@ -112,0 +112,0 @@

@@ -7,3 +7,3 @@ /*!

/**
* A function for splitting a string into tokens ready to be insterted into
* A function for splitting a string into tokens ready to be inserted into
* the search index.

@@ -18,4 +18,3 @@ *

var trailingPunctuationRegex = /[\!|\,|\.|\?]+$/,
whiteSpaceSplitRegex = /\s+/
var whiteSpaceSplitRegex = /\s+/

@@ -22,0 +21,0 @@ return str.split(whiteSpaceSplitRegex).map(function (token) {

@@ -33,3 +33,3 @@ /*!

len = elems.length,
magnitude, el
el

@@ -36,0 +36,0 @@ for (var i = 0; i < len; i++) {

@@ -1,13 +0,13 @@

/*!
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.2.0
/**
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.2.1
* Copyright (C) 2013 Oliver Nightingale
* MIT Licensed
* @license
*/
;
/**
* Convinience function for instantiating a new lunr index and configuring it
* Convenience function for instantiating a new lunr index and configuring it
* with the default pipeline functions and the passed config function.
*
* When using this convinience function a new index will be created with the
* When using this convenience function a new index will be created with the
* following functions already in the pipeline:

@@ -30,3 +30,3 @@ *

* this.pipeline.add(function () {
* // some custome pipeline function
* // some custom pipeline function
* })

@@ -54,4 +54,7 @@ *

lunr.version = "0.2.0"
lunr.version = "0.2.1"
if (typeof module !== 'undefined') {
module.exports = lunr
}
/*!

@@ -63,3 +66,3 @@ * lunr.tokenizer

/**
* A function for splitting a string into tokens ready to be insterted into
* A function for splitting a string into tokens ready to be inserted into
* the search index.

@@ -74,4 +77,3 @@ *

var trailingPunctuationRegex = /[\!|\,|\.|\?]+$/,
whiteSpaceSplitRegex = /\s+/
var whiteSpaceSplitRegex = /\s+/

@@ -219,3 +221,3 @@ return str.split(whiteSpaceSplitRegex).map(function (token) {

len = elems.length,
magnitude, el
el

@@ -358,3 +360,3 @@ for (var i = 0; i < len; i++) {

lunr.SortedSet.prototype.indexOf = function (elem, startIndex) {
return this.elements.indexOf(elem)
return this.elements.indexOf(elem, startIndex)
}

@@ -516,3 +518,3 @@

/**
* Sets the property used to uniquely indetify documents added to the index,
* Sets the property used to uniquely identify documents added to the index,
* by default this property is 'id'.

@@ -578,3 +580,3 @@ *

* The document passed only needs to have the same ref property value as the
* document that was added to the index, they could be completly different
* document that was added to the index, they could be completely different
* objects.

@@ -641,3 +643,3 @@ *

* All query tokens are passed through the same pipeline that document tokens
* are passed through, so any lanugage processing involved will be run on every
* are passed through, so any language processing involved will be run on every
* query term.

@@ -861,4 +863,3 @@ *

re3,
re4,
origword = w;
re4;

@@ -994,3 +995,3 @@ if (w.length < 3) { return w; }

*
* This is intented to be used in the Pipeline. If the token does not pass the
* This is intended to be used in the Pipeline. If the token does not pass the
* filter then undefined will be returned.

@@ -1236,3 +1237,3 @@ *

lunr.TokenStore.prototype.get = function (token, root) {
return this.getNode(token).docs || {}
return this.getNode(token, root).docs || {}
}

@@ -1239,0 +1240,0 @@

@@ -1,5 +0,7 @@

/*!
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.2.0
/**
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.2.1
* Copyright (C) 2013 Oliver Nightingale
* MIT Licensed
*/var lunr=function(a){var b=new lunr.Index;return b.pipeline.add(lunr.stopWordFilter,lunr.stemmer),a&&a.call(b,b),b};lunr.version="0.2.0",lunr.tokenizer=function(a){if(Array.isArray(a))return a;var b=/[\!|\,|\.|\?]+$/,c=/\s+/;return a.split(c).map(function(a){return a.replace(/^\W+/,"").replace(/\W+$/,"").toLowerCase()})},lunr.Pipeline=function(){this._stack=[]},lunr.Pipeline.prototype.add=function(){var a=Array.prototype.slice.call(arguments);Array.prototype.push.apply(this._stack,a)},lunr.Pipeline.prototype.after=function(a,b){var c=this._stack.indexOf(a)+1;this._stack.splice(c,0,b)},lunr.Pipeline.prototype.before=function(a,b){var c=this._stack.indexOf(a);this._stack.splice(c,0,b)},lunr.Pipeline.prototype.remove=function(a){var b=this._stack.indexOf(a);this._stack.splice(b,1)},lunr.Pipeline.prototype.run=function(a){var b=[],c=a.length,d=this._stack.length;for(var e=0;e<c;e++){var f=a[e];for(var g=0;g<d;g++){f=this._stack[g](f,e,a);if(f===void 0)break}f!==void 0&&b.push(f)}return b},lunr.Vector=function(a){this.elements=a;for(var b=0;b<a.length;b++)b in this.elements||(this.elements[b]=0)},lunr.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;var a=0,b=this.elements,c=b.length,d,e;for(var f=0;f<c;f++)e=b[f],a+=e*e;return this._magnitude=Math.sqrt(a)},lunr.Vector.prototype.dot=function(a){var b=this.elements,c=a.elements,d=b.length,e=0;for(var f=0;f<d;f++)e+=b[f]*c[f];return e},lunr.Vector.prototype.similarity=function(a){return this.dot(a)/(this.magnitude()*a.magnitude())},lunr.Vector.prototype.toArray=function(){return this.elements},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(a){if(~this.elements.indexOf(a))return;this.elements.splice(this.locationFor(a),0,a)},this),this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(a,b){return this.elements.map(a,b)},lunr.SortedSet.prototype.forEach=function(a,b){return this.elements.forEach(a,b)},lunr.SortedSet.prototype.indexOf=function(a,b){return this.elements.indexOf(a)},lunr.SortedSet.prototype.locationFor=function(a,b,c){var b=b||0,c=c||this.elements.length,d=c-b,e=b+Math.floor(d/2),f=this.elements[e];if(d<=1){if(f>a)return e;if(f<a)return e+1}if(f<a)return this.locationFor(a,e,c);if(f>a)return this.locationFor(a,b,e)},lunr.SortedSet.prototype.intersect=function(a){var b=new lunr.SortedSet,c=0,d=0,e=this.length,f=a.length,g=this.elements,h=a.elements;for(;;){if(c>e-1||d>f-1)break;if(g[c]===h[d]){b.add(g[c]),c++,d++;continue}if(g[c]<h[d]){c++;continue}if(g[c]>h[d]){d++;continue}}return b},lunr.SortedSet.prototype.clone=function(){var a=new lunr.SortedSet;return a.elements=this.toArray(),a.length=a.elements.length,a},lunr.SortedSet.prototype.union=function(a){var b,c,d;return this.length>=a.length?(b=this,c=a):(b=a,c=this),d=b.clone(),d.add.apply(d,c.toArray()),d},lunr.Index=function(){this._fields=[],this._ref="id",this.pipeline=new lunr.Pipeline,this.documentStore=new lunr.Store,this.tokenStore=new lunr.TokenStore,this.corpusTokens=new lunr.SortedSet},lunr.Index.prototype.field=function(a,b){var b=b||{},c={name:a,boost:b.boost||1};return this._fields.push(c),this},lunr.Index.prototype.ref=function(a){return this._ref=a,this},lunr.Index.prototype.add=function(a){var b={},c=new lunr.SortedSet,d=a[this._ref];this._fields.forEach(function(d){var e=this.pipeline.run(lunr.tokenizer(a[d.name]));b[d.name]=e,lunr.SortedSet.prototype.add.apply(c,e)},this),this.documentStore.set(d,c),lunr.SortedSet.prototype.add.apply(this.corpusTokens,c.toArray());for(var e=0;e<c.length;e++){var f=c.elements[e],g=this._fields.reduce(function(a,c){var d=b[c.name].filter(function(a){return a===f}).length,e=b[c.name].length;return a+d/e*c.boost},0);this.tokenStore.add(f,{ref:d,tf:g})}},lunr.Index.prototype.remove=function(a){var b=a[this._ref],c=this.documentStore.get(b);this.documentStore.remove(b),c.forEach(function(a){this.tokenStore.remove(a,b)},this)},lunr.Index.prototype.update=function(a){this.remove(a),this.add(a)},lunr.Index.prototype.idf=function(a){var b=Object.keys(this.tokenStore.get(a)).length;return b===0?1:1+Math.log(this.tokenStore.length/b)},lunr.Index.prototype.search=function(a){var b=this.pipeline.run(lunr.tokenizer(a)),c=new Array(this.corpusTokens.length),d=[],e=this._fields.reduce(function(a,b){return a+b.boost},0);if(!b.some(lunr.TokenStore.prototype.has,this.tokenStore))return[];b.forEach(function(a,b,f){var g=1/f.length*this._fields.length*e,h=this,i=this.tokenStore.expand(a).reduce(function(a,b){var d=h.corpusTokens.indexOf(b),e=h.idf(b),f=new lunr.SortedSet;return d>-1&&(c[d]=g*e),Object.keys(h.tokenStore.get(b)).forEach(function(a){f.add(a)}),a.union(f)},new lunr.SortedSet);d.push(i)},this);var f=d.reduce(function(a,b){return a.intersect(b)}),g=new lunr.Vector(c);return f.map(function(a){return{ref:a,score:g.similarity(this.documentVector(a))}},this).sort(function(a,b){return b.score-a.score})},lunr.Index.prototype.documentVector=function(a){var b=this.documentStore.get(a),c=b.length,d=new Array(this.corpusTokens.length);for(var e=0;e<c;e++){var f=b.elements[e],g=this.tokenStore.get(f)[a].tf,h=this.idf(f);d[this.corpusTokens.indexOf(f)]=g*h}return new lunr.Vector(d)},lunr.Store=function(){this.store={},this.length=0},lunr.Store.prototype.set=function(a,b){this.store[a]=b,this.length=Object.keys(this.store).length},lunr.Store.prototype.get=function(a){return this.store[a]},lunr.Store.prototype.has=function(a){return a in this.store},lunr.Store.prototype.remove=function(a){if(!this.has(a))return;delete this.store[a],this.length--},lunr.stemmer=function(){var a={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},b={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},c="[^aeiou]",d="[aeiouy]",e=c+"[^aeiouy]*",f=d+"[aeiou]*",g="^("+e+")?"+f+e,h="^("+e+")?"+f+e+"("+f+")?$",i="^("+e+")?"+f+e+f+e,j="^("+e+")?"+d;return function(c){var f,k,l,m,n,o,p,q=c;if(c.length<3)return c;l=c.substr(0,1),l=="y"&&(c=l.toUpperCase()+c.substr(1)),m=/^(.+?)(ss|i)es$/,n=/^(.+?)([^s])s$/,m.test(c)?c=c.replace(m,"$1$2"):n.test(c)&&(c=c.replace(n,"$1$2")),m=/^(.+?)eed$/,n=/^(.+?)(ed|ing)$/;if(m.test(c)){var r=m.exec(c);m=new RegExp(g),m.test(r[1])&&(m=/.$/,c=c.replace(m,""))}else if(n.test(c)){var r=n.exec(c);f=r[1],n=new RegExp(j),n.test(f)&&(c=f,n=/(at|bl|iz)$/,o=new RegExp("([^aeiouylsz])\\1$"),p=new RegExp("^"+e+d+"[^aeiouwxy]$"),n.test(c)?c+="e":o.test(c)?(m=/.$/,c=c.replace(m,"")):p.test(c)&&(c+="e"))}m=/^(.+?)y$/;if(m.test(c)){var r=m.exec(c);f=r[1],m=new RegExp(j),m.test(f)&&(c=f+"i")}m=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;if(m.test(c)){var r=m.exec(c);f=r[1],k=r[2],m=new RegExp(g),m.test(f)&&(c=f+a[k])}m=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;if(m.test(c)){var r=m.exec(c);f=r[1],k=r[2],m=new RegExp(g),m.test(f)&&(c=f+b[k])}m=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,n=/^(.+?)(s|t)(ion)$/;if(m.test(c)){var r=m.exec(c);f=r[1],m=new RegExp(i),m.test(f)&&(c=f)}else if(n.test(c)){var r=n.exec(c);f=r[1]+r[2],n=new RegExp(i),n.test(f)&&(c=f)}m=/^(.+?)e$/;if(m.test(c)){var r=m.exec(c);f=r[1],m=new RegExp(i),n=new RegExp(h),o=new RegExp("^"+e+d+"[^aeiouwxy]$");if(m.test(f)||n.test(f)&&!o.test(f))c=f}return m=/ll$/,n=new RegExp(i),m.test(c)&&n.test(c)&&(m=/.$/,c=c.replace(m,"")),l=="y"&&(c=l.toLowerCase()+c.substr(1)),c}}(),lunr.stopWordFilter=function(a){var b=["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"];if(b.indexOf(a)===-1)return a},lunr.TokenStore=function(){this.root={docs:{}},this.length=0},lunr.TokenStore.prototype.add=function(a,b,c){var c=c||this.root,d=a[0],e=a.slice(1);d in c||(c[d]={docs:{}});if(e.length===0){c[d].docs[b.ref]=b,this.length+=1;return}return this.add(e,b,c[d])},lunr.TokenStore.prototype.has=function(a,b){var b=b||this.root,c=a[0],d=a.slice(1);return c in b?d.length===0?!0:this.has(d,b[c]):!1},lunr.TokenStore.prototype.getNode=function(a,b){var b=b||this.root,c=a[0],d=a.slice(1);return c in b?d.length===0?b[c]:this.getNode(d,b[c]):{}},lunr.TokenStore.prototype.get=function(a,b){return this.getNode(a).docs||{}},lunr.TokenStore.prototype.remove=function(a,b,c){var c=c||this.root,d=a[0],e=a.slice(1);if(!(d in c))return;if(e.length===0)delete c[d].docs[b];else return this.remove(e,b,c[d])},lunr.TokenStore.prototype.expand=function(a,b){var c=this.getNode(a),d=c.docs||{},b=b||[];return Object.keys(d).length&&b.push(a),Object.keys(c).forEach(function(c){if(c==="docs")return;b.concat(this.expand(a+c,b))},this),b};
* @license
*/
var lunr=function(e){var t=new lunr.Index;return t.pipeline.add(lunr.stopWordFilter,lunr.stemmer),e&&e.call(t,t),t};lunr.version="0.2.1","undefined"!=typeof module&&(module.exports=lunr),lunr.tokenizer=function(e){if(Array.isArray(e))return e;var t=/\s+/;return e.split(t).map(function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"").toLowerCase()})},lunr.Pipeline=function(){this._stack=[]},lunr.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);Array.prototype.push.apply(this._stack,e)},lunr.Pipeline.prototype.after=function(e,t){var n=this._stack.indexOf(e)+1;this._stack.splice(n,0,t)},lunr.Pipeline.prototype.before=function(e,t){var n=this._stack.indexOf(e);this._stack.splice(n,0,t)},lunr.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);this._stack.splice(t,1)},lunr.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,r=this._stack.length,o=0;n>o;o++){for(var i=e[o],s=0;r>s&&(i=this._stack[s](i,o,e),void 0!==i);s++);void 0!==i&&t.push(i)}return t},lunr.Vector=function(e){this.elements=e;for(var t=0;e.length>t;t++)t in this.elements||(this.elements[t]=0)},lunr.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e,t=0,n=this.elements,r=n.length,o=0;r>o;o++)e=n[o],t+=e*e;return this._magnitude=Math.sqrt(t)},lunr.Vector.prototype.dot=function(e){for(var t=this.elements,n=e.elements,r=t.length,o=0,i=0;r>i;i++)o+=t[i]*n[i];return o},lunr.Vector.prototype.similarity=function(e){return this.dot(e)/(this.magnitude()*e.magnitude())},lunr.Vector.prototype.toArray=function(){return this.elements},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){~this.elements.indexOf(e)||this.elements.splice(this.locationFor(e),0,e)},this),this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e,t){return this.elements.indexOf(e,t)},lunr.SortedSet.prototype.locationFor=function(e,t,n){var t=t||0,n=n||this.elements.length,r=n-t,o=t+Math.floor(r/2),i=this.elements[o];if(1>=r){if(i>e)return o;if(e>i)return o+1}return e>i?this.locationFor(e,o,n):i>e?this.locationFor(e,t,o):void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,r=0,o=this.length,i=e.length,s=this.elements,l=e.elements;;){if(n>o-1||r>i-1)break;s[n]!==l[r]?s[n]<l[r]?n++:s[n]>l[r]&&r++:(t.add(s[n]),n++,r++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,r;return this.length>=e.length?(t=this,n=e):(t=e,n=this),r=t.clone(),r.add.apply(r,n.toArray()),r},lunr.Index=function(){this._fields=[],this._ref="id",this.pipeline=new lunr.Pipeline,this.documentStore=new lunr.Store,this.tokenStore=new lunr.TokenStore,this.corpusTokens=new lunr.SortedSet},lunr.Index.prototype.field=function(e,t){var t=t||{},n={name:e,boost:t.boost||1};return this._fields.push(n),this},lunr.Index.prototype.ref=function(e){return this._ref=e,this},lunr.Index.prototype.add=function(e){var t={},n=new lunr.SortedSet,r=e[this._ref];this._fields.forEach(function(r){var o=this.pipeline.run(lunr.tokenizer(e[r.name]));t[r.name]=o,lunr.SortedSet.prototype.add.apply(n,o)},this),this.documentStore.set(r,n),lunr.SortedSet.prototype.add.apply(this.corpusTokens,n.toArray());for(var o=0;n.length>o;o++){var i=n.elements[o],s=this._fields.reduce(function(e,n){var r=t[n.name].filter(function(e){return e===i}).length,o=t[n.name].length;return e+r/o*n.boost},0);this.tokenStore.add(i,{ref:r,tf:s})}},lunr.Index.prototype.remove=function(e){var t=e[this._ref],n=this.documentStore.get(t);this.documentStore.remove(t),n.forEach(function(e){this.tokenStore.remove(e,t)},this)},lunr.Index.prototype.update=function(e){this.remove(e),this.add(e)},lunr.Index.prototype.idf=function(e){var t=Object.keys(this.tokenStore.get(e)).length;return 0===t?1:1+Math.log(this.tokenStore.length/t)},lunr.Index.prototype.search=function(e){var t=this.pipeline.run(lunr.tokenizer(e)),n=Array(this.corpusTokens.length),r=[],o=this._fields.reduce(function(e,t){return e+t.boost},0);if(!t.some(lunr.TokenStore.prototype.has,this.tokenStore))return[];t.forEach(function(e,t,i){var s=1/i.length*this._fields.length*o,l=this,u=this.tokenStore.expand(e).reduce(function(e,t){var r=l.corpusTokens.indexOf(t),o=l.idf(t),i=new lunr.SortedSet;return r>-1&&(n[r]=s*o),Object.keys(l.tokenStore.get(t)).forEach(function(e){i.add(e)}),e.union(i)},new lunr.SortedSet);r.push(u)},this);var i=r.reduce(function(e,t){return e.intersect(t)}),s=new lunr.Vector(n);return i.map(function(e){return{ref:e,score:s.similarity(this.documentVector(e))}},this).sort(function(e,t){return t.score-e.score})},lunr.Index.prototype.documentVector=function(e){for(var t=this.documentStore.get(e),n=t.length,r=Array(this.corpusTokens.length),o=0;n>o;o++){var i=t.elements[o],s=this.tokenStore.get(i)[e].tf,l=this.idf(i);r[this.corpusTokens.indexOf(i)]=s*l}return new lunr.Vector(r)},lunr.Store=function(){this.store={},this.length=0},lunr.Store.prototype.set=function(e,t){this.store[e]=t,this.length=Object.keys(this.store).length},lunr.Store.prototype.get=function(e){return this.store[e]},lunr.Store.prototype.has=function(e){return e in this.store},lunr.Store.prototype.remove=function(e){this.has(e)&&(delete this.store[e],this.length--)},lunr.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},t={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",r="[aeiouy]",o=n+"[^aeiouy]*",i=r+"[aeiou]*",s="^("+o+")?"+i+o,l="^("+o+")?"+i+o+"("+i+")?$",u="^("+o+")?"+i+o+i+o,a="^("+o+")?"+r;return function(n){var i,h,c,p,f,d,y;if(3>n.length)return n;if(c=n.substr(0,1),"y"==c&&(n=c.toUpperCase()+n.substr(1)),p=/^(.+?)(ss|i)es$/,f=/^(.+?)([^s])s$/,p.test(n)?n=n.replace(p,"$1$2"):f.test(n)&&(n=n.replace(f,"$1$2")),p=/^(.+?)eed$/,f=/^(.+?)(ed|ing)$/,p.test(n)){var m=p.exec(n);p=RegExp(s),p.test(m[1])&&(p=/.$/,n=n.replace(p,""))}else if(f.test(n)){var m=f.exec(n);i=m[1],f=RegExp(a),f.test(i)&&(n=i,f=/(at|bl|iz)$/,d=RegExp("([^aeiouylsz])\\1$"),y=RegExp("^"+o+r+"[^aeiouwxy]$"),f.test(n)?n+="e":d.test(n)?(p=/.$/,n=n.replace(p,"")):y.test(n)&&(n+="e"))}if(p=/^(.+?)y$/,p.test(n)){var m=p.exec(n);i=m[1],p=RegExp(a),p.test(i)&&(n=i+"i")}if(p=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,p.test(n)){var m=p.exec(n);i=m[1],h=m[2],p=RegExp(s),p.test(i)&&(n=i+e[h])}if(p=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,p.test(n)){var m=p.exec(n);i=m[1],h=m[2],p=RegExp(s),p.test(i)&&(n=i+t[h])}if(p=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,f=/^(.+?)(s|t)(ion)$/,p.test(n)){var m=p.exec(n);i=m[1],p=RegExp(u),p.test(i)&&(n=i)}else if(f.test(n)){var m=f.exec(n);i=m[1]+m[2],f=RegExp(u),f.test(i)&&(n=i)}if(p=/^(.+?)e$/,p.test(n)){var m=p.exec(n);i=m[1],p=RegExp(u),f=RegExp(l),d=RegExp("^"+o+r+"[^aeiouwxy]$"),(p.test(i)||f.test(i)&&!d.test(i))&&(n=i)}return p=/ll$/,f=RegExp(u),p.test(n)&&f.test(n)&&(p=/.$/,n=n.replace(p,"")),"y"==c&&(n=c.toLowerCase()+n.substr(1)),n}}(),lunr.stopWordFilter=function(e){var t=["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"];return-1===t.indexOf(e)?e:void 0},lunr.TokenStore=function(){this.root={docs:{}},this.length=0},lunr.TokenStore.prototype.add=function(e,t,n){var n=n||this.root,r=e[0],o=e.slice(1);return r in n||(n[r]={docs:{}}),0===o.length?(n[r].docs[t.ref]=t,this.length+=1,void 0):this.add(o,t,n[r])},lunr.TokenStore.prototype.has=function(e,t){var t=t||this.root,n=e[0],r=e.slice(1);return n in t?0===r.length?!0:this.has(r,t[n]):!1},lunr.TokenStore.prototype.getNode=function(e,t){var t=t||this.root,n=e[0],r=e.slice(1);return n in t?0===r.length?t[n]:this.getNode(r,t[n]):{}},lunr.TokenStore.prototype.get=function(e,t){return this.getNode(e,t).docs||{}},lunr.TokenStore.prototype.remove=function(e,t,n){var n=n||this.root,r=e[0],o=e.slice(1);if(r in n)return 0!==o.length?this.remove(o,t,n[r]):(delete n[r].docs[t],void 0)},lunr.TokenStore.prototype.expand=function(e,t){var n=this.getNode(e),r=n.docs||{},t=t||[];return Object.keys(r).length&&t.push(e),Object.keys(n).forEach(function(n){"docs"!==n&&t.concat(this.expand(e+n,t))},this),t};
{
"name": "lunr",
"description": "Simple full-text search in your browser.",
"version": "0.2.0",
"version": "0.2.1",
"author": "Oliver Nightingale",
"keywords": ["search"]
"keywords": ["search"],
"homepage": "http://lunrjs.com",
"bugs": "http://github.com/olivernn/lunr.js/issues",
"main": "lunr.js",
"devDependencies": {
"phantomjs": "1.8.1"
},
"scripts": {
"test": "phantomjs test/env/runner.js http://localhost:3000/test"
}
}

@@ -353,3 +353,3 @@ /**

// Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
// Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through.
expect: function( asserts ) {

@@ -407,3 +407,3 @@ if (arguments.length === 1) {

// Asssert helpers
// Assert helpers
// All of these must call either QUnit.push() or manually do:

@@ -1015,3 +1015,3 @@ // - runLoggingCallbacks( "log", .. );

label.setAttribute( "for", "qunit-filter-pass" );
label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." );
label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." );
label.innerHTML = "Hide passed tests";

@@ -1061,3 +1061,3 @@ toolbar.appendChild( label );

// Cover uncaught exceptions
// Returning true will surpress the default browser handler,
// Returning true will suppress the default browser handler,
// returning false will let it run.

@@ -1071,3 +1071,3 @@ window.onerror = function ( error, filePath, linerNr ) {

// Treat return value as window.onerror itself does,
// Only do our handling if not surpressed.
// Only do our handling if not suppressed.
if ( ret !== true ) {

@@ -1423,3 +1423,3 @@ if ( QUnit.config.current ) {

if ( b instanceof a.constructor || a instanceof b.constructor ) {
// to catch short annotaion VS 'new' annotation of a
// to catch short annotation VS 'new' annotation of a
// declaration

@@ -1453,3 +1453,3 @@ // e.g. var i = 1;

a.source === b.source &&
// and its modifers
// and its modifiers
a.global === b.global &&

@@ -1490,3 +1490,3 @@ // (gmi) ...

if ( parents[j] === a[i] ) {
loop = true;// dont rewalk array
loop = true;// don't rewalk array
}

@@ -1979,3 +1979,3 @@ }

// for CommonJS enviroments, export everything
// for CommonJS environments, export everything
if ( typeof exports !== "undefined" ) {

@@ -1982,0 +1982,0 @@ extend(exports, QUnit);

@@ -20,3 +20,3 @@ module('lunr.SortedSet')

test('sort is maintaned when adding elements to the set', function () {
test('sort is maintained when adding elements to the set', function () {
var set = new lunr.SortedSet

@@ -23,0 +23,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc