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

fuse.js

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuse.js - npm Package Compare versions

Comparing version 5.0.2-beta to 5.0.3-beta

dist/fuse.dev.js

6

CHANGELOG.md

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

# Version 5.0.3-beta
- A couple of fixes, courtesy of [Daniel Dickinson](https://github.com/cshoredaniel):
- Generate multiple targets with webpack (#359)
- Fixed TypeError (#360)
# Version 5.0.2-beta

@@ -2,0 +8,0 @@

2

dist/fuse.d.ts

@@ -1,2 +0,2 @@

// Type definitions for Fuse.js v5.0.2-beta
// Type definitions for Fuse.js v5.0.3-beta
// TypeScript Version: 3.1

@@ -3,0 +3,0 @@

/*!
* Fuse.js v5.0.2-beta - Lightweight fuzzy-search (http://fusejs.io)
* Fuse.js v5.0.3-beta - Lightweight fuzzy-search (http://fusejs.io)
*

@@ -9,2 +9,2 @@ * Copyright (c) 2012-2020 Kirollos Risk (http://kiro.me)

*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Fuse",[],e):"object"==typeof exports?exports.Fuse=e():t.Fuse=e()}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=5)}([function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}t.exports={isDefined:function(t){return null!=t},isArray:function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:function(t){return"object"===r(t)},toString:function(t){return null==t?"":function(t){if("string"==typeof t)return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(7),o=r(10),a=r(2).MAX_BITS,s=function(){function t(e,r){var n=r.location,i=void 0===n?0:n,s=r.distance,c=void 0===s?100:s,u=r.threshold,h=void 0===u?.6:u,f=r.isCaseSensitive,l=void 0!==f&&f,v=r.findAllMatches,p=void 0!==v&&v,d=r.minMatchCharLength,y=void 0===d?1:d,g=r.includeMatches,m=void 0!==g&&g;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options={location:i,distance:c,threshold:h,isCaseSensitive:l,findAllMatches:p,includeMatches:m,minMatchCharLength:y},e.length>a)throw new Error("Pattern length exceeds max of ".concat(a,"."));this.pattern=l?e:e.toLowerCase(),this.patternAlphabet=o(this.pattern)}var e,r,s;return e=t,(r=[{key:"searchIn",value:function(t){var e=t.$,r=this.options,n=r.isCaseSensitive,o=r.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var a={isMatch:!0,score:0};return o&&(a.matchedIndices=[[0,e.length-1]]),a}var s=this.options,c=s.location,u=s.distance,h=s.threshold,f=s.findAllMatches,l=s.minMatchCharLength;return i(e,this.pattern,this.patternAlphabet,{location:c,distance:u,threshold:h,findAllMatches:f,minMatchCharLength:l,includeMatches:o})}}])&&n(e.prototype,r),s&&n(e,s),t}();t.exports=s},function(t,e){t.exports.MAX_BITS=32},function(t,e){t.exports=function(t,e){var r=e.n,n=void 0===r?3:r,i=e.pad,o=void 0===i||i,a=e.sort,s=void 0!==a&&a,c=[];if(null==t)return c;t=t.toLowerCase(),o&&(t=" ".concat(t," "));var u=t.length-n+1;if(u<1)return c;for(;u--;)c[u]=t.substr(u,n);return s&&c.sort((function(t,e){return t==e?0:t<e?-1:1})),c}},function(t,e,r){var n=r(0),i=n.isDefined,o=n.isString,a=n.isNumber,s=n.isArray,c=n.toString;t.exports=function(t,e){var r=[],n=!1;return function t(e,u){if(u){var h=u.indexOf("."),f=u,l=null;-1!==h&&(f=u.slice(0,h),l=u.slice(h+1));var v=e[f];if(i(v))if(l||!o(v)&&!a(v))if(s(v)){n=!0;for(var p=0,d=v.length;p<d;p+=1)t(v[p],l)}else l&&t(v,l);else r.push(c(v))}else r.push(e)}(t,e),n?r:r[0]}},function(t,e,r){function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var c=r(6),u=c.BitapSearch,h=c.ExtendedSearch,f=c.NGramSearch,l=r(0),v=l.isArray,p=l.isDefined,d=l.isString,y=l.isNumber,g=(l.isObject,r(4)),m=r(24),b=m.createIndex,x=m.KeyStore,S=r(27),k=S.transformMatches,M=S.transformScore,w=r(2).MAX_BITS,_={isCaseSensitive:!1,distance:100,findAllMatches:!1,getFn:g,includeMatches:!1,includeScore:!1,keys:[],location:0,minMatchCharLength:1,shouldSort:!0,sortFn:function(t,e){return t.score-e.score},threshold:.6,useExtendedSearch:!1},O=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;a(this,t),this.options=i({},_,{},r),this.options.isCaseSensitive=r.caseSensitive,delete this.options.caseSensitive,this._processKeys(this.options.keys),this.setCollection(e,n)}var e,r,n;return e=t,(r=[{key:"setCollection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.list=t,this.listIsStringArray=d(t[0]),e?this.setIndex(e):this.setIndex(this._createIndex())}},{key:"setIndex",value:function(t){this._indexedList=t}},{key:"_processKeys",value:function(e){this._keyStore=new x(e),t.verbose}},{key:"_createIndex",value:function(){return b(this._keyStore.keys(),this.list,{getFn:this.options.getFn})}},{key:"search",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{limit:!1},r=this.options,n=r.useExtendedSearch,i=r.shouldSort,o=null;o=n?new h(t,this.options):t.length>w?new f(t,this.options):new u(t,this.options);var a=this._searchUsing(o);return this._computeScore(a),i&&this._sort(a),e.limit&&y(e.limit)&&(a=a.slice(0,e.limit)),this._format(a)}},{key:"_searchUsing",value:function(t){var e=this._indexedList,r=[],n=this.options.includeMatches;if(this.listIsStringArray)for(var i=0,o=e.length;i<o;i+=1){var a=e[i],s=a.$,c=a.idx;if(p(s)){var u=t.searchIn(a),h=u.isMatch,f=u.score;if(h){var l={score:f,value:s};n&&(l.indices=u.matchedIndices),r.push({item:s,idx:c,matches:[l]})}}}else for(var d=this._keyStore.keys(),y=this._keyStore.count(),g=0,m=e.length;g<m;g+=1){var b=e[g],x=b.$,S=b.idx;if(p(x)){for(var k=[],M=0;M<y;M+=1){var w=d[M],_=x[w];if(p(_))if(v(_))for(var O=0,j=_.length;O<j;O+=1){var P=_[O],A=P.$,I=P.idx;if(p(A)){var C=t.searchIn(P),L=C.isMatch,F=C.score;if(L){var E={score:F,key:w,value:A,idx:I};n&&(E.indices=C.matchedIndices),k.push(E)}}}else{var N=_.$,$=t.searchIn(_),z=$.isMatch,T=$.score;if(!z)continue;var D={score:T,key:w,value:N};n&&(D.indices=$.matchedIndices),k.push(D)}}k.length&&r.push({idx:S,item:x,matches:k})}}return r}},{key:"_computeScore",value:function(t){for(var e=0,r=t.length;e<r;e+=1){for(var n=t[e],i=n.matches,o=i.length,a=1,s=0;s<o;s+=1){var c=i[s],u=c.key,h=this._keyStore.get(u,"weight"),f=h||1,l=0===c.score&&h&&h>0?Number.EPSILON:c.score;a*=Math.pow(l,f)}n.score=a}}},{key:"_sort",value:function(t){t.sort(this.options.sortFn)}},{key:"_format",value:function(t){var e=[],r=this.options,n=r.includeMatches,i=r.includeScore,o=[];n&&o.push(k),i&&o.push(M);for(var a=0,s=t.length;a<s;a+=1){var c=t[a],u=c.idx,h={item:this.list[u],refIndex:u};if(o.length)for(var f=0,l=o.length;f<l;f+=1)o[f](c,h);e.push(h)}return e}}])&&s(e.prototype,r),n&&s(e,n),t}();O.createIndex=b,t.exports=O},function(t,e,r){t.exports={BitapSearch:r(1),ExtendedSearch:r(11),NGramSearch:r(18)}},function(t,e,r){var n=r(8),i=r(9);t.exports=function(t,e,r,o){for(var a=o.location,s=void 0===a?0:a,c=o.distance,u=void 0===c?100:c,h=o.threshold,f=void 0===h?.6:h,l=o.findAllMatches,v=void 0!==l&&l,p=o.minMatchCharLength,d=void 0===p?1:p,y=o.includeMatches,g=void 0!==y&&y,m=e.length,b=t.length,x=Math.max(0,Math.min(s,b)),S=f,k=t.indexOf(e,x),M=[],w=0;w<b;w+=1)M[w]=0;if(-1!==k){var _=n(e,{errors:0,currentLocation:k,expectedLocation:x,distance:u});if(S=Math.min(_,S),-1!==(k=t.lastIndexOf(e,x+m))){var O=n(e,{errors:0,currentLocation:k,expectedLocation:x,distance:u});S=Math.min(O,S)}}k=-1;for(var j=[],P=1,A=m+b,I=1<<(m<=31?m-1:30),C=0;C<m;C+=1){for(var L=0,F=A;L<F;){n(e,{errors:C,currentLocation:x+F,expectedLocation:x,distance:u})<=S?L=F:A=F,F=Math.floor((A-L)/2+L)}A=F;var E=Math.max(1,x-F+1),N=v?b:Math.min(x+F,b)+m,$=Array(N+2);$[N+1]=(1<<C)-1;for(var z=N;z>=E;z-=1){var T=z-1,D=r[t.charAt(T)];if(D&&(M[T]=1),$[z]=($[z+1]<<1|1)&D,0!==C&&($[z]|=(j[z+1]|j[z])<<1|1|j[z+1]),$[z]&I&&(P=n(e,{errors:C,currentLocation:T,expectedLocation:x,distance:u}))<=S){if(S=P,(k=T)<=x)break;E=Math.max(1,2*x-k)}}if(n(e,{errors:C+1,currentLocation:x,expectedLocation:x,distance:u})>S)break;j=$}var W={isMatch:k>=0,score:P||.001};return g&&(W.matchedIndices=i(M,d)),W}},function(t,e){t.exports=function(t,e){var r=e.errors,n=void 0===r?0:r,i=e.currentLocation,o=void 0===i?0:i,a=e.expectedLocation,s=void 0===a?0:a,c=e.distance,u=void 0===c?100:c,h=n/t.length,f=Math.abs(s-o);return u?h+f/u:f?1:h}},function(t,e){t.exports=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=[],n=-1,i=-1,o=0,a=t.length;o<a;o+=1){var s=t[o];s&&-1===n?n=o:s||-1===n||((i=o-1)-n+1>=e&&r.push([n,i]),n=-1)}return t[o-1]&&o-n>=e&&r.push([n,o-1]),r}},function(t,e){t.exports=function(t){for(var e={},r=t.length,n=0;n<r;n+=1)e[t.charAt(n)]=0;for(var i=0;i<r;i+=1)e[t.charAt(i)]|=1<<r-i-1;return e}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(12),o=r(13),a=r(14),s=r(15),c=r(16),u=r(17),h=r(1),f=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=r.isCaseSensitive;this.options=r,this.pattern=n?e:e.toLowerCase(),this.query=function(t){return t.split("|").map((function(t){return t.trim().split(/ +/g)}))}(this.pattern),this._fuzzyCache={}}var e,r,f;return e=t,(r=[{key:"searchIn",value:function(t){var e=t.$,r=this.query;e=this.options.isCaseSensitive?e:e.toLowerCase();for(var n=!1,i=0,o=r.length;i<o;i+=1){var a=r[i],s=null;n=!0;for(var c=0,u=a.length;c<u;c+=1){var h=a[c];if(!(s=this._search(h,e)).isMatch){n=!1;break}}if(n)return s}return{isMatch:!1,score:1}}},{key:"_search",value:function(t,e){if(i.isForPattern(t))return i.match(t,e);if(a.isForPattern(t))return a.match(t,e);if(s.isForPattern(t))return s.match(t,e);if(u.isForPattern(t))return u.match(t,e);if(c.isForPattern(t))return c.match(t,e);if(o.isForPattern(t))return o.match(t,e);var r=this._fuzzyCache[t];return r||(r=new h(t,this.options),this._fuzzyCache[t]=r),r.search(e)}}])&&n(e.prototype,r),f&&n(e,f),t}();t.exports=f},function(t,e){var r=function(t){return t.substr(1)};t.exports={isForPattern:function(t){return"'"==t.charAt(0)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:e.indexOf(n)>-1,score:0}}}},function(t,e){var r=function(t){return t.substr(1)};t.exports={isForPattern:function(t){return"!"==t.charAt(0)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:-1===e.indexOf(n),score:0}}}},function(t,e){var r=function(t){return t.substr(1)};t.exports={isForPattern:function(t){return"^"==t.charAt(0)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:e.startsWith(n),score:0}}}},function(t,e){var r=function(t){return t.substr(2)};t.exports={isForPattern:function(t){return"!"==t.charAt(0)&&"^"==t.charAt(1)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:!e.startsWith(n),score:0}}}},function(t,e){var r=function(t){return t.substr(0,t.length-1)};t.exports={isForPattern:function(t){return"$"==t.charAt(t.length-1)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:e.endsWith(n),score:0}}}},function(t,e){var r=function(t){return t.substring(1,t.length-1)};t.exports={isForPattern:function(t){return"!"==t.charAt(0)&&"$"==t.charAt(t.length-1)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:!e.endsWith(n),score:0}}}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(3),o=r(19).jaccardDistance,a=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.patternNgram=i(e,{sort:!0})}var e,r,a;return e=t,(r=[{key:"searchIn",value:function(t){var e=t.ng;e||(e=i(t.$,{sort:!0}),t.ng=e);var r=o(this.patternNgram,e);return{score:r,isMatch:r<1}}}])&&n(e.prototype,r),a&&n(e,a),t}();t.exports=a},function(t,e,r){t.exports={jaccardDistance:r(20)}},function(t,e,r){var n=r(21),i=n.union,o=n.intersection;t.exports=function(t,e){var r=i(t,e);return 1-o(t,e).length/r.length}},function(t,e,r){t.exports={union:r(22),intersection:r(23)}},function(t,e){t.exports=function(t,e){for(var r=[],n=0,i=0;n<t.length&&i<e.length;){var o=t[n],a=e[i];o<a?(r.push(o),n+=1):a<o?(r.push(a),i+=1):(r.push(a),n+=1,i+=1)}for(;n<t.length;)r.push(t[n]),n+=1;for(;i<e.length;)r.push(e[i]),i+=1;return r}},function(t,e){t.exports=function(t,e){for(var r=[],n=0,i=0;n<t.length&&i<e.length;){var o=t[n],a=e[i];o==a?(r.push(o),n+=1,i+=1):o<a?n+=1:(o>a||(n+=1),i+=1)}return r}},function(t,e,r){t.exports={createIndex:r(25),KeyStore:r(26)}},function(t,e,r){var n=r(0),i=n.isArray,o=n.isDefined,a=n.isString,s=r(4),c=r(3);t.exports=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.getFn,u=void 0===n?s:n,h=r.ngrams,f=void 0!==h&&h,l=[];if(a(e[0]))for(var v=0,p=e.length;v<p;v+=1){var d=e[v];if(o(d)){var y={$:d,idx:v};f&&(y.ng=c(d,{sort:!0})),l.push(y)}}else for(var g=t.length,m=0,b=e.length;m<b;m+=1){for(var x=e[m],S={idx:m,$:{}},k=0;k<g;k+=1){var M=t[k],w=u(x,M);if(o(w))if(i(w)){for(var _=[],O=[{arrayIndex:-1,value:w}];O.length;){var j=O.pop(),P=j.arrayIndex,A=j.value;if(o(A))if(a(A)){var I={$:A,idx:P};f&&(I.ng=c(A,{sort:!0})),_.push(I)}else if(i(A))for(var C=0,L=A.length;C<L;C+=1)O.push({arrayIndex:C,value:A[C]})}S.$[M]=_}else{var F={$:w};f&&(F.ng=c(w,{sort:!0})),S.$[M]=F}}l.push(S)}return l}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(0).isString,o=function(){function t(e){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._keys={},this._keyNames=[],this._length=e.length,this._hasWeights=!1,e.length&&i(e[0]))for(var r=0;r<this._length;r+=1){var n=e[r];this._keys[n]={weight:1},this._keyNames.push(n)}else{for(var o=0,a=0;a<this._length;a+=1){var s=e[a];if(!s.hasOwnProperty("name"))throw new Error('Missing "name" property in key object');var c=s.name;if(this._keyNames.push(c),!s.hasOwnProperty("weight"))throw new Error('Missing "weight" property in key object');var u=s.weight;if(u<=0||u>=1)throw new Error('"weight" property in key must bein the range of (0, 1)');this._keys[c]={weight:u},o+=u,this._hasWeights=!0}if(o>1)throw new Error("Total of keyWeights cannot exceed 1")}}var e,r,o;return e=t,(r=[{key:"get",value:function(t,e){return this._keys[t]?this._keys[t][e]:null}},{key:"keys",value:function(){return this._keyNames}},{key:"count",value:function(){return this._length}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}])&&n(e.prototype,r),o&&n(e,o),t}();t.exports=o},function(t,e,r){t.exports={transformMatches:r(28),transformScore:r(29)}},function(t,e){t.exports=function(t,e){var r=t.matches;e.matches=[];for(var n=0,i=r.length;n<i;n+=1){var o=r[n];if(0!==o.indices.length){var a={indices:o.indices,value:o.value};o.key&&(a.key=o.key),o.idx>-1&&(a.refIndex=o.idx),e.matches.push(a)}}}},function(t,e){t.exports=function(t,e){e.score=t.score}}])}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Fuse",[],e):"object"==typeof exports?exports.Fuse=e():t.Fuse=e()}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=5)}([function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}t.exports={isDefined:function(t){return null!=t},isArray:function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:function(t){return"object"===r(t)},toString:function(t){return null==t?"":function(t){if("string"==typeof t)return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(7),o=r(10),a=r(2).MAX_BITS,s=function(){function t(e,r){var n=r.location,i=void 0===n?0:n,s=r.distance,c=void 0===s?100:s,u=r.threshold,h=void 0===u?.6:u,f=r.isCaseSensitive,l=void 0!==f&&f,v=r.findAllMatches,p=void 0!==v&&v,d=r.minMatchCharLength,y=void 0===d?1:d,g=r.includeMatches,m=void 0!==g&&g;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options={location:i,distance:c,threshold:h,isCaseSensitive:l,findAllMatches:p,includeMatches:m,minMatchCharLength:y},e.length>a)throw new Error("Pattern length exceeds max of ".concat(a,"."));this.pattern=l?e:e.toLowerCase(),this.patternAlphabet=o(this.pattern)}var e,r,s;return e=t,(r=[{key:"searchIn",value:function(t){var e=t.$,r=this.options,n=r.isCaseSensitive,o=r.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var a={isMatch:!0,score:0};return o&&(a.matchedIndices=[[0,e.length-1]]),a}var s=this.options,c=s.location,u=s.distance,h=s.threshold,f=s.findAllMatches,l=s.minMatchCharLength;return i(e,this.pattern,this.patternAlphabet,{location:c,distance:u,threshold:h,findAllMatches:f,minMatchCharLength:l,includeMatches:o})}}])&&n(e.prototype,r),s&&n(e,s),t}();t.exports=s},function(t,e){t.exports.MAX_BITS=32},function(t,e){t.exports=function(t,e){var r=e.n,n=void 0===r?3:r,i=e.pad,o=void 0===i||i,a=e.sort,s=void 0!==a&&a,c=[];if(null==t)return c;t=t.toLowerCase(),o&&(t=" ".concat(t," "));var u=t.length-n+1;if(u<1)return c;for(;u--;)c[u]=t.substr(u,n);return s&&c.sort((function(t,e){return t==e?0:t<e?-1:1})),c}},function(t,e,r){var n=r(0),i=n.isDefined,o=n.isString,a=n.isNumber,s=n.isArray,c=n.toString;t.exports=function(t,e){var r=[],n=!1;return function t(e,u){if(u){var h=u.indexOf("."),f=u,l=null;-1!==h&&(f=u.slice(0,h),l=u.slice(h+1));var v=e[f];if(i(v))if(l||!o(v)&&!a(v))if(s(v)){n=!0;for(var p=0,d=v.length;p<d;p+=1)t(v[p],l)}else l&&t(v,l);else r.push(c(v))}else r.push(e)}(t,e),n?r:r[0]}},function(t,e,r){function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var c=r(6),u=c.BitapSearch,h=c.ExtendedSearch,f=c.NGramSearch,l=r(0),v=l.isArray,p=l.isDefined,d=l.isString,y=l.isNumber,g=(l.isObject,r(4)),m=r(24),b=m.createIndex,x=m.KeyStore,S=r(27),k=S.transformMatches,M=S.transformScore,w=r(2).MAX_BITS,_={isCaseSensitive:!1,distance:100,findAllMatches:!1,getFn:g,includeMatches:!1,includeScore:!1,keys:[],location:0,minMatchCharLength:1,shouldSort:!0,sortFn:function(t,e){return t.score-e.score},threshold:.6,useExtendedSearch:!1},O=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;a(this,t),this.options=i({},_,{},r),this.options.isCaseSensitive=r.caseSensitive,delete this.options.caseSensitive,this._processKeys(this.options.keys),this.setCollection(e,n)}var e,r,n;return e=t,(r=[{key:"setCollection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.list=t,this.listIsStringArray=d(t[0]),e?this.setIndex(e):this.setIndex(this._createIndex())}},{key:"setIndex",value:function(t){this._indexedList=t}},{key:"_processKeys",value:function(e){this._keyStore=new x(e),t.verbose}},{key:"_createIndex",value:function(){return b(this._keyStore.keys(),this.list,{getFn:this.options.getFn})}},{key:"search",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{limit:!1},r=this.options,n=r.useExtendedSearch,i=r.shouldSort,o=null;o=n?new h(t,this.options):t.length>w?new f(t,this.options):new u(t,this.options);var a=this._searchUsing(o);return this._computeScore(a),i&&this._sort(a),e.limit&&y(e.limit)&&(a=a.slice(0,e.limit)),this._format(a)}},{key:"_searchUsing",value:function(t){var e=this._indexedList,r=[],n=this.options.includeMatches;if(this.listIsStringArray)for(var i=0,o=e.length;i<o;i+=1){var a=e[i],s=a.$,c=a.idx;if(p(s)){var u=t.searchIn(a),h=u.isMatch,f=u.score;if(h){var l={score:f,value:s};n&&(l.indices=u.matchedIndices),r.push({item:s,idx:c,matches:[l]})}}}else for(var d=this._keyStore.keys(),y=this._keyStore.count(),g=0,m=e.length;g<m;g+=1){var b=e[g],x=b.$,S=b.idx;if(p(x)){for(var k=[],M=0;M<y;M+=1){var w=d[M],_=x[w];if(p(_))if(v(_))for(var O=0,j=_.length;O<j;O+=1){var A=_[O],P=A.$,I=A.idx;if(p(P)){var C=t.searchIn(A),L=C.isMatch,F=C.score;if(L){var E={score:F,key:w,value:P,idx:I};n&&(E.indices=C.matchedIndices),k.push(E)}}}else{var N=_.$,$=t.searchIn(_),z=$.isMatch,D=$.score;if(!z)continue;var T={score:D,key:w,value:N};n&&(T.indices=$.matchedIndices),k.push(T)}}k.length&&r.push({idx:S,item:x,matches:k})}}return r}},{key:"_computeScore",value:function(t){for(var e=0,r=t.length;e<r;e+=1){for(var n=t[e],i=n.matches,o=i.length,a=1,s=0;s<o;s+=1){var c=i[s],u=c.key,h=this._keyStore.get(u,"weight"),f=h||1,l=0===c.score&&h&&h>0?Number.EPSILON:c.score;a*=Math.pow(l,f)}n.score=a}}},{key:"_sort",value:function(t){t.sort(this.options.sortFn)}},{key:"_format",value:function(t){var e=[],r=this.options,n=r.includeMatches,i=r.includeScore,o=[];n&&o.push(k),i&&o.push(M);for(var a=0,s=t.length;a<s;a+=1){var c=t[a],u=c.idx,h={item:this.list[u],refIndex:u};if(o.length)for(var f=0,l=o.length;f<l;f+=1)o[f](c,h);e.push(h)}return e}}])&&s(e.prototype,r),n&&s(e,n),t}();O.createIndex=b,t.exports=O},function(t,e,r){t.exports={BitapSearch:r(1),ExtendedSearch:r(11),NGramSearch:r(18)}},function(t,e,r){var n=r(8),i=r(9);t.exports=function(t,e,r,o){for(var a=o.location,s=void 0===a?0:a,c=o.distance,u=void 0===c?100:c,h=o.threshold,f=void 0===h?.6:h,l=o.findAllMatches,v=void 0!==l&&l,p=o.minMatchCharLength,d=void 0===p?1:p,y=o.includeMatches,g=void 0!==y&&y,m=e.length,b=t.length,x=Math.max(0,Math.min(s,b)),S=f,k=t.indexOf(e,x),M=[],w=0;w<b;w+=1)M[w]=0;if(-1!==k){var _=n(e,{errors:0,currentLocation:k,expectedLocation:x,distance:u});if(S=Math.min(_,S),-1!==(k=t.lastIndexOf(e,x+m))){var O=n(e,{errors:0,currentLocation:k,expectedLocation:x,distance:u});S=Math.min(O,S)}}k=-1;for(var j=[],A=1,P=m+b,I=1<<(m<=31?m-1:30),C=0;C<m;C+=1){for(var L=0,F=P;L<F;){n(e,{errors:C,currentLocation:x+F,expectedLocation:x,distance:u})<=S?L=F:P=F,F=Math.floor((P-L)/2+L)}P=F;var E=Math.max(1,x-F+1),N=v?b:Math.min(x+F,b)+m,$=Array(N+2);$[N+1]=(1<<C)-1;for(var z=N;z>=E;z-=1){var D=z-1,T=r[t.charAt(D)];if(T&&(M[D]=1),$[z]=($[z+1]<<1|1)&T,0!==C&&($[z]|=(j[z+1]|j[z])<<1|1|j[z+1]),$[z]&I&&(A=n(e,{errors:C,currentLocation:D,expectedLocation:x,distance:u}))<=S){if(S=A,(k=D)<=x)break;E=Math.max(1,2*x-k)}}if(n(e,{errors:C+1,currentLocation:x,expectedLocation:x,distance:u})>S)break;j=$}var W={isMatch:k>=0,score:A||.001};return g&&(W.matchedIndices=i(M,d)),W}},function(t,e){t.exports=function(t,e){var r=e.errors,n=void 0===r?0:r,i=e.currentLocation,o=void 0===i?0:i,a=e.expectedLocation,s=void 0===a?0:a,c=e.distance,u=void 0===c?100:c,h=n/t.length,f=Math.abs(s-o);return u?h+f/u:f?1:h}},function(t,e){t.exports=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=[],n=-1,i=-1,o=0,a=t.length;o<a;o+=1){var s=t[o];s&&-1===n?n=o:s||-1===n||((i=o-1)-n+1>=e&&r.push([n,i]),n=-1)}return t[o-1]&&o-n>=e&&r.push([n,o-1]),r}},function(t,e){t.exports=function(t){for(var e={},r=t.length,n=0;n<r;n+=1)e[t.charAt(n)]=0;for(var i=0;i<r;i+=1)e[t.charAt(i)]|=1<<r-i-1;return e}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(12),o=r(13),a=r(14),s=r(15),c=r(16),u=r(17),h=r(1),f=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=r.isCaseSensitive;this.options=r,this.pattern=n?e:e.toLowerCase(),this.query=function(t){return t.split("|").map((function(t){return t.trim().split(/ +/g)}))}(this.pattern),this._fuzzyCache={}}var e,r,f;return e=t,(r=[{key:"searchIn",value:function(t){var e=t.$,r=this.query;e=this.options.isCaseSensitive?e:e.toLowerCase();for(var n=!1,i=0,o=r.length;i<o;i+=1){var a=r[i],s=null;n=!0;for(var c=0,u=a.length;c<u;c+=1){var h=a[c];if(!(s=this._search(h,e)).isMatch){n=!1;break}}if(n)return s}return{isMatch:!1,score:1}}},{key:"_search",value:function(t,e){if(i.isForPattern(t))return i.match(t,e);if(a.isForPattern(t))return a.match(t,e);if(s.isForPattern(t))return s.match(t,e);if(u.isForPattern(t))return u.match(t,e);if(c.isForPattern(t))return c.match(t,e);if(o.isForPattern(t))return o.match(t,e);var r=this._fuzzyCache[t];return r||(r=new h(t,this.options),this._fuzzyCache[t]=r),r.search(e)}}])&&n(e.prototype,r),f&&n(e,f),t}();t.exports=f},function(t,e){var r=function(t){return t.substr(1)};t.exports={isForPattern:function(t){return"'"==t.charAt(0)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:e.indexOf(n)>-1,score:0}}}},function(t,e){var r=function(t){return t.substr(1)};t.exports={isForPattern:function(t){return"!"==t.charAt(0)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:-1===e.indexOf(n),score:0}}}},function(t,e){var r=function(t){return t.substr(1)};t.exports={isForPattern:function(t){return"^"==t.charAt(0)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:e.startsWith(n),score:0}}}},function(t,e){var r=function(t){return t.substr(2)};t.exports={isForPattern:function(t){return"!"==t.charAt(0)&&"^"==t.charAt(1)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:!e.startsWith(n),score:0}}}},function(t,e){var r=function(t){return t.substr(0,t.length-1)};t.exports={isForPattern:function(t){return"$"==t.charAt(t.length-1)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:e.endsWith(n),score:0}}}},function(t,e){var r=function(t){return t.substring(1,t.length-1)};t.exports={isForPattern:function(t){return"!"==t.charAt(0)&&"$"==t.charAt(t.length-1)},sanitize:r,match:function(t,e){var n=r(t);return{isMatch:!e.endsWith(n),score:0}}}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(3),o=r(19).jaccardDistance,a=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.patternNgram=i(e,{sort:!0})}var e,r,a;return e=t,(r=[{key:"searchIn",value:function(t){var e=t.ng;e||(e=i(t.$,{sort:!0}),t.ng=e);var r=o(this.patternNgram,e);return{score:r,isMatch:r<1}}}])&&n(e.prototype,r),a&&n(e,a),t}();t.exports=a},function(t,e,r){t.exports={jaccardDistance:r(20)}},function(t,e,r){var n=r(21),i=n.union,o=n.intersection;t.exports=function(t,e){var r=i(t,e);return 1-o(t,e).length/r.length}},function(t,e,r){t.exports={union:r(22),intersection:r(23)}},function(t,e){t.exports=function(t,e){for(var r=[],n=0,i=0;n<t.length&&i<e.length;){var o=t[n],a=e[i];o<a?(r.push(o),n+=1):a<o?(r.push(a),i+=1):(r.push(a),n+=1,i+=1)}for(;n<t.length;)r.push(t[n]),n+=1;for(;i<e.length;)r.push(e[i]),i+=1;return r}},function(t,e){t.exports=function(t,e){for(var r=[],n=0,i=0;n<t.length&&i<e.length;){var o=t[n],a=e[i];o==a?(r.push(o),n+=1,i+=1):o<a?n+=1:(o>a||(n+=1),i+=1)}return r}},function(t,e,r){t.exports={createIndex:r(25),KeyStore:r(26)}},function(t,e,r){var n=r(0),i=n.isArray,o=n.isDefined,a=n.isString,s=r(4),c=r(3);t.exports=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.getFn,u=void 0===n?s:n,h=r.ngrams,f=void 0!==h&&h,l=[];if(a(e[0]))for(var v=0,p=e.length;v<p;v+=1){var d=e[v];if(o(d)){var y={$:d,idx:v};f&&(y.ng=c(d,{sort:!0})),l.push(y)}}else for(var g=t.length,m=0,b=e.length;m<b;m+=1){for(var x=e[m],S={idx:m,$:{}},k=0;k<g;k+=1){var M=t[k],w=u(x,M);if(o(w))if(i(w)){for(var _=[],O=[{arrayIndex:-1,value:w}];O.length;){var j=O.pop(),A=j.arrayIndex,P=j.value;if(o(P))if(a(P)){var I={$:P,idx:A};f&&(I.ng=c(P,{sort:!0})),_.push(I)}else if(i(P))for(var C=0,L=P.length;C<L;C+=1)O.push({arrayIndex:C,value:P[C]})}S.$[M]=_}else{var F={$:w};f&&(F.ng=c(w,{sort:!0})),S.$[M]=F}}l.push(S)}return l}},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var i=r(0).isString,o=function(){function t(e){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._keys={},this._keyNames=[],this._length=e.length,this._hasWeights=!1,e.length&&i(e[0]))for(var r=0;r<this._length;r+=1){var n=e[r];this._keys[n]={weight:1},this._keyNames.push(n)}else{for(var o=0,a=0;a<this._length;a+=1){var s=e[a];if(!s.hasOwnProperty("name"))throw new Error('Missing "name" property in key object');var c=s.name;if(this._keyNames.push(c),!s.hasOwnProperty("weight"))throw new Error('Missing "weight" property in key object');var u=s.weight;if(u<=0||u>=1)throw new Error('"weight" property in key must bein the range of (0, 1)');this._keys[c]={weight:u},o+=u,this._hasWeights=!0}if(o>1)throw new Error("Total of keyWeights cannot exceed 1")}}var e,r,o;return e=t,(r=[{key:"get",value:function(t,e){return this._keys[t]?this._keys[t][e]:null}},{key:"keys",value:function(){return this._keyNames}},{key:"count",value:function(){return this._length}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}])&&n(e.prototype,r),o&&n(e,o),t}();t.exports=o},function(t,e,r){t.exports={transformMatches:r(28),transformScore:r(29)}},function(t,e,r){var n=r(0),i=(n.isArray,n.isDefined);n.isString,n.isNumber,n.isObject;t.exports=function(t,e){var r=t.matches;if(e.matches=[],i(r))for(var n=0,o=r.length;n<o;n+=1){var a=r[n];if(i(a.indices)&&0!==a.indices.length){var s={indices:a.indices,value:a.value};a.key&&(s.key=a.key),a.idx>-1&&(s.refIndex=a.idx),e.matches.push(s)}}}},function(t,e){t.exports=function(t,e){e.score=t.score}}])}));

@@ -8,3 +8,3 @@ {

},
"version": "5.0.2-beta",
"version": "5.0.3-beta",
"description": "Lightweight fuzzy-search",

@@ -28,3 +28,3 @@ "license": "Apache-2.0",

"prebuild": "npm run clean",
"build": "webpack --config ./configs/webpack.prod.js",
"build": "webpack --config ./configs/webpack.output.js",
"predev": "npm run clean",

@@ -31,0 +31,0 @@ "dev": "webpack --progress --colors --watch --config ./configs/webpack.dev.js"

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