-
Notifications
You must be signed in to change notification settings - Fork 61
/
wade.min.js
6 lines (6 loc) · 2.29 KB
/
wade.min.js
1
2
3
4
5
6
/**
* Wade v0.2.0
* Copyright 2017 Kabir Shah
* Released under the MIT License
*/
!function(e,o){"object"==typeof module&&module.exports?module.exports=o():e.Wade=o()}(this,function(){var e=["about","after","all","also","am","an","and","another","any","are","as","at","be","because","been","before","being","between","both","but","by","came","can","come","could","did","do","each","for","from","get","got","has","had","he","have","her","here","him","himself","his","how","if","in","into","is","it","like","make","many","me","might","more","most","much","must","my","never","now","of","on","only","or","other","our","out","over","said","same","see","should","since","some","still","such","take","than","that","the","their","them","then","there","these","they","this","those","through","to","too","under","up","very","was","way","we","well","were","what","where","which","while","who","with","would","you","your","a","i"],o=/\.|\,|\!/g,n=function(e,o){for(var n=o,r=0;r<e.length&&void 0!==(n=n[e[r]]);r++);return n},r=function(e,o,n,r){for(var t=null,i=0;i<e.length;i++){var h=e[i];void 0===(t=n[h])?(n[h]=o.length,o.push({index:h,score:r})):o[t].score+=r}},t=function(e,o,t,i,h){var a=n(e,o);void 0!==a&&void 0!==a.id&&r(a.id,t,i,h)},i=function(e,o,t,i,h){var a=n(e,o);if(void 0!==a)for(var u=[a],s=null,d=0;0!==u.length;){void 0!==(s=u[d]).id&&r(s.id,t,i,h),u.pop(),d--;for(var l in s)u.push(s[l]),d++}},h=function(e){var o=e.length-1;return" "===e[0]&&(e=e.substring(1))," "===e[o]&&(e=e.substring(0,o)),e.split(" ")},a=function(e){return e.toLowerCase()},u=function(e){return e.replace(o,"")},s=function(o){for(var n=h(o),r=0;r<n.length;r++)-1!==e.indexOf(n[r])&&n.splice(r,1);return n.join(" ")},d=function(e){for(var o=function(e){for(var n=o.index,r=h(d.process(e)),a=r.length,u=a-1,s=1/a,l=[],f={},c=0;c<u;c++)t(r[c],n,l,f,s);return i(r[u],n,l,f,s),l},n=0;n<e.length;n++)e[n]=d.process(e[n]);return o.index=d.index(e),o.data=e,o};return d.pipeline=[a,u,s],d.process=function(e){for(var o=d.pipeline,n=0;n<o.length;n++)e=o[n](e);return e},d.index=function(e){for(var o={},n=0;n<e.length;n++)for(var r=h(e[n]),t=0;t<r.length;t++){for(var i=r[t],a=i.length-1,u=o,s=0;s<a;s++){var d=i[s],l=u[d];l=void 0===l?{}:l,u[d]=l,u=l}var f=i[a];void 0===u[f]?u[f]={id:[n]}:void 0===(u=u[f]).id?u.id=[n]:u.id.push(n)}return o},d.version="0.2.0",d});