From ec9ce992b7439836206a8af87186ab88d5d20be9 Mon Sep 17 00:00:00 2001 From: Kirollos Risk Date: Sat, 9 Mar 2019 21:01:20 -0800 Subject: [PATCH] Fixed #293 --- configs/webpack.prod.js | 5 ++++- dist/fuse.js | 2 +- package.json | 2 +- yarn.lock | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/configs/webpack.prod.js b/configs/webpack.prod.js index b5e8fe93c..6f93beec4 100644 --- a/configs/webpack.prod.js +++ b/configs/webpack.prod.js @@ -7,6 +7,9 @@ const CopyPlugin = require('copy-webpack-plugin') module.exports = merge(common, { mode: 'production', devtool: false, + module: { + rules: [{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }] + }, plugins: [ new CopyPlugin([{ from: path.resolve(__dirname, '../src/typings.d.ts'), @@ -16,4 +19,4 @@ module.exports = merge(common, { optimization: { minimizer: [new TerserPlugin()] } -}) +}) diff --git a/dist/fuse.js b/dist/fuse.js index b7b231d88..559ff59ff 100644 --- a/dist/fuse.js +++ b/dist/fuse.js @@ -6,4 +6,4 @@ * * http://www.apache.org/licenses/LICENSE-2.0 */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Fuse",[],t):"object"==typeof exports?exports.Fuse=t():e.Fuse=t()}(this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=(e=>Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e))},function(e,t,n){const r=n(2),o=n(8),s=n(0);e.exports=class{constructor(e,{location:t=0,distance:n=100,threshold:r=.6,maxPatternLength:s=32,caseSensitive:i=!1,tokenSeparator:l=/ +/g,findAllMatches:a=!1,minMatchCharLength:c=1,id:h=null,keys:u=[],shouldSort:p=!0,getFn:f=o,sortFn:d=((e,t)=>e.score-t.score),tokenize:g=!1,matchAllTokens:m=!1,includeMatches:y=!1,includeScore:x=!1,verbose:S=!1}){this.options={location:t,distance:n,threshold:r,maxPatternLength:s,isCaseSensitive:i,tokenSeparator:l,findAllMatches:a,minMatchCharLength:c,id:h,keys:u,includeMatches:y,includeScore:x,shouldSort:p,getFn:f,sortFn:d,verbose:S,tokenize:g,matchAllTokens:m},this.setCollection(e)}setCollection(e){return this.list=e,e}search(e,t={limit:!1}){this._log(`---------\nSearch pattern: "${e}"`);const{tokenSearchers:n,fullSearcher:r}=this._prepareSearchers(e);let{weights:o,results:s}=this._search(n,r);return this._computeScore(o,s),this.options.shouldSort&&this._sort(s),t.limit&&"number"==typeof t.limit&&(s=s.slice(0,t.limit)),this._format(s)}_prepareSearchers(e=""){const t=[];if(this.options.tokenize){const n=e.split(this.options.tokenSeparator);for(let e=0,o=n.length;e1)throw new Error("Key weight has to be > 0 and <= 1");a=a.name}else s[a]={weight:1};this._analyze({key:a,value:this.options.getFn(l,a),record:l,index:i},{resultMap:r,results:o,tokenSearchers:e,fullSearcher:t})}}return{weights:s,results:o}}_analyze({key:e,arrayIndex:t=-1,value:n,record:r,index:o},{tokenSearchers:i=[],fullSearcher:l=[],resultMap:a={},results:c=[]}){if(null==n)return;let h=!1,u=-1,p=0;if("string"==typeof n){this._log(`\nKey: ${""===e?"-":e}`);let s=l.search(n);if(this._log(`Full text: "${n}", score: ${s.score}`),this.options.tokenize){let e=n.split(this.options.tokenSeparator),t=[];for(let n=0;n-1&&(f=(f+u)/2),this._log("Score average:",f);let d=!this.options.tokenize||!this.options.matchAllTokens||p>=i.length;if(this._log(`\nCheck Matches: ${d}`),(h||s.isMatch)&&d){let i=a[o];i?i.output.push({key:e,arrayIndex:t,value:n,score:f,matchedIndices:s.matchedIndices}):(a[o]={item:r,output:[{key:e,arrayIndex:t,value:n,score:f,matchedIndices:s.matchedIndices}]},c.push(a[o]))}}else if(s(n))for(let t=0,s=n.length;t{const n=e.output;t.matches=[];for(let e=0,r=n.length;e-1&&(o.arrayIndex=r.arrayIndex),t.matches.push(o)}}),this.options.includeScore&&n.push((e,t)=>{t.score=e.score});for(let r=0,o=e.length;rt)return r(e,this.pattern,n);const{location:s,distance:i,threshold:l,findAllMatches:a,minMatchCharLength:c}=this.options;return o(e,this.pattern,this.patternAlphabet,{location:s,distance:i,threshold:l,findAllMatches:a,minMatchCharLength:c})}}},function(e,t){const n=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=((e,t,r=/ +/g)=>{let o=new RegExp(t.replace(n,"\\$&").replace(r,"|")),s=e.match(o),i=!!s,l=[];if(i)for(let t=0,n=s.length;t{const h=s,u=e.length;let p=l,f=e.indexOf(t,h);const d=t.length,g=[];for(let e=0;e=c;s-=1){let l=s-1,a=n[e.charAt(l)];if(a&&(g[l]=1),M[s]=(M[s+1]<<1|1)&a,0!==o&&(M[s]|=(m[s+1]|m[s])<<1|1|m[s+1]),M[s]&S&&(y=r(t,{errors:o,currentLocation:l,expectedLocation:h,distance:i}))<=p){if(p=y,(f=l)<=h)break;c=Math.max(1,2*h-f)}}if(r(t,{errors:o+1,currentLocation:h,expectedLocation:h,distance:i})>p)break;m=M}return{isMatch:f>=0,score:0===y?.001:y,matchedIndices:o(g,c)}})},function(e,t){e.exports=((e,{errors:t=0,currentLocation:n=0,expectedLocation:r=0,distance:o=100})=>{const s=t/e.length,i=Math.abs(r-n);return o?s+i/o:i?1:s})},function(e,t){e.exports=((e=[],t=1)=>{let n=[],r=-1,o=-1,s=0;for(let i=e.length;s=t&&n.push([r,o]),r=-1)}return e[s-1]&&s-r>=t&&n.push([r,s-1]),n})},function(e,t){e.exports=(e=>{let t={},n=e.length;for(let r=0;r{if(t){const s=t.indexOf(".");let i=t,l=null;-1!==s&&(i=t.slice(0,s),l=t.slice(s+1));const a=e[i];if(null!=a)if(l||"string"!=typeof a&&"number"!=typeof a)if(r(a))for(let e=0,t=a.length;eo(e,t,[]))}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Fuse",[],t):"object"==typeof exports?exports.Fuse=t():e.Fuse=t()}(this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{limit:!1};this._log('---------\nSearch pattern: "'.concat(e,'"'));var n=this._prepareSearchers(e),r=n.tokenSearchers,o=n.fullSearcher,i=this._search(r,o),a=i.weights,s=i.results;return this._computeScore(a,s),this.options.shouldSort&&this._sort(s),t.limit&&"number"==typeof t.limit&&(s=s.slice(0,t.limit)),this._format(s)}},{key:"_prepareSearchers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=[];if(this.options.tokenize)for(var n=e.split(this.options.tokenSeparator),r=0,o=n.length;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=this.list,r={},o=[];if("string"==typeof n[0]){for(var i=0,a=n.length;i1)throw new Error("Key weight has to be > 0 and <= 1");d=d.name}else s[d]={weight:1};this._analyze({key:d,value:this.options.getFn(l,d),record:l,index:c},{resultMap:r,results:o,tokenSearchers:e,fullSearcher:t})}return{weights:s,results:o}}},{key:"_analyze",value:function(e,t){var n=e.key,r=e.arrayIndex,o=void 0===r?-1:r,i=e.value,a=e.record,c=e.index,h=t.tokenSearchers,l=void 0===h?[]:h,u=t.fullSearcher,f=void 0===u?[]:u,d=t.resultMap,v=void 0===d?{}:d,p=t.results,g=void 0===p?[]:p;if(null!=i){var y=!1,m=-1,k=0;if("string"==typeof i){this._log("\nKey: ".concat(""===n?"-":n));var S=f.search(i);if(this._log('Full text: "'.concat(i,'", score: ').concat(S.score)),this.options.tokenize){for(var x=i.split(this.options.tokenSeparator),b=[],M=0;M-1&&(P=(P+m)/2),this._log("Score average:",P);var F=!this.options.tokenize||!this.options.matchAllTokens||k>=l.length;if(this._log("\nCheck Matches: ".concat(F)),(y||S.isMatch)&&F){var T=v[c];T?T.output.push({key:n,arrayIndex:o,value:i,score:P,matchedIndices:S.matchedIndices}):(v[c]={item:a,output:[{key:n,arrayIndex:o,value:i,score:P,matchedIndices:S.matchedIndices}]},g.push(v[c]))}}else if(s(i))for(var z=0,E=i.length;z-1&&(a.arrayIndex=i.arrayIndex),t.matches.push(a)}}}),this.options.includeScore&&o.push(function(e,t){t.score=e.score});for(var i=0,a=e.length;in)return o(e,this.pattern,r);var a=this.options,s=a.location,c=a.distance,h=a.threshold,l=a.findAllMatches,u=a.minMatchCharLength;return i(e,this.pattern,this.patternAlphabet,{location:s,distance:c,threshold:h,findAllMatches:l,minMatchCharLength:u})}}])&&r(t.prototype,n),s&&r(t,s),e}();e.exports=s},function(e,t){var n=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/ +/g,o=new RegExp(t.replace(n,"\\$&").replace(r,"|")),i=e.match(o),a=!!i,s=[];if(a)for(var c=0,h=i.length;c=P;z-=1){var E=z-1,K=n[e.charAt(E)];if(K&&(x[E]=1),T[z]=(T[z+1]<<1|1)&K,0!==I&&(T[z]|=(L[z+1]|L[z])<<1|1|L[z+1]),T[z]&C&&(w=r(t,{errors:I,currentLocation:E,expectedLocation:g,distance:h}))<=m){if(m=w,(k=E)<=g)break;P=Math.max(1,2*g-k)}}if(r(t,{errors:I+1,currentLocation:g,expectedLocation:g,distance:h})>m)break;L=T}return{isMatch:k>=0,score:0===w?.001:w,matchedIndices:o(x,p)}}},function(e,t){e.exports=function(e,t){var n=t.errors,r=void 0===n?0:n,o=t.currentLocation,i=void 0===o?0:o,a=t.expectedLocation,s=void 0===a?0:a,c=t.distance,h=void 0===c?100:c,l=r/e.length,u=Math.abs(s-i);return h?l+u/h:u?1:l}},function(e,t){e.exports=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=[],r=-1,o=-1,i=0,a=e.length;i=t&&n.push([r,o]),r=-1)}return e[i-1]&&i-r>=t&&n.push([r,i-1]),n}},function(e,t){e.exports=function(e){for(var t={},n=e.length,r=0;r