1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-01 01:51:57 +02:00
This commit is contained in:
Thomas Wilkerling
2019-02-02 23:14:20 +01:00
parent ef846b508d
commit a43db89ca5
19 changed files with 395 additions and 360 deletions

View File

@@ -43,20 +43,20 @@ Get Latest (Stable Release):
</tr>
<tr>
<td>flexsearch.min.js</td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/flexsearch.min.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/flexsearch.min.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/flexsearch.min.js</a></td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.min.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.min.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.min.js</a></td>
</tr>
<tr></tr>
<tr>
<td>flexsearch.light.js</td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/flexsearch.light.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/flexsearch.light.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/flexsearch.light.js</a></td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.light.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.light.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.light.js</a></td>
</tr>
<tr></tr>
<tr>
<td>flexsearch.compact.js</td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/flexsearch.compact.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/flexsearch.compact.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/flexsearch.compact.js</a></td>
<td><a href="https://github.com/nextapps-de/flexsearch/raw/master/dist/flexsearch.compact.js" target="_blank">Download</a></td>
<td><a href="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.compact.js" target="_blank">https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/dist/flexsearch.compact.js</a></td>
</tr>
<tr></tr>
<tr>
@@ -188,7 +188,7 @@ All Features:
Comparison: <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">Benchmark "Gulliver's Travels"</a>
__Query Test: "Gulliver's Travels"__
##### Query Test: "Gulliver's Travels"
<table>
<tr></tr>
@@ -282,7 +282,7 @@ __Query Test: "Gulliver's Travels"__
</tr>
</table>
__Memory Test: "Gulliver's Travels"__
##### Memory Test: "Gulliver's Travels"
<table>
<tr></tr>
@@ -491,15 +491,15 @@ __Note:__ This feature is actually not enabled by default. Read <a href="#contex
Use latest from CDN:
```html
<script src="https://cdn.rawgit.com/nextapps-de/flexsearch/master/flexsearch.min.js"></script>
<script src="https://cdn.rawgit.com/nextapps-de/flexsearch/master/dist/flexsearch.min.js"></script>
```
Or a specific version:
```html
<script src="https://cdn.rawgit.com/nextapps-de/flexsearch/0.3.2/flexsearch.min.js"></script>
<script src="https://cdn.rawgit.com/nextapps-de/flexsearch/0.3.51/dist/flexsearch.min.js"></script>
```
__AMD__
AMD:
```javascript
var FlexSearch = require("./flexsearch.js");
@@ -549,6 +549,7 @@ Index methods:
- <a href="#index.import">Index.__import__(string)</a>
## Usage
<a name="flexsearch.create"></a>
#### Create a new index
@@ -612,6 +613,7 @@ index.search("John", 10);
<a name="async_search"></a>
#### Async Search
Perform queries asynchronously:
```js
@@ -644,6 +646,7 @@ async function search(query){
```
#### Custom Search
Pass custom options for each query:
```js
@@ -673,6 +676,7 @@ index.search("John", {
```
#### Suggestions
Get also suggestions for a query:
```js
@@ -1561,7 +1565,7 @@ Compare these presets:
## Best Practices
__Split Complexity__
##### Split Complexity
Whenever you can, try to divide content by categories and add them to its own index, e.g.:
@@ -1616,7 +1620,7 @@ var results = search("action", "movie title"); // --> [1]
Filter queries by categories will hugely improve performance.
__Use numeric IDs__
##### Use numeric IDs
It is recommended to use numeric id values as reference when adding content to the index. The byte length of passed ids influences the memory consumption significantly. If this is not possible you should consider to use a index table and map the ids with indexes, this becomes important especially when using contextual indexes on a large amount of content.
@@ -1711,7 +1715,7 @@ index.stats;
The returning stats payload is divided into several categories. Each of these category provides its own statistic values.
__Profiler Stats Properties__
##### Profiler Stats Properties
<table>
<tr></tr>
<tr>
@@ -1774,7 +1778,7 @@ node compile SUPPORT_WORKER=true
> The custom build will be saved to flexsearch.custom.xxxxx.js (the "xxxxx" is a hash based on the used build flags).
__Supported Build Flags__
##### Supported Build Flags
<table>
<tr></tr>

View File

@@ -113,12 +113,13 @@ if(release === "lang"){
}
else{
exec("java -jar node_modules/google-closure-compiler-java/compiler.jar" + parameter + "' --js='flexsearch.js' --js='lang/**.js' --js='!lang/**.min.js'" + flag_str + " --js_output_file='flexsearch." + (options["RELEASE"] || "custom") + ".js' && exit 0", function(){
exec("java -jar node_modules/google-closure-compiler-java/compiler.jar" + parameter + "' --js='flexsearch.js' --js='lang/**.js' --js='!lang/**.min.js'" + flag_str + " --js_output_file='dist/flexsearch." + (options["RELEASE"] || "custom") + ".js' && exit 0", function(){
var filename = "flexsearch." + (options["RELEASE"] || "custom") + ".js";
console.log("Build Complete: " + filename);
/*
if(release === "es5"){
//fs.existsSync("dist/") || fs.mkdirSync("dist/");
@@ -128,6 +129,7 @@ else{
//fs.copyFileSync(filename, "dist/latest/" + filename);
fs.unlinkSync(filename);
}
*/
});
}

23
dist/flexsearch.compact.js vendored Normal file
View File

@@ -0,0 +1,23 @@
/*
FlexSearch v0.3.51
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(f,r,d){let k;(k=d.define)&&k.amd?k([],function(){return r}):(k=d.modules)?k[f.toLowerCase()]=r:"object"===typeof exports?module.exports=r:d[f]=r})("FlexSearch",function(){function f(b){z(b)&&(b=F[b]);b||(b=v);this.id=b.id||L++;this.init(b);r(this,"index",function(){return this.b});r(this,"length",function(){return Object.keys(this.b).length})}function r(b,a,c){Object.defineProperty(b,a,{get:c})}function d(b){return new RegExp(b,"g")}function k(b,a){for(let c=0;c<a.length;c+=
2)b=b.replace(a[c],a[c+1]);return b}function y(b,a,c,g,e,d,m){if(a[c])return a[c];e=e?(9-(m||6))*d+(m||6)*e:d;a[c]=e;e>=m&&(b=b[9-(e+.5>>0)],b=b[c]||(b[c]=[]),b[b.length]=g);return e}function C(b,a){if(b){const c=Object.keys(b);for(let g=0,d=c.length;g<d;g++){const d=c[g],e=b[d];if(e)for(let c=0,g=e.length;c<g;c++)if(e[c]===a){1===g?delete b[d]:e.splice(c,1);break}else"object"===typeof e[c]&&C(e[c],a)}}}function D(b){let a="",c="";var d="";for(let e=0;e<b.length;e++){const g=b[e];if(g!==c)if(e&&"h"===
g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)a+=g}else a+=g;d=e===b.length-1?"":b[e+1];c=g}return a}function M(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function N(b,a){b=b.length-a.length;return 0>b?-1:b?1:0}function O(b,a,c){let d=[],e;const t=b.length;if(1<t){b.sort(N);const g=u();let l=b[0],n=l.length,h=0;for(;h<n;)g["@"+l[h++]]=1;let f,p=0,q=0;for(;++q<t;){let G=!1;const k=q===t-1;e=[];l=b[q];n=l.length;for(h=
0;h<n;){f=l[h++];var m="@"+f;if(g[m]){const b=g[m];if(b===q){if(k){if(d[p++]=f,a&&p===a)return d}else g[m]=q+1;G=!0}else c&&(m=e[b]||(e[b]=[]),m[m.length]=f)}}if(!G&&!c)break}if(c&&(p=d.length,(q=e.length)&&(!a||p<a)))for(;q--;)if(f=e[q])for(h=0,n=f.length;h<n;h++)if(d[p++]=f[h],a&&p===a)return d}else t&&(d=b[0],a&&d.length>a&&(d=d.slice(0,a)));return d}function z(b){return"string"===typeof b}function A(b){return"function"===typeof b}function B(b){return"undefined"===typeof b}function H(b){const a=
Array(b);for(let c=0;c<b;c++)a[c]=u();return a}function u(){return Object.create(null)}const v={encode:"icase",a:"forward",i:!1,cache:!1,async:!1,j:!1,threshold:0,depth:0},F={memory:{encode:"extra",a:"strict",threshold:7},speed:{encode:"icase",a:"strict",threshold:7,depth:2},match:{encode:"extra",a:"full"},score:{encode:"extra",a:"strict",threshold:5,depth:4},balance:{encode:"balance",a:"strict",threshold:6,depth:3},fastest:{encode:"icase",a:"strict",threshold:9,depth:1}},E=[];let L=0;const I=d("\\W+"),
J={},K={};f.create=function(b){return new f(b)};f.registerMatcher=function(b){for(const a in b)b.hasOwnProperty(a)&&E.push(d(a),b[a]);return this};f.registerEncoder=function(b,a){x[b]=a.bind(x);return this};f.registerLanguage=function(b,a){J[b]=a.filter;K[b]=a.stemmer;return this};f.encode=function(b,a){return x[b](a)};f.prototype.init=function(b){this.h=[];b||(b=v);var a=b.preset,c=a?F[a]:{};this.a=b.tokenize||c.a||this.a||v.a;this.async="undefined"===typeof Promise||B(a=b.async)?this.async||v.async:
a;this.threshold=B(a=b.threshold)?c.threshold||this.threshold||v.threshold:a;this.depth=B(a=b.depth)?c.depth||this.depth||v.depth:a;this.f=(a=B(a=b.encode)?c.encode:a)&&x[a]&&x[a].bind(x)||(A(a)?a:this.f||!1);(a=b.matcher)&&this.addMatcher(a);if(a=b.filter){a=J[a]||a;c=this.f;var g=u();if(a)for(let b=0;b<a.length;b++){const d=c?c(a[b]):a[b];g[d]=String.fromCharCode(65E3-a.length+b)}this.filter=a=g}if(a=b.stemmer){var e;b=K[a]||a;a=this.f;c=[];if(b)for(e in b)b.hasOwnProperty(e)&&(g=a?a(e):e,c.push(d("(?=.{"+
(g.length+3)+",})"+g+"$"),a?a(b[e]):b[e]));this.stemmer=e=c}this.g=H(10-(this.threshold||0));this.c=u();this.b=u();return this};f.prototype.encode=function(b){b&&E.length&&(b=k(b,E));b&&this.h.length&&(b=k(b,this.h));b&&this.f&&(b=this.f(b));b&&this.stemmer&&(b=k(b,this.stemmer));return b};f.prototype.addMatcher=function(b){const a=this.h;for(const c in b)b.hasOwnProperty(c)&&a.push(d(c),b[c]);return this};f.prototype.add=function(b,a,c,d,e){if(a&&z(a)&&(b||0===b)){var g="@"+b;if(this.b[g]&&!d)return this.update(b,
a);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(b,a,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(b,a,null,d,!0),c(),this}a=this.encode(a);if(!a.length)return this;c=this.a;e=A(c)?c(a):a.split(I);const k=u();k._ctx=u();const p=this.threshold,q=this.depth,t=this.g,w=e.length;for(let a=0;a<w;a++){var m=e[a];if(m){var f=m.length,l=(w-a)/w,n="";switch(c){case "reverse":case "both":for(var h=
f-1;1<=h;h--)n=m[h]+n,y(t,k,n,b,(f-h)/f,l,p);n="";case "forward":for(h=0;h<f;h++)n+=m[h],y(t,k,n,b,1,l,p);break;case "full":for(h=0;h<f;h++){const a=(f-h)/f;for(let c=f;c>h;c--)n=m.substring(h,c),y(t,k,n,b,a,l,p)}break;default:if(f=y(t,k,m,b,1,l,p),q&&1<w&&f>=p)for(f=k._ctx[m]||(k._ctx[m]=u()),m=this.c[m]||(this.c[m]=H(10-(p||0))),l=a-q,n=a+q+1,0>l&&(l=0),n>w&&(n=w);l<n;l++)l!==a&&y(m,f,e[l],b,0,10-(l<a?a-l:l-a),p)}}}this.b[g]=1}return this};f.prototype.update=function(b,a,c){this.b["@"+b]&&z(a)&&
(this.remove(b),this.add(b,a,c,!0));return this};f.prototype.remove=function(b,a,c){var d="@"+b;if(this.b[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(a){setTimeout(function(){c.remove(b,null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<10-(this.threshold||0);a++)C(this.g[a],b);this.depth&&C(this.c,b);delete this.b[d]}return this};f.prototype.search=function(b,a,c,d){let e=b;let f=
[];if("object"===typeof b){(c=b.callback||a)&&(e.callback=null);a=b.limit;var g=b.threshold;b=b.query}g||(g=this.threshold||0);A(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let b=this;g=new Promise(function(c){setTimeout(function(){c(b.search(e,a,null,!0));b=null})});if(c)g.then(c);else return g;return this}if(c)return c(this.search(e,a,null,!0)),this}if(!b||!z(b))return f;e=b;e=this.encode(e);if(!e.length)return f;c=this.a;c=A(c)?c(e):e.split(I);b=c.length;
d=!0;const k=[],l=u();let n;if(1<b)if(this.depth){n=!0;var h=c[0];l[h]=1}else c.sort(M);let r;if(!n||(r=this.c)[h])for(let a=n?1:0;a<b;a++){const b=c[a];if(b){if(!l[b]){const a=[];let c=!1,e=0;if(h=n?r[h]:this.g){let d;for(let f=0;f<10-g;f++)if(d=h[f][b])a[e++]=d,c=!0}if(c)k[k.length]=1<e?a.concat.apply([],a):a[0];else{d=!1;break}l[b]=1}h=b}}else d=!1;d&&(f=O(k,a,!1));return f};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.g=this.c=this.b=null;return this};
const x={icase:function(b){return b.toLowerCase()},simple:function(){const b=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(a){a=k(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=
[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=k(a,b));c||1<a.length&&(a=D(a));return a}}(),extra:function(){const b=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=
a.split(" ");for(let c=0;c<a.length;c++){const d=a[c];1<d.length&&(a[c]=d[0]+k(d.substring(1),b))}a=a.join(" ");a=D(a)}return a}}(),balance:function(){const b=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(a){return D(k(a.toLowerCase(),b))}}()};return f}(!1),this);

37
dist/flexsearch.es5.js vendored Normal file
View File

@@ -0,0 +1,37 @@
/*
FlexSearch v0.3.51
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';function J(g){var k=0;return function(){return k<g.length?{done:!1,value:g[k++]}:{done:!0}}}function K(g){var k="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return k?k.call(g):{next:J(g)}}var Q="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,R="function"==typeof Object.defineProperties?Object.defineProperty:function(g,k,e){g!=Array.prototype&&g!=Object.prototype&&(g[k]=e.value)};
function S(g,k){if(k){var e=Q;g=g.split(".");for(var h=0;h<g.length-1;h++){var l=g[h];l in e||(e[l]={});e=e[l]}g=g[g.length-1];h=e[g];k=k(h);k!=h&&null!=k&&R(e,g,{configurable:!0,writable:!0,value:k})}}
S("Promise",function(g){function k(d){this.b=0;this.i=void 0;this.a=[];var c=this.c();try{d(c.resolve,c.reject)}catch(z){c.reject(z)}}function e(){this.a=null}function h(d){return d instanceof k?d:new k(function(c){c(d)})}if(g)return g;e.prototype.b=function(d){if(null==this.a){this.a=[];var c=this;this.c(function(){c.i()})}this.a.push(d)};var l=Q.setTimeout;e.prototype.c=function(d){l(d,0)};e.prototype.i=function(){for(;this.a&&this.a.length;){var d=this.a;this.a=[];for(var c=0;c<d.length;++c){var e=
d[c];d[c]=null;try{e()}catch(D){this.f(D)}}}this.a=null};e.prototype.f=function(d){this.c(function(){throw d;})};k.prototype.c=function(){function d(d){return function(k){e||(e=!0,d.call(c,k))}}var c=this,e=!1;return{resolve:d(this.F),reject:d(this.f)}};k.prototype.F=function(d){if(d===this)this.f(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof k)this.G(d);else{a:switch(typeof d){case "object":var c=null!=d;break a;case "function":c=!0;break a;default:c=!1}c?this.D(d):this.j(d)}};
k.prototype.D=function(d){var c=void 0;try{c=d.then}catch(z){this.f(z);return}"function"==typeof c?this.H(c,d):this.j(d)};k.prototype.f=function(c){this.m(2,c)};k.prototype.j=function(c){this.m(1,c)};k.prototype.m=function(c,e){if(0!=this.b)throw Error("Cannot settle("+c+", "+e+"): Promise already settled in state"+this.b);this.b=c;this.i=e;this.u()};k.prototype.u=function(){if(null!=this.a){for(var d=0;d<this.a.length;++d)c.b(this.a[d]);this.a=null}};var c=new e;k.prototype.G=function(c){var d=this.c();
c.A(d.resolve,d.reject)};k.prototype.H=function(c,e){var d=this.c();try{c.call(e,d.resolve,d.reject)}catch(D){d.reject(D)}};k.prototype.then=function(c,e){function d(c,d){return"function"==typeof c?function(d){try{g(c(d))}catch(w){h(w)}}:d}var g,h,B=new k(function(c,d){g=c;h=d});this.A(d(c,g),d(e,h));return B};k.prototype.catch=function(c){return this.then(void 0,c)};k.prototype.A=function(d,e){function k(){switch(g.b){case 1:d(g.i);break;case 2:e(g.i);break;default:throw Error("Unexpected state: "+
g.b);}}var g=this;null==this.a?c.b(k):this.a.push(k)};k.resolve=h;k.reject=function(c){return new k(function(d,e){e(c)})};k.race=function(c){return new k(function(d,e){for(var k=K(c),g=k.next();!g.done;g=k.next())h(g.value).A(d,e)})};k.all=function(c){var d=K(c),e=d.next();return e.done?h([]):new k(function(c,k){function g(d){return function(e){l[d]=e;C--;0==C&&c(l)}}var l=[],C=0;do l.push(void 0),C++,h(e.value).A(g(l.length-1),k),e=d.next();while(!e.done)})};return k});
(function(g,k,e){var h;(h=e.define)&&h.amd?h([],function(){return k}):(h=e.modules)?h[g.toLowerCase()]=k:"object"===typeof exports?module.exports=k:e[g]=k})("FlexSearch",function W(g){function e(b){C(b)&&((b=L[b])||console.warn("Preset not found: "+b));b||(b=t);this.id=b.id||X++;this.init(b);l(this,"index",function(){return this.a});l(this,"length",function(){return Object.keys(this.a).length})}function h(b,a,f,c){this.v!==this.h&&(this.l=this.l.concat(f),this.v++,c&&this.l.length>=c&&(this.v=this.h),
this.B&&this.v===this.h&&(this.cache&&this.o.set(a,this.l),this.B(this.l),this.l=[]));return this}function l(b,a,f){Object.defineProperty(b,a,{get:f})}function c(b){return new RegExp(b,"g")}function d(b,a){for(var f=0;f<a.length;f+=2)b=b.replace(a[f],a[f+1]);return b}function B(b,a,f,c,d,e,g){if(a[f])return a[f];d=d?(9-(g||6))*e+(g||6)*d:e;a[f]=d;d>=g&&(b=b[9-(d+.5>>0)],b=b[f]||(b[f]=[]),b[b.length]=c);return d}function z(b,a){if(b)for(var f=Object.keys(b),c=0,d=f.length;c<d;c++){var e=f[c],g=b[e];
if(g)for(var x=0,h=g.length;x<h;x++)if(g[x]===a){1===h?delete b[e]:g.splice(x,1);break}else"object"===typeof g[x]&&z(g[x],a)}}function D(b){for(var a="",f="",c="",d=0;d<b.length;d++){var e=b[d];if(e!==f)if(d&&"h"===e){if(c="a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c,("a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f)&&c||" "===f)a+=e}else a+=e;c=d===b.length-1?"":b[d+1];f=e}return a}function T(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function V(b,a){b=b.length-a.length;return 0>b?
-1:b?1:0}function U(b,a,f){var c=[],d=b.length;if(1<d){b.sort(V);for(var e=y(),g=b[0],x=g.length,h=0;h<x;)e["@"+g[h++]]=1;for(var l,E=0,r=0;++r<d;){var q=!1,u=r===d-1;var n=[];g=b[r];x=g.length;for(h=0;h<x;){l=g[h++];var m="@"+l;if(e[m]){var p=e[m];if(p===r){if(u){if(c[E++]=l,a&&E===a)return c}else e[m]=r+1;q=!0}else f&&(m=n[p]||(n[p]=[]),m[m.length]=l)}}if(!q&&!f)break}if(f&&(E=c.length,(r=n.length)&&(!a||E<a)))for(;r--;)if(l=n[r])for(h=0,x=l.length;h<x;h++)if(c[E++]=l[h],a&&E===a)return c}else d&&
(c=b[0],a&&c.length>a&&(c=c.slice(0,a)));return c}function C(b){return"string"===typeof b}function G(b){return"function"===typeof b}function w(b){return"undefined"===typeof b}function M(b){for(var a=Array(b),f=0;f<b;f++)a[f]=y();return a}function y(){return Object.create(null)}function Y(){var b,a;self.onmessage=function(f){if(f=f.data)if(f.search){var c=a.search(f.content,f.threshold?{limit:f.limit,threshold:f.threshold}:f.limit);self.postMessage({id:b,content:f.content,limit:f.limit,result:c})}else f.add?
a.add(f.id,f.content):f.update?a.update(f.id,f.content):f.remove?a.remove(f.id):f.clear?a.clear():f.info?(f=a.info(),f.worker=b,console.log(f)):f.register&&(b=f.id,f.options.cache=!1,f.options.async=!1,f.options.worker=!1,a=(new Function(f.register.substring(f.register.indexOf("{")+1,f.register.lastIndexOf("}"))))(),a=new a(f.options))}}function Z(b,a,f,c){b=g("flexsearch","id"+b,Y,function(a){(a=a.data)&&a.result&&c(a.id,a.content,a.result,a.limit)},a);var d=W.toString();f.id=a;b.postMessage({register:d,
options:f,id:a});return b}var t={encode:"icase",g:"forward",w:!1,cache:!1,async:!1,h:!1,threshold:0,depth:0},L={memory:{encode:"extra",g:"strict",threshold:7},speed:{encode:"icase",g:"strict",threshold:7,depth:2},match:{encode:"extra",g:"full"},score:{encode:"extra",g:"strict",threshold:5,depth:4},balance:{encode:"balance",g:"strict",threshold:6,depth:3},fastest:{encode:"icase",g:"strict",threshold:9,depth:1}},I=[],X=0,N=c("\\W+"),O={},P={};e.create=function(b){return new e(b)};e.registerMatcher=
function(b){for(var a in b)b.hasOwnProperty(a)&&I.push(c(a),b[a]);return this};e.registerEncoder=function(b,a){F[b]=a.bind(F);return this};e.registerLanguage=function(b,a){O[b]=a.filter;P[b]=a.stemmer;return this};e.encode=function(b,a){return F[b](a)};e.prototype.init=function(b){this.i=[];b||(b=t);var a=b.preset,f=a?L[a]:{};f||console.warn("Preset not found: "+a);if(a=b.worker)if("undefined"===typeof Worker)b.worker=!1,this.f=null;else{var d=parseInt(a,10)||4;this.u=-1;this.v=0;this.l=[];this.B=
null;this.f=Array(d);for(var e=0;e<d;e++)this.f[e]=Z(this.id,e,b,h.bind(this))}this.g=b.tokenize||f.g||this.g||t.g;this.async="undefined"===typeof Promise||w(a=b.async)?this.async||t.async:a;this.h=w(a=b.worker)?this.h||t.h:a;this.threshold=w(a=b.threshold)?f.threshold||this.threshold||t.threshold:a;this.depth=w(a=b.depth)?f.depth||this.depth||t.depth:a;this.w=w(a=b.suggest)?this.w||t.w:a;this.j=(a=w(a=b.encode)?f.encode:a)&&F[a]&&F[a].bind(F)||(G(a)?a:this.j||!1);(a=b.matcher)&&this.addMatcher(a);
if(a=b.filter){a=O[a]||a;f=this.j;d=y();if(a)for(e=0;e<a.length;e++){var g=f?f(a[e]):a[e];d[g]=String.fromCharCode(65E3-a.length+e)}this.filter=d}if(a=b.stemmer){f=P[a]||a;d=this.j;e=[];if(f)for(var l in f)f.hasOwnProperty(l)&&(g=d?d(l):l,e.push(c("(?=.{"+(g.length+3)+",})"+g+"$"),d?d(f[l]):f[l]));this.stemmer=e}this.b=M(10-(this.threshold||0));this.c=y();this.a=y();this.m=!0;this.o=(this.cache=a=w(a=b.cache)?this.cache||t.cache:a)?new aa(a):!1;return this};e.prototype.encode=function(b){b&&I.length&&
(b=d(b,I));b&&this.i.length&&(b=d(b,this.i));b&&this.j&&(b=this.j(b));b&&this.stemmer&&(b=d(b,this.stemmer));return b};e.prototype.addMatcher=function(b){var a=this.i,f;for(f in b)b.hasOwnProperty(f)&&a.push(c(f),b[f]);return this};e.prototype.add=function(b,a,f,c,d){if(a&&C(a)&&(b||0===b)){var e="@"+b;if(this.a[e]&&!c)return this.update(b,a);if(this.h)return++this.u>=this.f.length&&(this.u=0),this.f[this.u].postMessage({add:!0,id:b,content:a}),this.a[e]=""+this.u,f&&f(),this;if(!d){if(this.async&&
"function"!==typeof importScripts){var g=this;e=new Promise(function(f){setTimeout(function(){g.add(b,a,null,c,!0);g=null;f()})});if(f)e.then(f);else return e;return this}if(f)return this.add(b,a,null,c,!0),f(),this}a=this.encode(a);if(!a.length)return this;f=this.g;d=G(f)?f(a):a.split(N);var h=y();h._ctx=y();for(var A=this.threshold,l=this.depth,H=this.b,r=d.length,q=0;q<r;q++){var u=d[q];if(u){var n=u.length,m=(r-q)/r,p="";switch(f){case "reverse":case "both":for(var v=n-1;1<=v;v--)p=u[v]+p,B(H,
h,p,b,(n-v)/n,m,A);p="";case "forward":for(v=0;v<n;v++)p+=u[v],B(H,h,p,b,1,m,A);break;case "full":for(v=0;v<n;v++)for(var w=(n-v)/n,t=n;t>v;t--)p=u.substring(v,t),B(H,h,p,b,w,m,A);break;default:if(n=B(H,h,u,b,1,m,A),l&&1<r&&n>=A)for(n=h._ctx[u]||(h._ctx[u]=y()),u=this.c[u]||(this.c[u]=M(10-(A||0))),m=q-l,p=q+l+1,0>m&&(m=0),p>r&&(p=r);m<p;m++)m!==q&&B(u,n,d[m],b,0,10-(m<q?q-m:m-q),A)}}}this.a[e]=1;this.m=!1}return this};e.prototype.update=function(b,a,f){this.a["@"+b]&&C(a)&&(this.remove(b),this.add(b,
a,f,!0));return this};e.prototype.remove=function(b,a,f){var c="@"+b;if(this.a[c]){if(this.h)return this.f[this.a[c]].postMessage({remove:!0,id:b}),delete this.a[c],a&&a(),this;if(!f){if(this.async&&"function"!==typeof importScripts){var d=this;c=new Promise(function(a){setTimeout(function(){d.remove(b,null,!0);d=null;a()})});if(a)c.then(a);else return c;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<10-(this.threshold||0);a++)z(this.b[a],b);this.depth&&z(this.c,b);delete this.a[c];
this.m=!1}return this};e.prototype.search=function(b,a,c,d){var f=b,e=[];if("object"===typeof b){(c=b.callback||a)&&(f.callback=null);a=b.limit;var g=b.threshold;b=b.query}g||(g=this.threshold||0);G(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(this.h)for(this.B=c,this.v=0,this.l=[],e=0;e<this.h;e++)this.f[e].postMessage({search:!0,limit:a,threshold:g,content:b});else{if(!d){if(this.async&&"function"!==typeof importScripts){var h=this;b=new Promise(function(b){setTimeout(function(){b(h.search(f,a,null,!0));
h=null})});if(c)b.then(c);else return b;return this}if(c)return c(this.search(f,a,null,!0)),this}if(!b||!C(b))return e;f=b;if(this.cache)if(this.m){if(c=this.o.get(b))return c}else this.o.clear(),this.m=!0;f=this.encode(f);if(!f.length)return e;c=this.g;c=G(c)?c(f):f.split(N);d=c.length;var l=!0,A=[],t=y();if(1<d)if(this.depth){var r=!0;var q=c[0];t[q]=1}else c.sort(T);var u;if(!r||(u=this.c)[q])for(var n=r?1:0;n<d;n++){var m=c[n];if(m){if(!t[m]){var p=[],v=!1,w=0;if(q=r?u[q]:this.b)for(var B=void 0,
z=0;z<10-g;z++)if(B=q[z][m])p[w++]=B,v=!0;if(v)A[A.length]=1<w?p.concat.apply([],p):p[0];else if(!this.w){l=!1;break}t[m]=1}q=m}}else l=!1;l&&(e=U(A,a,this.w));this.cache&&this.o.set(b,e);return e}};e.prototype.info=function(){if(this.h)for(var b=0;b<this.h;b++)this.f[b].postMessage({info:!0,id:this.id});else{for(var a,c=0,d=0,e=0,g=0;g<10-(this.threshold||0);g++){b=Object.keys(this.b[g]);for(var h=0;h<b.length;h++)a=this.b[g][b[h]].length,c+=1*a+2*b[h].length+4,d+=a,e+=2*b[h].length}b=Object.keys(this.a);
a=b.length;for(g=0;g<a;g++)c+=2*b[g].length+2;return{id:this.id,memory:c,items:a,sequences:d,chars:e,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:I.length+(this.i?this.i.length:0),worker:this.h,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.g}}};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.cache&&(this.o.clear(),this.o=null);this.b=this.c=this.a=null;return this};e.prototype.export=function(){return JSON.stringify([this.b,
this.c,this.a])};e.prototype.import=function(b){b=JSON.parse(b);this.b=b[0];this.c=b[1];this.a=b[2]};var F={icase:function(b){return b.toLowerCase()},simple:function(){var b=[c("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",c("[\u00e8\u00e9\u00ea\u00eb]"),"e",c("[\u00ec\u00ed\u00ee\u00ef]"),"i",c("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",c("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",c("[\u00fd\u0177\u00ff]"),"y",c("\u00f1"),"n",c("\u00e7"),"c",c("\u00df"),"s",c(" & ")," and ",c("[-/]")," ",c("[^a-z0-9 ]"),
"",c("\\s+")," "];return function(a){a=d(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){var b=[c("ae"),"a",c("ai"),"ei",c("ay"),"ei",c("ey"),"ei",c("oe"),"o",c("ue"),"u",c("ie"),"i",c("sz"),"s",c("zs"),"s",c("sh"),"s",c("ck"),"k",c("cc"),"k",c("dt"),"t",c("ph"),"f",c("pf"),"f",c("ou"),"o",c("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=d(a,b));c||1<a.length&&(a=D(a));return a}}(),extra:function(){var b=[c("p"),"b",c("z"),"s",c("[cgq]"),"k",c("n"),"m",
c("d"),"t",c("[vw]"),"f",c("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(var c=0;c<a.length;c++){var e=a[c];1<e.length&&(a[c]=e[0]+d(e.substring(1),b))}a=a.join(" ");a=D(a)}return a}}(),balance:function(){var b=[c("[-/]")," ",c("[^a-z0-9 ]"),"",c("\\s+")," "];return function(a){return D(d(a.toLowerCase(),b))}}()},aa=function(){function b(a){this.clear();this.C=!0!==a&&a}b.prototype.clear=function(){this.cache=y();this.count=y();this.index=
y();this.s=[]};b.prototype.set=function(a,b){if(this.C&&w(this.cache[a])){var c=this.s.length;if(c===this.C){c--;var e=this.s[c];delete this.cache[e];delete this.count[e];delete this.index[e]}this.index[a]=c;this.s[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};b.prototype.get=function(a){var b=this.cache[a];if(this.C&&b){var c=++this.count[a],e=this.index,d=e[a];if(0<d){for(var g=this.s,h=d;this.count[g[--d]]<=c&&-1!==d;);d++;if(d!==h){for(c=h;c>d;c--)h=g[c-1],g[c]=h,e[h]=
c;g[d]=a;e[a]=d}}}return b};return b}();return e}(function(){var g={},k="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,h,l,c,d){l=k?URL.createObjectURL(new Blob(["("+l.toString()+")()"],{type:"text/javascript"})):e+".es5.js";e+="-"+h;g[e]||(g[e]=[]);g[e][d]=new Worker(l);g[e][d].onmessage=c;console.log("Register Worker: "+e+"@"+d);return g[e][d]}}()),this);

18
dist/flexsearch.light.js vendored Normal file
View File

@@ -0,0 +1,18 @@
/*
FlexSearch v0.3.51
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(e,u,v){let m;(m=v.define)&&m.amd?m([],function(){return u}):(m=v.modules)?m[e.toLowerCase()]=u:"object"===typeof exports?module.exports=u:v[e]=u})("FlexSearch",function(){function e(a){a||(a=x);this.id=a.id||G++;this.init(a);u(this,"index",function(){return this.a});u(this,"length",function(){return Object.keys(this.a).length})}function u(a,b,c){Object.defineProperty(a,b,{get:c})}function v(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function m(a,b,c,
f,d,n,g){if(b[c])return b[c];d=d?(9-(g||6))*n+(g||6)*d:n;b[c]=d;d>=g&&(a=a[9-(d+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=f);return d}function z(a,b){if(a){const c=Object.keys(a);for(let f=0,d=c.length;f<d;f++){const d=c[f],g=a[d];if(g)for(let c=0,f=g.length;c<f;c++)if(g[c]===b){1===f?delete a[d]:g.splice(c,1);break}else"object"===typeof g[c]&&z(g[c],b)}}}function H(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function I(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function y(a){return"function"===typeof a}
function A(a){return"undefined"===typeof a}function C(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=t();return b}function t(){return Object.create(null)}const x={encode:"icase",b:"forward",i:!1,cache:!1,async:!1,j:!1,threshold:0,depth:0},B=[];let G=0;const D=/\W+/g,E={},F={};e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&B.push(new RegExp(b,"g"),a[b]);return this};e.registerEncoder=function(a,b){w[a]=b.bind(w);return this};e.registerLanguage=
function(a,b){E[a]=b.filter;F[a]=b.stemmer;return this};e.encode=function(a,b){return w[a](b)};e.prototype.init=function(a){this.h=[];a||(a=x);var b=a.preset,c={};this.b=a.tokenize||c.b||this.b||x.b;this.threshold=A(b=a.threshold)?c.threshold||this.threshold||x.threshold:b;this.depth=A(b=a.depth)?c.depth||this.depth||x.depth:b;this.f=(b=A(b=a.encode)?c.encode:b)&&w[b]&&w[b].bind(w)||(y(b)?b:this.f||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){b=E[b]||b;c=this.f;var f=t();if(b)for(let a=0;a<
b.length;a++){const d=c?c(b[a]):b[a];f[d]=String.fromCharCode(65E3-b.length+a)}this.filter=b=f}if(b=a.stemmer){var d;a=F[b]||b;b=this.f;c=[];if(a)for(d in a)a.hasOwnProperty(d)&&(f=b?b(d):d,c.push(new RegExp("(?=.{"+(f.length+3)+",})"+f+"$","g"),b?b(a[d]):a[d]));this.stemmer=d=c}this.g=C(10-(this.threshold||0));this.c=t();this.a=t();return this};e.prototype.encode=function(a){a&&B.length&&(a=v(a,B));a&&this.h.length&&(a=v(a,this.h));a&&this.f&&(a=this.f(a));a&&this.stemmer&&(a=v(a,this.stemmer));
return a};e.prototype.addMatcher=function(a){const b=this.h;for(const c in a)a.hasOwnProperty(c)&&b.push(new RegExp(c,"g"),a[c]);return this};e.prototype.add=function(a,b,c,f,d){if(b&&"string"===typeof b&&(a||0===a)){const e="@"+a;if(this.a[e]&&!f)return this.update(a,b);if(!d&&c)return this.add(a,b,null,f,!0),c(),this;b=this.encode(b);if(!b.length)return this;c=this.b;b=y(c)?c(b):b.split(D);f=t();f._ctx=t();d=this.threshold;const r=this.depth,q=this.g,p=b.length;for(let e=0;e<p;e++){var n=b[e];if(n){var g=
n.length,k=(p-e)/p,l="";switch(c){case "reverse":case "both":for(var h=g-1;1<=h;h--)l=n[h]+l,m(q,f,l,a,(g-h)/g,k,d);l="";case "forward":for(h=0;h<g;h++)l+=n[h],m(q,f,l,a,1,k,d);break;case "full":for(h=0;h<g;h++){const b=(g-h)/g;for(let c=g;c>h;c--)l=n.substring(h,c),m(q,f,l,a,b,k,d)}break;default:if(g=m(q,f,n,a,1,k,d),r&&1<p&&g>=d)for(g=f._ctx[n]||(f._ctx[n]=t()),n=this.c[n]||(this.c[n]=C(10-(d||0))),k=e-r,l=e+r+1,0>k&&(k=0),l>p&&(l=p);k<l;k++)k!==e&&m(n,g,b[k],a,0,10-(k<e?e-k:k-e),d)}}}this.a[e]=
1}return this};e.prototype.update=function(a,b,c){this.a["@"+a]&&"string"===typeof b&&(this.remove(a),this.add(a,b,c,!0));return this};e.prototype.remove=function(a,b,c){const f="@"+a;if(this.a[f]){if(!c&&b)return this.remove(a,null,!0),b(),this;for(b=0;b<10-(this.threshold||0);b++)z(this.g[b],a);this.depth&&z(this.c,a);delete this.a[f]}return this};e.prototype.search=function(a,b,c,f){var d=a,e=[];if("object"===typeof a){b=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);y(b)?(c=b,b=
1E3):b||0===b||(b=1E3);if(!f&&c)return c(this.search(d,b,null,!0)),this;if(!a||"string"!==typeof a)return e;d=this.encode(a);if(!d.length)return e;a=this.b;a=y(a)?a(d):d.split(D);c=a.length;f=!0;d=[];var k=t();if(1<c)if(this.depth){var l=!0;var h=a[0];k[h]=1}else a.sort(H);var m;if(!l||(m=this.c)[h])for(var r=l?1:0;r<c;r++){var q=a[r];if(q){if(!k[q]){var p=[];let a=!1,b=0;if(h=l?m[h]:this.g){let c;for(let d=0;d<10-g;d++)if(c=h[d][q])p[b++]=c,a=!0}if(a)d[d.length]=1<b?p.concat.apply([],p):p[0];else{f=
!1;break}k[q]=1}h=q}}else f=!1;if(f)a:{g=[];e=d.length;if(1<e){d.sort(I);l=t();m=d[0];h=m.length;for(a=0;a<h;)l["@"+m[a++]]=1;for(k=f=0;++k<e;){r=!1;q=k===e-1;m=d[k];h=m.length;for(a=0;a<h;)if(c=m[a++],p="@"+c,l[p]&&l[p]===k){if(q){if(g[f++]=c,b&&f===b){e=g;break a}}else l[p]=k+1;r=!0}if(!r)break}}else e&&(g=d[0],b&&g.length>b&&(g=g.slice(0,b)));e=g}return e};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.g=this.c=this.a=null;return this};const w={icase:function(a){return a.toLowerCase()}};
return e}(!1),this);

30
dist/flexsearch.min.js vendored Normal file
View File

@@ -0,0 +1,30 @@
/*
FlexSearch v0.3.51
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(u,z,h){let v;(v=h.define)&&v.amd?v([],function(){return z}):(v=h.modules)?v[u.toLowerCase()]=z:"object"===typeof exports?module.exports=z:h[u]=z})("FlexSearch",function P(u){function h(b){D(b)&&(b=J[b]);b||(b=w);this.id=b.id||Q++;this.init(b);A(this,"index",function(){return this.a});A(this,"length",function(){return Object.keys(this.a).length})}function v(b,a,c,d){this.m!==this.c&&(this.g=this.g.concat(c),this.m++,d&&this.g.length>=d&&(this.m=this.c),this.A&&this.m===this.c&&
(this.cache&&this.j.set(a,this.g),this.A(this.g),this.g=[]));return this}function A(b,a,c){Object.defineProperty(b,a,{get:c})}function f(b){return new RegExp(b,"g")}function m(b,a){for(let c=0;c<a.length;c+=2)b=b.replace(a[c],a[c+1]);return b}function C(b,a,c,d,e,l,g){if(a[c])return a[c];e=e?(9-(g||6))*l+(g||6)*e:l;a[c]=e;e>=g&&(b=b[9-(e+.5>>0)],b=b[c]||(b[c]=[]),b[b.length]=d);return e}function H(b,a){if(b){const c=Object.keys(b);for(let d=0,e=c.length;d<e;d++){const e=c[d],g=b[e];if(g)for(let c=
0,d=g.length;c<d;c++)if(g[c]===a){1===d?delete b[e]:g.splice(c,1);break}else"object"===typeof g[c]&&H(g[c],a)}}}function I(b){let a="",c="";var d="";for(let e=0;e<b.length;e++){const l=b[e];if(l!==c)if(e&&"h"===l){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)a+=l}else a+=l;d=e===b.length-1?"":b[e+1];c=l}return a}function R(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function S(b,a){b=b.length-a.length;return 0>b?-1:b?
1:0}function T(b,a,c){let d=[],e;const l=b.length;if(1<l){b.sort(S);const f=r();let h=b[0],n=h.length,k=0;for(;k<n;)f["@"+h[k++]]=1;let y,q=0,t=0;for(;++t<l;){let K=!1;const p=t===l-1;e=[];h=b[t];n=h.length;for(k=0;k<n;){y=h[k++];var g="@"+y;if(f[g]){const b=f[g];if(b===t){if(p){if(d[q++]=y,a&&q===a)return d}else f[g]=t+1;K=!0}else c&&(g=e[b]||(e[b]=[]),g[g.length]=y)}}if(!K&&!c)break}if(c&&(q=d.length,(t=e.length)&&(!a||q<a)))for(;t--;)if(y=e[t])for(k=0,n=y.length;k<n;k++)if(d[q++]=y[k],a&&q===a)return d}else l&&
(d=b[0],a&&d.length>a&&(d=d.slice(0,a)));return d}function D(b){return"string"===typeof b}function F(b){return"function"===typeof b}function x(b){return"undefined"===typeof b}function L(b){const a=Array(b);for(let c=0;c<b;c++)a[c]=r();return a}function r(){return Object.create(null)}function U(){let b,a;self.onmessage=function(c){if(c=c.data)if(c.search){const d=a.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:b,content:c.content,limit:c.limit,result:d})}else c.add?
a.add(c.id,c.content):c.update?a.update(c.id,c.content):c.remove?a.remove(c.id):c.clear?a.clear():c.info?(c=a.info(),c.worker=b,console.log(c)):c.register&&(b=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,a=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),a=new a(c.options))}}function V(b,a,c,d){b=u("flexsearch","id"+b,U,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},a);const e=P.toString();c.id=a;b.postMessage({register:e,
options:c,id:a});return b}const w={encode:"icase",b:"forward",u:!1,cache:!1,async:!1,c:!1,threshold:0,depth:0},J={memory:{encode:"extra",b:"strict",threshold:7},speed:{encode:"icase",b:"strict",threshold:7,depth:2},match:{encode:"extra",b:"full"},score:{encode:"extra",b:"strict",threshold:5,depth:4},balance:{encode:"balance",b:"strict",threshold:6,depth:3},fastest:{encode:"icase",b:"strict",threshold:9,depth:1}},G=[];let Q=0;const M=f("\\W+"),N={},O={};h.create=function(b){return new h(b)};h.registerMatcher=
function(b){for(const a in b)b.hasOwnProperty(a)&&G.push(f(a),b[a]);return this};h.registerEncoder=function(b,a){B[b]=a.bind(B);return this};h.registerLanguage=function(b,a){N[b]=a.filter;O[b]=a.stemmer;return this};h.encode=function(b,a){return B[b](a)};h.prototype.init=function(b){this.o=[];b||(b=w);var a=b.preset,c=a?J[a]:{};if(a=b.worker)if("undefined"===typeof Worker)b.worker=!1,this.i=null;else{var d=parseInt(a,10)||4;this.w=-1;this.m=0;this.g=[];this.A=null;this.i=Array(d);for(var e=0;e<d;e++)this.i[e]=
V(this.id,e,b,v.bind(this))}this.b=b.tokenize||c.b||this.b||w.b;this.async="undefined"===typeof Promise||x(a=b.async)?this.async||w.async:a;this.c=x(a=b.worker)?this.c||w.c:a;this.threshold=x(a=b.threshold)?c.threshold||this.threshold||w.threshold:a;this.depth=x(a=b.depth)?c.depth||this.depth||w.depth:a;this.u=x(a=b.suggest)?this.u||w.u:a;this.s=(a=x(a=b.encode)?c.encode:a)&&B[a]&&B[a].bind(B)||(F(a)?a:this.s||!1);(a=b.matcher)&&this.addMatcher(a);if(a=b.filter){a=N[a]||a;c=this.s;d=r();if(a)for(e=
0;e<a.length;e++){var l=c?c(a[e]):a[e];d[l]=String.fromCharCode(65E3-a.length+e)}this.filter=a=d}if(a=b.stemmer){var g;c=O[a]||a;d=this.s;e=[];if(c)for(g in c)c.hasOwnProperty(g)&&(l=d?d(g):g,e.push(f("(?=.{"+(l.length+3)+",})"+l+"$"),d?d(c[g]):c[g]));this.stemmer=g=e}this.f=L(10-(this.threshold||0));this.h=r();this.a=r();this.v=!0;this.j=(this.cache=a=x(a=b.cache)?this.cache||w.cache:a)?new W(a):!1;return this};h.prototype.encode=function(b){b&&G.length&&(b=m(b,G));b&&this.o.length&&(b=m(b,this.o));
b&&this.s&&(b=this.s(b));b&&this.stemmer&&(b=m(b,this.stemmer));return b};h.prototype.addMatcher=function(b){const a=this.o;for(const c in b)b.hasOwnProperty(c)&&a.push(f(c),b[c]);return this};h.prototype.add=function(b,a,c,d,e){if(a&&D(a)&&(b||0===b)){var f="@"+b;if(this.a[f]&&!d)return this.update(b,a);if(this.c)return++this.w>=this.i.length&&(this.w=0),this.i[this.w].postMessage({add:!0,id:b,content:a}),this.a[f]=""+this.w,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=
this;f=new Promise(function(c){setTimeout(function(){e.add(b,a,null,d,!0);e=null;c()})});if(c)f.then(c);else return f;return this}if(c)return this.add(b,a,null,d,!0),c(),this}a=this.encode(a);if(!a.length)return this;c=this.b;e=F(c)?c(a):a.split(M);const l=r();l._ctx=r();const q=this.threshold,t=this.depth,E=this.f,m=e.length;for(let a=0;a<m;a++){var g=e[a];if(g){var h=g.length,p=(m-a)/m,n="";switch(c){case "reverse":case "both":for(var k=h-1;1<=k;k--)n=g[k]+n,C(E,l,n,b,(h-k)/h,p,q);n="";case "forward":for(k=
0;k<h;k++)n+=g[k],C(E,l,n,b,1,p,q);break;case "full":for(k=0;k<h;k++){const a=(h-k)/h;for(let c=h;c>k;c--)n=g.substring(k,c),C(E,l,n,b,a,p,q)}break;default:if(h=C(E,l,g,b,1,p,q),t&&1<m&&h>=q)for(h=l._ctx[g]||(l._ctx[g]=r()),g=this.h[g]||(this.h[g]=L(10-(q||0))),p=a-t,n=a+t+1,0>p&&(p=0),n>m&&(n=m);p<n;p++)p!==a&&C(g,h,e[p],b,0,10-(p<a?a-p:p-a),q)}}}this.a[f]=1;this.v=!1}return this};h.prototype.update=function(b,a,c){this.a["@"+b]&&D(a)&&(this.remove(b),this.add(b,a,c,!0));return this};h.prototype.remove=
function(b,a,c){var d="@"+b;if(this.a[d]){if(this.c)return this.i[this.a[d]].postMessage({remove:!0,id:b}),delete this.a[d],a&&a(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(a){setTimeout(function(){c.remove(b,null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<10-(this.threshold||0);a++)H(this.f[a],b);this.depth&&H(this.h,b);delete this.a[d];this.v=!1}return this};h.prototype.search=
function(b,a,c,d){let e=b,f;var g=[];"object"===typeof b&&((c=b.callback||a)&&(e.callback=null),a=b.limit,f=b.threshold,b=b.query);f||(f=this.threshold||0);F(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(this.c)for(this.A=c,this.m=0,this.g=[],g=0;g<this.c;g++)this.i[g].postMessage({search:!0,limit:a,threshold:f,content:b});else{if(!d){if(this.async&&"function"!==typeof importScripts){let d=this;b=new Promise(function(b){setTimeout(function(){b(d.search(e,a,null,!0));d=null})});if(c)b.then(c);else return b;
return this}if(c)return c(this.search(e,a,null,!0)),this}if(!b||!D(b))return g;e=b;if(this.cache)if(this.v){if(c=this.j.get(b))return c}else this.j.clear(),this.v=!0;e=this.encode(e);if(!e.length)return g;c=this.b;c=F(c)?c(e):e.split(M);d=c.length;var h=!0,p=[],n=r();if(1<d)if(this.depth){var k=!0;var m=c[0];n[m]=1}else c.sort(R);var q;if(!k||(q=this.h)[m])for(let a=k?1:0;a<d;a++){const b=c[a];if(b){if(!n[b]){const a=[];let c=!1,d=0;if(m=k?q[m]:this.f){let e;for(let g=0;g<10-f;g++)if(e=m[g][b])a[d++]=
e,c=!0}if(c)p[p.length]=1<d?a.concat.apply([],a):a[0];else if(!this.u){h=!1;break}n[b]=1}m=b}}else h=!1;h&&(g=T(p,a,this.u));this.cache&&this.j.set(b,g);return g}};h.prototype.info=function(){if(this.c)for(var b=0;b<this.c;b++)this.i[b].postMessage({info:!0,id:this.id});else{var a=0,c=0,d=0;for(var e=0;e<10-(this.threshold||0);e++){b=Object.keys(this.f[e]);for(let g=0;g<b.length;g++){var f=this.f[e][b[g]].length;a+=1*f+2*b[g].length+4;c+=f;d+=2*b[g].length}}b=Object.keys(this.a);f=b.length;for(e=
0;e<f;e++)a+=2*b[e].length+2;return{id:this.id,memory:a,items:f,sequences:c,chars:d,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:G.length+(this.o?this.o.length:0),worker:this.c,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.b}}};h.prototype.clear=function(){return this.destroy().init()};h.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.f=this.h=this.a=null;return this};h.prototype.export=function(){return JSON.stringify([this.f,
this.h,this.a])};h.prototype.import=function(b){b=JSON.parse(b);this.f=b[0];this.h=b[1];this.a=b[2]};const B={icase:function(b){return b.toLowerCase()},simple:function(){const b=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),
"",f("\\s+")," "];return function(a){a=m(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=m(a,b));c||1<a.length&&(a=I(a));return a}}(),extra:function(){const b=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),
"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(let c=0;c<a.length;c++){const d=a[c];1<d.length&&(a[c]=d[0]+m(d.substring(1),b))}a=a.join(" ");a=I(a)}return a}}(),balance:function(){const b=[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(a){return I(m(a.toLowerCase(),b))}}()},W=function(){function b(a){this.clear();this.B=!0!==a&&a}b.prototype.clear=function(){this.cache=r();this.count=r();this.index=
r();this.l=[]};b.prototype.set=function(a,b){if(this.B&&x(this.cache[a])){let c=this.l.length;if(c===this.B){c--;const a=this.l[c];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=c;this.l[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};b.prototype.get=function(a){const b=this.cache[a];if(this.B&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.l;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=
f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return b}();return h}(function(){const u={},z="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(h,v,A,f,m){A=z?URL.createObjectURL(new Blob(["("+A.toString()+")()"],{type:"text/javascript"})):h+".min.js";h+="-"+v;u[h]||(u[h]=[]);u[h][m]=new Worker(A);u[h][m].onmessage=f;return u[h][m]}}()),this);

26
dist/flexsearch.node.js vendored Normal file
View File

@@ -0,0 +1,26 @@
/*
FlexSearch v0.3.51
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(g,x,d){let m;(m=d.define)&&m.amd?m([],function(){return x}):(m=d.modules)?m[g.toLowerCase()]=x:"object"===typeof exports?module.exports=x:d[g]=x})("FlexSearch",function(){function g(b){B(b)&&(b=G[b]);b||(b=w);this.id=b.id||L++;this.init(b);x(this,"index",function(){return this.b});x(this,"length",function(){return Object.keys(this.b).length})}function x(b,a,c){Object.defineProperty(b,a,{get:c})}function d(b){return new RegExp(b,"g")}function m(b,a){for(let c=0;c<a.length;c+=
2)b=b.replace(a[c],a[c+1]);return b}function A(b,a,c,f,e,d,h){if(a[c])return a[c];e=e?(9-(h||6))*d+(h||6)*e:d;a[c]=e;e>=h&&(b=b[9-(e+.5>>0)],b=b[c]||(b[c]=[]),b[b.length]=f);return e}function E(b,a){if(b){const c=Object.keys(b);for(let f=0,e=c.length;f<e;f++){const e=c[f],h=b[e];if(h)for(let c=0,f=h.length;c<f;c++)if(h[c]===a){1===f?delete b[e]:h.splice(c,1);break}else"object"===typeof h[c]&&E(h[c],a)}}}function F(b){let a="",c="";var f="";for(let e=0;e<b.length;e++){const d=b[e];if(d!==c)if(e&&"h"===
d){if(f="a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&f||" "===c)a+=d}else a+=d;f=e===b.length-1?"":b[e+1];c=d}return a}function M(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function N(b,a){b=b.length-a.length;return 0>b?-1:b?1:0}function O(b,a,c){let f=[],e;const d=b.length;if(1<d){b.sort(N);const n=t();let l=b[0],g=l.length,k=0;for(;k<g;)n["@"+l[k++]]=1;let r,p=0,u=0;for(;++u<d;){let v=!1;const q=u===d-1;e=[];l=b[u];g=l.length;for(k=
0;k<g;){r=l[k++];var h="@"+r;if(n[h]){const b=n[h];if(b===u){if(q){if(f[p++]=r,a&&p===a)return f}else n[h]=u+1;v=!0}else c&&(h=e[b]||(e[b]=[]),h[h.length]=r)}}if(!v&&!c)break}if(c&&(p=f.length,(u=e.length)&&(!a||p<a)))for(;u--;)if(r=e[u])for(k=0,g=r.length;k<g;k++)if(f[p++]=r[k],a&&p===a)return f}else d&&(f=b[0],a&&f.length>a&&(f=f.slice(0,a)));return f}function B(b){return"string"===typeof b}function C(b){return"function"===typeof b}function y(b){return"undefined"===typeof b}function H(b){const a=
Array(b);for(let c=0;c<b;c++)a[c]=t();return a}function t(){return Object.create(null)}const w={encode:"icase",a:"forward",l:!1,cache:!1,async:!1,s:!1,threshold:0,depth:0},G={memory:{encode:"extra",a:"strict",threshold:7},speed:{encode:"icase",a:"strict",threshold:7,depth:2},match:{encode:"extra",a:"full"},score:{encode:"extra",a:"strict",threshold:5,depth:4},balance:{encode:"balance",a:"strict",threshold:6,depth:3},fastest:{encode:"icase",a:"strict",threshold:9,depth:1}},D=[];let L=0;const I=d("\\W+"),
J={},K={};g.create=function(b){return new g(b)};g.registerMatcher=function(b){for(const a in b)b.hasOwnProperty(a)&&D.push(d(a),b[a]);return this};g.registerEncoder=function(b,a){z[b]=a.bind(z);return this};g.registerLanguage=function(b,a){J[b]=a.filter;K[b]=a.stemmer;return this};g.encode=function(b,a){return z[b](a)};g.prototype.init=function(b){this.i=[];b||(b=w);var a=b.preset,c=a?G[a]:{};this.a=b.tokenize||c.a||this.a||w.a;this.async="undefined"===typeof Promise||y(a=b.async)?this.async||w.async:
a;this.threshold=y(a=b.threshold)?c.threshold||this.threshold||w.threshold:a;this.depth=y(a=b.depth)?c.depth||this.depth||w.depth:a;this.l=y(a=b.suggest)?this.l||w.l:a;this.j=(a=y(a=b.encode)?c.encode:a)&&z[a]&&z[a].bind(z)||(C(a)?a:this.j||!1);(a=b.matcher)&&this.addMatcher(a);if(a=b.filter){a=J[a]||a;c=this.j;var f=t();if(a)for(var e=0;e<a.length;e++){var n=c?c(a[e]):a[e];f[n]=String.fromCharCode(65E3-a.length+e)}this.filter=a=f}if(a=b.stemmer){var h;c=K[a]||a;f=this.j;e=[];if(c)for(h in c)c.hasOwnProperty(h)&&
(n=f?f(h):h,e.push(d("(?=.{"+(n.length+3)+",})"+n+"$"),f?f(c[h]):c[h]));this.stemmer=h=e}this.c=H(10-(this.threshold||0));this.f=t();this.b=t();this.m=!0;this.h=(this.cache=a=y(a=b.cache)?this.cache||w.cache:a)?new P(a):!1;return this};g.prototype.encode=function(b){b&&D.length&&(b=m(b,D));b&&this.i.length&&(b=m(b,this.i));b&&this.j&&(b=this.j(b));b&&this.stemmer&&(b=m(b,this.stemmer));return b};g.prototype.addMatcher=function(b){const a=this.i;for(const c in b)b.hasOwnProperty(c)&&a.push(d(c),b[c]);
return this};g.prototype.add=function(b,a,c,f,e){if(a&&B(a)&&(b||0===b)){var d="@"+b;if(this.b[d]&&!f)return this.update(b,a);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;d=new Promise(function(c){setTimeout(function(){e.add(b,a,null,f,!0);e=null;c()})});if(c)d.then(c);else return d;return this}if(c)return this.add(b,a,null,f,!0),c(),this}a=this.encode(a);if(!a.length)return this;c=this.a;e=C(c)?c(a):a.split(I);const n=t();n._ctx=t();const p=this.threshold,u=this.depth,m=this.c,
v=e.length;for(let a=0;a<v;a++){var h=e[a];if(h){var g=h.length,l=(v-a)/v,q="";switch(c){case "reverse":case "both":for(var k=g-1;1<=k;k--)q=h[k]+q,A(m,n,q,b,(g-k)/g,l,p);q="";case "forward":for(k=0;k<g;k++)q+=h[k],A(m,n,q,b,1,l,p);break;case "full":for(k=0;k<g;k++){const a=(g-k)/g;for(let c=g;c>k;c--)q=h.substring(k,c),A(m,n,q,b,a,l,p)}break;default:if(g=A(m,n,h,b,1,l,p),u&&1<v&&g>=p)for(g=n._ctx[h]||(n._ctx[h]=t()),h=this.f[h]||(this.f[h]=H(10-(p||0))),l=a-u,q=a+u+1,0>l&&(l=0),q>v&&(q=v);l<q;l++)l!==
a&&A(h,g,e[l],b,0,10-(l<a?a-l:l-a),p)}}}this.b[d]=1;this.m=!1}return this};g.prototype.update=function(b,a,c){this.b["@"+b]&&B(a)&&(this.remove(b),this.add(b,a,c,!0));return this};g.prototype.remove=function(b,a,c){var f="@"+b;if(this.b[f]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;f=new Promise(function(a){setTimeout(function(){c.remove(b,null,!0);c=null;a()})});if(a)f.then(a);else return f;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<10-(this.threshold||
0);a++)E(this.c[a],b);this.depth&&E(this.f,b);delete this.b[f];this.m=!1}return this};g.prototype.search=function(b,a,c,f){let e=b,d,h=[];"object"===typeof b&&((c=b.callback||a)&&(e.callback=null),a=b.limit,d=b.threshold,b=b.query);d||(d=this.threshold||0);C(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(!f){if(this.async&&"function"!==typeof importScripts){let d=this;b=new Promise(function(b){setTimeout(function(){b(d.search(e,a,null,!0));d=null})});if(c)b.then(c);else return b;return this}if(c)return c(this.search(e,
a,null,!0)),this}if(!b||!B(b))return h;e=b;if(this.cache)if(this.m){if(c=this.h.get(b))return c}else this.h.clear(),this.m=!0;e=this.encode(e);if(!e.length)return h;c=this.a;c=C(c)?c(e):e.split(I);f=c.length;let g=!0;const l=[],m=t();let k;if(1<f)if(this.depth){k=!0;var r=c[0];m[r]=1}else c.sort(M);let p;if(!k||(p=this.f)[r])for(let a=k?1:0;a<f;a++){const b=c[a];if(b){if(!m[b]){const a=[];let c=!1,f=0;if(r=k?p[r]:this.c){let e;for(let h=0;h<10-d;h++)if(e=r[h][b])a[f++]=e,c=!0}if(c)l[l.length]=1<f?
a.concat.apply([],a):a[0];else if(!this.l){g=!1;break}m[b]=1}r=b}}else g=!1;g&&(h=O(l,a,this.l));this.cache&&this.h.set(b,h);return h};g.prototype.info=function(){let b;let a=0,c=0,d=0;for(var e=0;e<10-(this.threshold||0);e++){b=Object.keys(this.c[e]);for(let f=0;f<b.length;f++){var g=this.c[e][b[f]].length;a+=1*g+2*b[f].length+4;c+=g;d+=2*b[f].length}}b=Object.keys(this.b);g=b.length;for(e=0;e<g;e++)a+=2*b[e].length+2;return{id:this.id,memory:a,items:g,sequences:c,chars:d,cache:this.cache&&this.cache.g?
this.cache.g.length:!1,matcher:D.length+(this.i?this.i.length:0),worker:this.s,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.a}};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=function(){this.cache&&(this.h.clear(),this.h=null);this.c=this.f=this.b=null;return this};g.prototype.export=function(){return JSON.stringify([this.c,this.f,this.b])};g.prototype.import=function(b){b=JSON.parse(b);this.c=b[0];this.f=b[1];this.b=b[2]};const z=
{icase:function(b){return b.toLowerCase()},simple:function(){const b=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(a){a=m(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=
[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=m(a,b));c||1<a.length&&(a=F(a));return a}}(),extra:function(){const b=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=
a.split(" ");for(let c=0;c<a.length;c++){const d=a[c];1<d.length&&(a[c]=d[0]+m(d.substring(1),b))}a=a.join(" ");a=F(a)}return a}}(),balance:function(){const b=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(a){return F(m(a.toLowerCase(),b))}}()},P=function(){function b(a){this.clear();this.o=!0!==a&&a}b.prototype.clear=function(){this.cache=t();this.count=t();this.index=t();this.g=[]};b.prototype.set=function(a,b){if(this.o&&y(this.cache[a])){let c=this.g.length;if(c===this.o){c--;
const a=this.g[c];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=c;this.g[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};b.prototype.get=function(a){const b=this.cache[a];if(this.o&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.g;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return b}();return g}(!1),this);

View File

@@ -1,23 +0,0 @@
/*
FlexSearch v0.3.5
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(f,r,d){let h;(h=d.define)&&h.amd?h([],function(){return r}):(h=d.modules)?h[f.toLowerCase()]=r:"object"===typeof exports?module.exports=r:d[f]=r})("FlexSearch",function(){function f(a){z(a)&&(a=F[a]);a||(a=v);this.id=a.id||L++;this.init(a);r(this,"index",function(){return this.b});r(this,"length",function(){return Object.keys(this.b).length})}function r(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function h(a,b){for(let c=0;c<b.length;c+=
2)a=a.replace(b[c],b[c+1]);return a}function y(a,b,c,g,e,d,m){if(b[c])return b[c];e=e?(9-(m||6))*d+(m||6)*e:d;b[c]=e;e>=m&&(a=a[9-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=g);return e}function C(a,b){if(a){const c=Object.keys(a);for(let g=0,d=c.length;g<d;g++){const d=c[g],e=a[d];if(e)for(let c=0,g=e.length;c<g;c++)if(e[c]===b){1===g?delete a[d]:e.splice(c,1);break}else"object"===typeof e[c]&&C(e[c],b)}}}function D(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const g=a[e];if(g!==c)if(e&&"h"===
g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=g}else b+=g;d=e===a.length-1?"":a[e+1];c=g}return b}function M(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function N(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function O(a,b,c){let d=[],e;const u=a.length;if(1<u){a.sort(N);const g=t();let l=a[0],n=l.length,k=0;for(;k<n;)g["@"+l[k++]]=1;let f,p=0,q=0;for(;++q<u;){let G=!1;const h=q===u-1;e=[];l=a[q];n=l.length;for(k=
0;k<n;){f=l[k++];var m="@"+f;if(g[m]){const a=g[m];if(a===q){if(h){if(d[p++]=f,b&&p===b)return d}else g[m]=q+1;G=!0}else c&&(m=e[a]||(e[a]=[]),m[m.length]=f)}}if(!G&&!c)break}if(c&&(p=d.length,(q=e.length)&&(!b||p<b)))for(;q--;)if(f=e[q])for(let a=0,c=f.length;a<c;a++)if(d[p++]=f[a],b&&p===b)return d}else u&&(d=a[0],b&&d.length>b&&(d=d.slice(0,b)));return d}function z(a){return"string"===typeof a}function A(a){return"function"===typeof a}function B(a){return"undefined"===typeof a}function H(a){const b=
Array(a);for(let c=0;c<a;c++)b[c]=t();return b}function t(){return Object.create(null)}const v={encode:"icase",a:"forward",i:!1,cache:!1,async:!1,j:!1,threshold:0,depth:0},F={memory:{encode:"extra",a:"strict",threshold:7},speed:{encode:"icase",a:"strict",threshold:7,depth:2},match:{encode:"extra",a:"full"},score:{encode:"extra",a:"strict",threshold:5,depth:4},balance:{encode:"balance",a:"strict",threshold:6,depth:3},fastest:{encode:"icase",a:"strict",threshold:9,depth:1}},E=[];let L=0;const I=d("\\W+"),
J={},K={};(function(){const a=Object.getOwnPropertyNames({}.__proto__),b=t();for(let c=0;c<a.length;c++)b[a[c]]=1;return b})();f.create=function(a){return new f(a)};f.registerMatcher=function(a){for(let b in a)a.hasOwnProperty(b)&&E.push(d(b),a[b]);return this};f.registerEncoder=function(a,b){x[a]=b.bind(x);return this};f.registerLanguage=function(a,b){J[a]=b.filter;K[a]=b.stemmer;return this};f.encode=function(a,b){return x[a](b)};f.prototype.init=function(a){this.h=[];a||(a=v);var b=a.profile,c=
b?F[b]:{};this.a=a.tokenize||c.a||this.a||v.a;this.async="undefined"===typeof Promise||B(b=a.async)?this.async||v.async:b;this.threshold=B(b=a.threshold)?c.threshold||this.threshold||v.threshold:b;this.depth=B(b=a.depth)?c.depth||this.depth||v.depth:b;this.f=(b=B(b=a.encode)?c.encode:b)&&x[b]&&x[b].bind(x)||(A(b)?b:this.f||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){b=J[b]||b;c=this.f;var g=t();if(b)for(let a=0;a<b.length;a++){const d=c?c(b[a]):b[a];g[d]=String.fromCharCode(65E3-b.length+
a)}this.filter=b=g}if(b=a.stemmer){var e;a=K[b]||b;b=this.f;c=[];if(a)for(e in a)a.hasOwnProperty(e)&&(g=b?b(e):e,c.push(d("(?=.{"+(g.length+3)+",})"+g+"$"),b?b(a[e]):a[e]));this.stemmer=e=c}this.g=H(10-(this.threshold||0));this.c=t();this.b=t();return this};f.prototype.encode=function(a){a&&E.length&&(a=h(a,E));a&&this.h.length&&(a=h(a,this.h));a&&this.f&&(a=this.f(a));a&&this.stemmer&&(a=h(a,this.stemmer));return a};f.prototype.addMatcher=function(a){const b=this.h;for(const c in a)a.hasOwnProperty(c)&&
b.push(d(c),a[c]);return this};f.prototype.add=function(a,b,c,d,e){if(b&&z(b)&&(a||0===a)){var g="@"+a;if(this.b[g]&&!d)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.a;e=A(c)?c(b):b.split(I);const h=t();h._ctx=t();const p=this.threshold,
q=this.depth,u=this.g,w=e.length;for(let b=0;b<w;b++){var m=e[b];if(m){var f=m.length,l=(w-b)/w,n="";switch(c){case "reverse":case "both":for(var k=f-1;1<=k;k--)n=m[k]+n,y(u,h,n,a,(f-k)/f,l,p);n="";case "forward":for(k=0;k<f;k++)n+=m[k],y(u,h,n,a,1,l,p);break;case "full":for(k=0;k<f;k++){const b=(f-k)/f;for(let c=f;c>k;c--)n=m.substring(k,c),y(u,h,n,a,b,l,p)}break;default:if(f=y(u,h,m,a,1,l,p),q&&1<w&&f>=p)for(f=h._ctx[m]||(h._ctx[m]=t()),m=this.c[m]||(this.c[m]=H(10-(p||0))),l=b-q,n=b+q+1,0>l&&(l=
0),n>w&&(n=w);l<n;l++)l!==b&&y(m,f,e[l],a,0,10-(l<b?b-l:l-b),p)}}}this.b[g]=1}return this};f.prototype.update=function(a,b,c){this.b["@"+a]&&z(b)&&(this.remove(a),this.add(a,b,c,!0));return this};f.prototype.remove=function(a,b,c){var d="@"+a;if(this.b[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<
10-(this.threshold||0);b++)C(this.g[b],a);this.depth&&C(this.c,a);delete this.b[d]}return this};f.prototype.search=function(a,b,c,d){let e=a;let f=[];if("object"===typeof a){(c=a.callback||b)&&(e.callback=null);b=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);A(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;g=new Promise(function(c){setTimeout(function(){c(a.search(e,b,null,!0));a=null})});if(c)g.then(c);else return g;return this}if(c)return c(this.search(e,
b,null,!0)),this}if(!a||!z(a))return f;e=a;e=this.encode(e);if(!e.length)return f;c=this.a;c=A(c)?c(e):e.split(I);a=c.length;d=!0;const h=[],l=t();let n;if(1<a)if(this.depth){n=!0;var k=c[0];l[k]=1}else c.sort(M);let r;if(!n||(r=this.c)[k])for(let b=n?1:0;b<a;b++){const a=c[b];if(a){if(!l[a]){const b=[];let c=!1,e=0;if(k=n?r[k]:this.g){let d;for(let f=0;f<10-g;f++)if(d=k[f][a])b[e++]=d,c=!0}if(c)h[h.length]=1<e?b.concat.apply([],b):b[0];else{d=!1;break}l[a]=1}k=a}}else d=!1;d&&(f=O(h,b,!1));return f};
f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.g=this.c=this.b=null;return this};const x={icase:function(a){return a.toLowerCase()},simple:function(){const a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & "),
" and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){b=h(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){const a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=h(b,a));c||1<b.length&&(b=D(b));return b}}(),extra:function(){const a=[d("p"),
"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+h(d.substring(1),a))}b=b.join(" ");b=D(b)}return b}}(),balance:function(){const a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){return D(h(b.toLowerCase(),a))}}()};return f}(!1),this);

View File

@@ -1,5 +1,5 @@
;/**!
* @preserve FlexSearch v0.3.5
/**!
* @preserve FlexSearch v0.3.51
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Released under the Apache 2.0 Licence
@@ -122,6 +122,8 @@
*/
/**
* NOTE: This could make issues on some languages (chinese, korean, thai)
* TODO: extract all language-specific stuff from the core
* @const {RegExp}
*/
@@ -130,22 +132,22 @@
const stemmer = {};
/**
*
* NOTE: Actually not really required when using bare objects: Object.create(null)
* @const {Object<string|number, number>}
*/
const index_blacklist = (function(){
const array = Object.getOwnPropertyNames(/** @type {!Array} */ (({}).__proto__));
const map = create_object();
for(let i = 0; i < array.length; i++){
map[array[i]] = 1;
}
return map;
})();
// const index_blacklist = (function(){
//
// const array = Object.getOwnPropertyNames(/** @type {!Array} */ (({}).__proto__));
// const map = create_object();
//
// for(let i = 0; i < array.length; i++){
//
// map[array[i]] = 1;
// }
//
// return map;
// }());
/**
* @param {string|Object<string, number|string|boolean|Object|function(string):string>=} options
@@ -213,7 +215,7 @@
FlexSearch.registerMatcher = function(matcher){
for(let key in matcher){
for(const key in matcher){
if(matcher.hasOwnProperty(key)){
@@ -279,6 +281,35 @@
// }
};
function worker_handler(id, query, result, limit){
if(this._task_completed !== this.worker){
this._task_result = this._task_result.concat(result);
this._task_completed++;
// TODO: sort results, return array of relevance [0...9] and apply in main thread
if(limit && (this._task_result.length >= limit)){
this._task_completed = this.worker;
}
if(this._current_callback && (this._task_completed === this.worker)){
if(this.cache){
this._cache.set(query, this._task_result);
}
this._current_callback(this._task_result);
this._task_result = [];
}
}
return this;
}
/**
* @param {Object<string, number|string|boolean|Object|function(string):string>=} options
* @export
@@ -291,10 +322,10 @@
options || (options = defaults);
let custom = /** @type {?string} */ (options["profile"]);
const profile = SUPPORT_PRESETS && custom ? presets[custom] : {};
let custom = /** @type {?string} */ (options["preset"]);
const preset = SUPPORT_PRESETS && custom ? presets[custom] : {};
if(DEBUG && !profile){
if(DEBUG && !preset){
console.warn("Preset not found: " + custom);
}
@@ -303,66 +334,36 @@
if(SUPPORT_WORKER && (custom = options["worker"])){
if(typeof Worker !== "undefined"){
const self = this;
const threads = parseInt(custom, 10) || 4;
/** @private */
self._current_task = -1;
/** @private */
self._task_completed = 0;
/** @private */
self._task_result = [];
/** @private */
self._current_callback = null;
//self._ids_count = new Array(threads);
/** @private */
self._worker = new Array(threads);
for(let i = 0; i < threads; i++){
//self._ids_count[i] = 0;
self._worker[i] = addWorker(self.id, i, options /*|| defaults*/, function(id, query, result, limit){
if(self._task_completed === self.worker){
return;
}
self._task_result = self._task_result.concat(result);
self._task_completed++;
// TODO: sort results, return array of relevance [0...9] and apply in main thread
if(limit && (self._task_result.length >= limit)){
self._task_completed = self.worker;
}
if(self._current_callback && (self._task_completed === self.worker)){
if(self.cache){
self._cache.set(query, self._task_result);
}
self._current_callback(self._task_result);
self._task_result = [];
}
return self;
});
}
}
else{
if(typeof Worker === "undefined"){
options["worker"] = false;
/** @private */
this._worker = null;
}
else{
const threads = parseInt(custom, 10) || 4;
/** @private */
this._current_task = -1;
/** @private */
this._task_completed = 0;
/** @private */
this._task_result = [];
/** @private */
this._current_callback = null;
//this._ids_count = new Array(threads);
/** @private */
this._worker = new Array(threads);
for(let i = 0; i < threads; i++){
//this._ids_count[i] = 0;
this._worker[i] = addWorker(this.id, i, options /*|| defaults*/, worker_handler.bind(this));
}
}
}
// apply custom options
@@ -371,7 +372,7 @@
this.tokenize = (
options["tokenize"] ||
profile.tokenize ||
preset.tokenize ||
this.tokenize ||
defaults.tokenize
);
@@ -401,7 +402,7 @@
is_undefined(custom = options["threshold"]) ?
profile.threshold ||
preset.threshold ||
this.threshold ||
defaults.threshold
:
@@ -413,7 +414,7 @@
is_undefined(custom = options["depth"]) ?
profile.depth ||
preset.depth ||
this.depth ||
defaults.depth
:
@@ -436,7 +437,7 @@
custom = is_undefined(custom = options["encode"]) ?
profile.encode
preset.encode
:
custom;
@@ -685,7 +686,8 @@
return this;
}
else if(callback){
if(callback){
this.add(id, content, null, _skip_update, true);
callback();
@@ -974,7 +976,8 @@
return this;
}
else if(callback){
if(callback){
this.remove(id, null, true);
callback();
@@ -1113,7 +1116,8 @@
return this;
}
else if(callback){
if(callback){
callback(this.search(_query, limit, null, true));
@@ -1138,15 +1142,7 @@
// invalidate cache
if(!this._cache_status){
this._cache.clear();
this._cache_status = true;
}
// validate cache
else {
if(this._cache_status){
const cache = this._cache.get(query);
@@ -1155,6 +1151,14 @@
return cache;
}
}
// validate cache
else {
this._cache.clear();
this._cache_status = true;
}
}
// encode string
@@ -1263,13 +1267,10 @@
//check[check.length] = map_check;
}
else{
else if(!SUPPORT_SUGGESTIONS || !this.suggest){
if(!SUPPORT_SUGGESTIONS || !this.suggest){
found = false;
break;
}
found = false;
break;
}
check_words[value] = 1;
@@ -1452,8 +1453,8 @@
const regex_whitespace = regex("\\s+"),
regex_strip = regex("[^a-z0-9 ]"),
regex_space = regex("[-/]"),
regex_vowel = regex("[aeiouy]");
regex_space = regex("[-/]");
//regex_vowel = regex("[aeiouy]");
/** @const {Array} */
const regex_pairs = [
@@ -1471,7 +1472,7 @@
replace(value.toLowerCase(), regex_pairs)
);
};
})();
}());
/** @const */
@@ -1535,7 +1536,7 @@
return (
str !== " " ? str : ""
str === " " ? "" : str
);
};
}()),
@@ -1544,7 +1545,7 @@
"advanced": (function(){
const regex_space = regex(" "),
const //regex_space = regex(" "),
regex_ae = regex("ae"),
regex_ai = regex("ai"),
regex_ay = regex("ay"),
@@ -1600,7 +1601,7 @@
// normalize special pairs
if(string.length > 2){
string = replace(string, regex_pairs)
string = replace(string, regex_pairs);
}
if(!_skip_post_processing){
@@ -1618,7 +1619,7 @@
return string;
};
})(),
}()),
// phonetic transformation
@@ -1680,7 +1681,7 @@
return str;
};
})(),
}()),
"balance": global_encoder_balance
@@ -1712,14 +1713,14 @@
);
};
})() : null;
}()) : null;
*/
// Flexi-Cache
const Cache = SUPPORT_CACHE ? (function(){
function Cache(limit){
function CacheClass(limit){
this.clear();
@@ -1727,7 +1728,7 @@
this.limit = (limit !== true) && limit;
}
Cache.prototype.clear = function(){
CacheClass.prototype.clear = function(){
/** @private */
this.cache = create_object();
@@ -1739,7 +1740,7 @@
this.ids = [];
};
Cache.prototype.set = function(key, value){
CacheClass.prototype.set = function(key, value){
if(this.limit && is_undefined(this.cache[key])){
@@ -1775,7 +1776,7 @@
* Note: It is better to have the complexity when fetching the cache:
*/
Cache.prototype.get = function(key){
CacheClass.prototype.get = function(key){
const cache = this.cache[key];
@@ -1807,10 +1808,10 @@
// copy values from predecessors
for(let i = old_index; i > current_index; i--) {
const key = ids[i - 1];
const tmp = ids[i - 1];
ids[i] = key;
index[key] = i;
ids[i] = tmp;
index[tmp] = i;
}
// push new value on top
@@ -1823,9 +1824,9 @@
return cache;
};
return Cache;
return CacheClass;
})() : null;
}()) : null;
if(PROFILER){
@@ -1885,17 +1886,17 @@
/**
* @param {!string} str
* @param {RegExp|Array} regex
* @param {RegExp|Array} regexp
* @returns {string}
*/
function replace(str, regex/*, replacement*/){
function replace(str, regexp/*, replacement*/){
//if(is_undefined(replacement)){
for(let i = 0; i < /** @type {Array} */ (regex).length; i += 2){
for(let i = 0; i < /** @type {Array} */ (regexp).length; i += 2){
str = str.replace(regex[i], regex[i + 1]);
str = str.replace(regexp[i], regexp[i + 1]);
}
return str;
@@ -1929,29 +1930,27 @@
return dupes[value];
}
else{
const score = (
const score = (
partial_score ?
partial_score ?
((9 - (threshold || 6)) * context_score) + ((threshold || 6) * partial_score)
:
context_score
);
((9 - (threshold || 6)) * context_score) + ((threshold || 6) * partial_score)
:
context_score
);
dupes[value] = score;
dupes[value] = score;
if(score >= threshold){
if(score >= threshold){
let arr = map[9 - ((score + 0.5) >> 0)];
arr = arr[value] || (arr[value] = []);
let arr = map[9 - ((score + 0.5) >> 0)];
arr = arr[value] || (arr[value] = []);
arr[arr.length] = id;
}
return score;
arr[arr.length] = id;
}
return score;
}
/**
@@ -2179,20 +2178,20 @@
}
/**
* @param {Object<string, string>} stemmer
* @param {Object<string, string>} stem
* @param encoder
* @returns {Array}
*/
function init_stemmer(stemmer, encoder){
function init_stemmer(stem, encoder){
const final = [];
if(stemmer){
if(stem){
for(const key in stemmer){
for(const key in stem){
if(stemmer.hasOwnProperty(key)){
if(stem.hasOwnProperty(key)){
const tmp = encoder ? encoder(key) : key;
@@ -2202,9 +2201,9 @@
encoder ?
encoder(stemmer[key])
encoder(stem[key])
:
stemmer[key]
stem[key]
);
}
}
@@ -2377,7 +2376,7 @@
if(tmp){
for(let i = 0, len = tmp.length; i < len; i++){
for(i = 0, length = tmp.length; i < length; i++){
result[count++] = tmp[i];
@@ -2745,6 +2744,93 @@
return Object.create(null);
}
function worker_module(){
let id;
/** @type {FlexSearch} */
let FlexSearchWorker;
/** @lends {Worker} */
self.onmessage = function(event){
const data = event["data"];
if(data){
if(data["search"]){
const results = FlexSearchWorker["search"](data["content"],
data["threshold"] ?
{
"limit": data["limit"],
"threshold": data["threshold"]
}
:
data["limit"]
);
/** @lends {Worker} */
self.postMessage({
"id": id,
"content": data["content"],
"limit": data["limit"],
"result": results
});
}
else if(data["add"]){
FlexSearchWorker["add"](data["id"], data["content"]);
}
else if(data["update"]){
FlexSearchWorker["update"](data["id"], data["content"]);
}
else if(data["remove"]){
FlexSearchWorker["remove"](data["id"]);
}
else if(data["clear"]){
FlexSearchWorker["clear"]();
}
else if(SUPPORT_INFO && data["info"]){
const info = FlexSearchWorker["info"]();
info["worker"] = id;
console.log(info);
/** @lends {Worker} */
//self.postMessage(info);
}
else if(data["register"]){
id = data["id"];
data["options"]["cache"] = false;
data["options"]["async"] = false;
data["options"]["worker"] = false;
FlexSearchWorker = new Function(
data["register"].substring(
data["register"].indexOf("{") + 1,
data["register"].lastIndexOf("}")
)
)();
FlexSearchWorker = new FlexSearchWorker(data["options"]);
}
}
};
}
function addWorker(id, core, options, callback){
const thread = register_worker(
@@ -2756,92 +2842,7 @@
"id" + id,
// worker:
function(){
let id;
/** @type {FlexSearch} */
let FlexSearchWorker;
/** @lends {Worker} */
self.onmessage = function(event){
const data = event["data"];
if(data){
if(data["search"]){
const results = FlexSearchWorker["search"](data["content"],
data["threshold"] ?
{
"limit": data["limit"],
"threshold": data["threshold"]
}
:
data["limit"]
);
/** @lends {Worker} */
self.postMessage({
"id": id,
"content": data["content"],
"limit": data["limit"],
"result": results
});
}
else if(data["add"]){
FlexSearchWorker["add"](data["id"], data["content"]);
}
else if(data["update"]){
FlexSearchWorker["update"](data["id"], data["content"]);
}
else if(data["remove"]){
FlexSearchWorker["remove"](data["id"]);
}
else if(data["clear"]){
FlexSearchWorker["clear"]();
}
else if(SUPPORT_INFO && data["info"]){
const info = FlexSearchWorker["info"]();
info["worker"] = id;
console.log(info);
/** @lends {Worker} */
//self.postMessage(info);
}
else if(data["register"]){
id = data["id"];
data["options"]["cache"] = false;
data["options"]["async"] = false;
data["options"]["worker"] = false;
FlexSearchWorker = new Function(
data["register"].substring(
data["register"].indexOf("{") + 1,
data["register"].lastIndexOf("}")
)
)();
FlexSearchWorker = new FlexSearchWorker(data["options"]);
}
}
};
},
worker_module,
// callback:
function(event){

View File

@@ -1,18 +0,0 @@
/*
FlexSearch v0.3.5
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(e,u,v){let m;(m=v.define)&&m.amd?m([],function(){return u}):(m=v.modules)?m[e.toLowerCase()]=u:"object"===typeof exports?module.exports=u:v[e]=u})("FlexSearch",function(){function e(a){a||(a=x);this.id=a.id||G++;this.init(a);u(this,"index",function(){return this.a});u(this,"length",function(){return Object.keys(this.a).length})}function u(a,b,c){Object.defineProperty(a,b,{get:c})}function v(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function m(a,b,c,
f,d,n,g){if(b[c])return b[c];d=d?(9-(g||6))*n+(g||6)*d:n;b[c]=d;d>=g&&(a=a[9-(d+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=f);return d}function z(a,b){if(a){const c=Object.keys(a);for(let f=0,d=c.length;f<d;f++){const d=c[f],g=a[d];if(g)for(let c=0,f=g.length;c<f;c++)if(g[c]===b){1===f?delete a[d]:g.splice(c,1);break}else"object"===typeof g[c]&&z(g[c],b)}}}function H(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function I(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function y(a){return"function"===typeof a}
function A(a){return"undefined"===typeof a}function C(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=r();return b}function r(){return Object.create(null)}const x={encode:"icase",b:"forward",i:!1,cache:!1,async:!1,j:!1,threshold:0,depth:0},B=[];let G=0;const D=/\W+/g,E={},F={};(function(){const a=Object.getOwnPropertyNames({}.__proto__),b=r();for(let c=0;c<a.length;c++)b[a[c]]=1;return b})();e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(let b in a)a.hasOwnProperty(b)&&B.push(new RegExp(b,
"g"),a[b]);return this};e.registerEncoder=function(a,b){w[a]=b.bind(w);return this};e.registerLanguage=function(a,b){E[a]=b.filter;F[a]=b.stemmer;return this};e.encode=function(a,b){return w[a](b)};e.prototype.init=function(a){this.h=[];a||(a=x);var b=a.profile,c={};this.b=a.tokenize||c.b||this.b||x.b;this.threshold=A(b=a.threshold)?c.threshold||this.threshold||x.threshold:b;this.depth=A(b=a.depth)?c.depth||this.depth||x.depth:b;this.f=(b=A(b=a.encode)?c.encode:b)&&w[b]&&w[b].bind(w)||(y(b)?b:this.f||
!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){b=E[b]||b;c=this.f;var f=r();if(b)for(let a=0;a<b.length;a++){const d=c?c(b[a]):b[a];f[d]=String.fromCharCode(65E3-b.length+a)}this.filter=b=f}if(b=a.stemmer){var d;a=F[b]||b;b=this.f;c=[];if(a)for(d in a)a.hasOwnProperty(d)&&(f=b?b(d):d,c.push(new RegExp("(?=.{"+(f.length+3)+",})"+f+"$","g"),b?b(a[d]):a[d]));this.stemmer=d=c}this.g=C(10-(this.threshold||0));this.c=r();this.a=r();return this};e.prototype.encode=function(a){a&&B.length&&(a=v(a,B));
a&&this.h.length&&(a=v(a,this.h));a&&this.f&&(a=this.f(a));a&&this.stemmer&&(a=v(a,this.stemmer));return a};e.prototype.addMatcher=function(a){const b=this.h;for(const c in a)a.hasOwnProperty(c)&&b.push(new RegExp(c,"g"),a[c]);return this};e.prototype.add=function(a,b,c,f,d){if(b&&"string"===typeof b&&(a||0===a)){const e="@"+a;if(this.a[e]&&!f)return this.update(a,b);if(!d&&c)return this.add(a,b,null,f,!0),c(),this;b=this.encode(b);if(!b.length)return this;c=this.b;b=y(c)?c(b):b.split(D);f=r();f._ctx=
r();d=this.threshold;const t=this.depth,q=this.g,p=b.length;for(let e=0;e<p;e++){var n=b[e];if(n){var g=n.length,k=(p-e)/p,l="";switch(c){case "reverse":case "both":for(var h=g-1;1<=h;h--)l=n[h]+l,m(q,f,l,a,(g-h)/g,k,d);l="";case "forward":for(h=0;h<g;h++)l+=n[h],m(q,f,l,a,1,k,d);break;case "full":for(h=0;h<g;h++){const b=(g-h)/g;for(let c=g;c>h;c--)l=n.substring(h,c),m(q,f,l,a,b,k,d)}break;default:if(g=m(q,f,n,a,1,k,d),t&&1<p&&g>=d)for(g=f._ctx[n]||(f._ctx[n]=r()),n=this.c[n]||(this.c[n]=C(10-(d||
0))),k=e-t,l=e+t+1,0>k&&(k=0),l>p&&(l=p);k<l;k++)k!==e&&m(n,g,b[k],a,0,10-(k<e?e-k:k-e),d)}}}this.a[e]=1}return this};e.prototype.update=function(a,b,c){this.a["@"+a]&&"string"===typeof b&&(this.remove(a),this.add(a,b,c,!0));return this};e.prototype.remove=function(a,b,c){const f="@"+a;if(this.a[f]){if(!c&&b)return this.remove(a,null,!0),b(),this;for(b=0;b<10-(this.threshold||0);b++)z(this.g[b],a);this.depth&&z(this.c,a);delete this.a[f]}return this};e.prototype.search=function(a,b,c,f){var d=a,e=
[];if("object"===typeof a){b=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);y(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!f&&c)return c(this.search(d,b,null,!0)),this;if(!a||"string"!==typeof a)return e;d=this.encode(a);if(!d.length)return e;a=this.b;a=y(a)?a(d):d.split(D);c=a.length;f=!0;d=[];var k=r();if(1<c)if(this.depth){var l=!0;var h=a[0];k[h]=1}else a.sort(H);var m;if(!l||(m=this.c)[h])for(var t=l?1:0;t<c;t++){var q=a[t];if(q){if(!k[q]){var p=[];let a=!1,b=0;if(h=l?m[h]:this.g){let c;
for(let d=0;d<10-g;d++)if(c=h[d][q])p[b++]=c,a=!0}if(a)d[d.length]=1<b?p.concat.apply([],p):p[0];else{f=!1;break}k[q]=1}h=q}}else f=!1;if(f)a:{g=[];e=d.length;if(1<e){d.sort(I);l=r();m=d[0];h=m.length;for(a=0;a<h;)l["@"+m[a++]]=1;for(k=f=0;++k<e;){t=!1;q=k===e-1;m=d[k];h=m.length;for(a=0;a<h;)if(c=m[a++],p="@"+c,l[p]&&l[p]===k){if(q){if(g[f++]=c,b&&f===b){e=g;break a}}else l[p]=k+1;t=!0}if(!t)break}}else e&&(g=d[0],b&&g.length>b&&(g=g.slice(0,b)));e=g}return e};e.prototype.clear=function(){return this.destroy().init()};
e.prototype.destroy=function(){this.g=this.c=this.a=null;return this};const w={icase:function(a){return a.toLowerCase()}};return e}(!1),this);

31
flexsearch.min.js vendored
View File

@@ -1,31 +0,0 @@
/*
FlexSearch v0.3.5
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(u,B,g){let v;(v=g.define)&&v.amd?v([],function(){return B}):(v=g.modules)?v[u.toLowerCase()]=B:"object"===typeof exports?module.exports=B:g[u]=B})("FlexSearch",function O(u){function g(a){E(a)&&(a=J[a]);a||(a=w);this.id=a.id||P++;this.init(a);v(this,"index",function(){return this.a});v(this,"length",function(){return Object.keys(this.a).length})}function v(a,b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,"g")}function x(a,b){for(let c=0;c<b.length;c+=
2)a=a.replace(b[c],b[c+1]);return a}function y(a,b,c,d,f,l,h){if(b[c])return b[c];f=f?(9-(h||6))*l+(h||6)*f:l;b[c]=f;f>=h&&(a=a[9-(f+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return f}function H(a,b){if(a){const c=Object.keys(a);for(let d=0,f=c.length;d<f;d++){const f=c[d],h=a[f];if(h)for(let c=0,d=h.length;c<d;c++)if(h[c]===b){1===d?delete a[f]:h.splice(c,1);break}else"object"===typeof h[c]&&H(h[c],b)}}}function I(a){let b="",c="";var d="";for(let f=0;f<a.length;f++){const l=a[f];if(l!==c)if(f&&"h"===
l){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=l}else b+=l;d=f===a.length-1?"":a[f+1];c=l}return b}function Q(a,b){const c=r();if(a)for(let d=0;d<a.length;d++){const f=b?b(a[d]):a[d];c[f]=String.fromCharCode(65E3-a.length+d)}return c}function R(a,b){const c=[];if(a)for(const d in a)if(a.hasOwnProperty(d)){const f=b?b(d):d;c.push(e("(?=.{"+(f.length+3)+",})"+f+"$"),b?b(a[d]):a[d])}return c}function S(a,b){a=a.length-
b.length;return 0>a?1:a?-1:0}function T(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function U(a,b,c){let d=[],f;const l=a.length;if(1<l){a.sort(T);const z=r();let e=a[0],g=e.length,k=0;for(;k<g;)z["@"+e[k++]]=1;let q,p=0,t=0;for(;++t<l;){let m=!1;const n=t===l-1;f=[];e=a[t];g=e.length;for(k=0;k<g;){q=e[k++];var h="@"+q;if(z[h]){const a=z[h];if(a===t){if(n){if(d[p++]=q,b&&p===b)return d}else z[h]=t+1;m=!0}else c&&(h=f[a]||(f[a]=[]),h[h.length]=q)}}if(!m&&!c)break}if(c&&(p=d.length,(t=f.length)&&
(!b||p<b)))for(;t--;)if(q=f[t])for(let a=0,c=q.length;a<c;a++)if(d[p++]=q[a],b&&p===b)return d}else l&&(d=a[0],b&&d.length>b&&(d=d.slice(0,b)));return d}function E(a){return"string"===typeof a}function F(a){return"function"===typeof a}function A(a){return"undefined"===typeof a}function K(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=r();return b}function r(){return Object.create(null)}function V(a,b,c,d){a=u("flexsearch","id"+a,function(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=
b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}},function(a){(a=
a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);const f=O.toString();c.id=b;a.postMessage({register:f,options:c,id:b});return a}const w={encode:"icase",b:"forward",u:!1,cache:!1,async:!1,c:!1,threshold:0,depth:0},J={memory:{encode:"extra",b:"strict",threshold:7},speed:{encode:"icase",b:"strict",threshold:7,depth:2},match:{encode:"extra",b:"full"},score:{encode:"extra",b:"strict",threshold:5,depth:4},balance:{encode:"balance",b:"strict",threshold:6,depth:3},fastest:{encode:"icase",b:"strict",
threshold:9,depth:1}},G=[];let P=0;const L=e("\\W+"),M={},N={};(function(){const a=Object.getOwnPropertyNames({}.__proto__),b=r();for(let c=0;c<a.length;c++)b[a[c]]=1;return b})();g.create=function(a){return new g(a)};g.registerMatcher=function(a){for(let b in a)a.hasOwnProperty(b)&&G.push(e(b),a[b]);return this};g.registerEncoder=function(a,b){D[a]=b.bind(D);return this};g.registerLanguage=function(a,b){M[a]=b.filter;N[a]=b.stemmer;return this};g.encode=function(a,b){return D[a](b)};g.prototype.init=
function(a){this.m=[];a||(a=w);let b=a.profile;const c=b?J[b]:{};if(b=a.worker)if("undefined"!==typeof Worker){const c=this,f=parseInt(b,10)||4;c.w=-1;c.o=0;c.h=[];c.B=null;c.i=Array(f);for(let b=0;b<f;b++)c.i[b]=V(c.id,b,a,function(a,b,d,f){if(c.o!==c.c)return c.h=c.h.concat(d),c.o++,f&&c.h.length>=f&&(c.o=c.c),c.B&&c.o===c.c&&(c.cache&&c.j.set(b,c.h),c.B(c.h),c.h=[]),c})}else a.worker=!1,this.i=null;this.b=a.tokenize||c.b||this.b||w.b;this.async="undefined"===typeof Promise||A(b=a.async)?this.async||
w.async:b;this.c=A(b=a.worker)?this.c||w.c:b;this.threshold=A(b=a.threshold)?c.threshold||this.threshold||w.threshold:b;this.depth=A(b=a.depth)?c.depth||this.depth||w.depth:b;this.u=A(b=a.suggest)?this.u||w.u:b;this.s=(b=A(b=a.encode)?c.encode:b)&&D[b]&&D[b].bind(D)||(F(b)?b:this.s||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.filter=Q(M[b]||b,this.s);if(b=a.stemmer)this.stemmer=R(N[b]||b,this.s);this.f=K(10-(this.threshold||0));this.g=r();this.a=r();this.v=!0;this.j=(this.cache=b=A(b=
a.cache)?this.cache||w.cache:b)?new W(b):!1;return this};g.prototype.encode=function(a){a&&G.length&&(a=x(a,G));a&&this.m.length&&(a=x(a,this.m));a&&this.s&&(a=this.s(a));a&&this.stemmer&&(a=x(a,this.stemmer));return a};g.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};g.prototype.add=function(a,b,c,d,f){if(b&&E(b)&&(a||0===a)){var e="@"+a;if(this.a[e]&&!d)return this.update(a,b);if(this.c)return++this.w>=this.i.length&&(this.w=
0),this.i[this.w].postMessage({add:!0,id:a,content:b}),this.a[e]=""+this.w,c&&c(),this;if(!f){if(this.async&&"function"!==typeof importScripts){let f=this;e=new Promise(function(c){setTimeout(function(){f.add(a,b,null,d,!0);f=null;c()})});if(c)e.then(c);else return e;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.b;f=F(c)?c(b):b.split(L);const l=r();l._ctx=r();const p=this.threshold,t=this.depth,z=this.f,C=f.length;for(let b=0;b<C;b++){var h=
f[b];if(h){var g=h.length,m=(C-b)/C,n="";switch(c){case "reverse":case "both":for(var k=g-1;1<=k;k--)n=h[k]+n,y(z,l,n,a,(g-k)/g,m,p);n="";case "forward":for(k=0;k<g;k++)n+=h[k],y(z,l,n,a,1,m,p);break;case "full":for(k=0;k<g;k++){const b=(g-k)/g;for(let c=g;c>k;c--)n=h.substring(k,c),y(z,l,n,a,b,m,p)}break;default:if(g=y(z,l,h,a,1,m,p),t&&1<C&&g>=p)for(g=l._ctx[h]||(l._ctx[h]=r()),h=this.g[h]||(this.g[h]=K(10-(p||0))),m=b-t,n=b+t+1,0>m&&(m=0),n>C&&(n=C);m<n;m++)m!==b&&y(h,g,f[m],a,0,10-(m<b?b-m:m-
b),p)}}}this.a[e]=1;this.v=!1}return this};g.prototype.update=function(a,b,c){this.a["@"+a]&&E(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=function(a,b,c){var d="@"+a;if(this.a[d]){if(this.c)return this.i[this.a[d]].postMessage({remove:!0,id:a}),delete this.a[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,
null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)H(this.f[b],a);this.depth&&H(this.g,a);delete this.a[d];this.v=!1}return this};g.prototype.search=function(a,b,c,d){let f=a,e;var h=[];"object"===typeof a&&((c=a.callback||b)&&(f.callback=null),b=a.limit,e=a.threshold,a=a.query);e||(e=this.threshold||0);F(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.c)for(this.B=c,this.o=0,this.h=[],h=0;h<this.c;h++)this.i[h].postMessage({search:!0,limit:b,threshold:e,content:a});else{if(!d){if(this.async&&"function"!==
typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(f,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!E(a))return h;f=a;if(this.cache)if(this.v){if(c=this.j.get(a))return c}else this.j.clear(),this.v=!0;f=this.encode(f);if(!f.length)return h;c=this.b;c=F(c)?c(f):f.split(L);d=c.length;var g=!0,m=[],n=r();if(1<d)if(this.depth){var k=!0;var q=c[0];n[q]=1}else c.sort(S);var p;if(!k||(p=this.g)[q])for(let a=
k?1:0;a<d;a++){const b=c[a];if(b){if(!n[b]){const a=[];let c=!1,d=0;if(q=k?p[q]:this.f){let f;for(let h=0;h<10-e;h++)if(f=q[h][b])a[d++]=f,c=!0}if(c)m[m.length]=1<d?a.concat.apply([],a):a[0];else if(!this.u){g=!1;break}n[b]=1}q=b}}else g=!1;g&&(h=U(m,b,this.u));this.cache&&this.j.set(a,h);return h}};g.prototype.info=function(){if(this.c)for(var a=0;a<this.c;a++)this.i[a].postMessage({info:!0,id:this.id});else{var b=0,c=0,d=0;for(var f=0;f<10-(this.threshold||0);f++){a=Object.keys(this.f[f]);for(let h=
0;h<a.length;h++){var e=this.f[f][a[h]].length;b+=1*e+2*a[h].length+4;c+=e;d+=2*a[h].length}}a=Object.keys(this.a);e=a.length;for(f=0;f<e;f++)b+=2*a[f].length+2;return{id:this.id,memory:b,items:e,sequences:c,chars:d,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:G.length+(this.m?this.m.length:0),worker:this.c,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.b}}};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=function(){this.cache&&
(this.j.clear(),this.j=null);this.f=this.g=this.a=null;return this};g.prototype.export=function(){return JSON.stringify([this.f,this.g,this.a])};g.prototype.import=function(a){a=JSON.parse(a);this.f=a[0];this.g=a[1];this.a=a[2]};const D={icase:function(a){return a.toLowerCase()},simple:function(){const a=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),
"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=x(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){const a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);
2<b.length&&(b=x(b,a));c||1<b.length&&(b=I(b));return b}}(),extra:function(){const a=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+x(d.substring(1),a))}b=b.join(" ");b=I(b)}return b}}(),balance:function(){const a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return I(x(b.toLowerCase(),
a))}}()},W=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache=r();this.count=r();this.index=r();this.l=[]};a.prototype.set=function(a,c){if(this.A&&A(this.cache[a])){let b=this.l.length;if(b===this.A){b--;const a=this.l[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.l[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];
const b=this.index;let c=b[a];if(0<c){const e=this.l;for(var f=c;this.count[e[--c]]<=d&&-1!==c;);c++;if(c!==f){for(d=f;d>c;d--)f=e[d-1],e[d]=f,b[f]=d;e[c]=a;b[a]=c}}}return b};return a}();return g}(function(){const u={},B="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(g,v,e,x,y){e=B?URL.createObjectURL(new Blob(["("+e.toString()+")()"],{type:"text/javascript"})):g+".min.js";g+="-"+v;u[g]||(u[g]=[]);u[g][y]=new Worker(e);u[g][y].onmessage=x;return u[g][y]}}()),
this);

View File

@@ -1,6 +1,6 @@
{
"name": "flexsearch",
"version": "0.3.5",
"version": "0.3.51",
"description": "Next-Generation full text search library with zero dependencies.",
"homepage": "https://github.com/nextapps-de/flexsearch/",
"author": "Thomas Wilkerling",
@@ -17,7 +17,8 @@
"url": "https://github.com/nextapps-de/flexsearch/issues",
"email": "info@nextapps.de"
},
"main": "flexsearch.min.js",
"main": "dist/flexsearch.node.js",
"browser": "dist/flexsearch.min.js",
"preferGlobal": false,
"bin": {},
"repository": {
@@ -30,8 +31,9 @@
"build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
"build-node": "node compile RELEASE=node DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-lang": "node compile RELEASE=lang",
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-lang",
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-node && npm run build-lang",
"test-production": "nyc --reporter=html --reporter=text mocha --timeout=3000 test --exit",
"test-light": "nyc --reporter=html --reporter=text mocha --timeout=3000 test/ --exit",
"test-develop": "nyc --reporter=html --reporter=text mocha --timeout=3000 --exit",
@@ -42,6 +44,7 @@
},
"files": [
"flexsearch.js",
"dist/",
"lang/",
"test/",
"compile.js",

View File

@@ -22,7 +22,7 @@
<hr>
<div id="container"></div>
<hr>
<script src="../flexsearch.compact.js"></script>
<script src="../dist/flexsearch.compact.js"></script>
<script src="../data/gulliver.js"></script>
<script>

View File

@@ -23,7 +23,7 @@
<div id="container"></div>
<hr>
Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least 7 matches for the query "gulliver", 4. result should be ordered by relevance
<script src="../flexsearch.light.js"></script>
<script src="../dist/flexsearch.light.js"></script>
<script src="https://rawgit.com/nextapps-de/bulksearch/master/bulksearch.light.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/elasticlunr/0.9.6/elasticlunr.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/olivernn/lunr.js@2.3.5/lunr.min.js"></script>

View File

@@ -1,37 +0,0 @@
/*
FlexSearch v0.3.5
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';function I(g){var k=0;return function(){return k<g.length?{done:!1,value:g[k++]}:{done:!0}}}function J(g){var k="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return k?k.call(g):{next:I(g)}}var Q="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,R="function"==typeof Object.defineProperties?Object.defineProperty:function(g,k,e){g!=Array.prototype&&g!=Object.prototype&&(g[k]=e.value)};
function S(g,k){if(k){var e=Q;g=g.split(".");for(var h=0;h<g.length-1;h++){var a=g[h];a in e||(e[a]={});e=e[a]}g=g[g.length-1];h=e[g];k=k(h);k!=h&&null!=k&&R(e,g,{configurable:!0,writable:!0,value:k})}}
S("Promise",function(g){function k(d){this.b=0;this.g=void 0;this.a=[];var a=this.c();try{d(a.resolve,a.reject)}catch(q){a.reject(q)}}function e(){this.a=null}function h(d){return d instanceof k?d:new k(function(a){a(d)})}if(g)return g;e.prototype.b=function(d){if(null==this.a){this.a=[];var a=this;this.c(function(){a.g()})}this.a.push(d)};var a=Q.setTimeout;e.prototype.c=function(d){a(d,0)};e.prototype.g=function(){for(;this.a&&this.a.length;){var d=this.a;this.a=[];for(var a=0;a<d.length;++a){var e=
d[a];d[a]=null;try{e()}catch(D){this.f(D)}}}this.a=null};e.prototype.f=function(d){this.c(function(){throw d;})};k.prototype.c=function(){function d(d){return function(k){e||(e=!0,d.call(a,k))}}var a=this,e=!1;return{resolve:d(this.u),reject:d(this.f)}};k.prototype.u=function(d){if(d===this)this.f(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof k)this.v(d);else{a:switch(typeof d){case "object":var a=null!=d;break a;case "function":a=!0;break a;default:a=!1}a?this.o(d):this.j(d)}};
k.prototype.o=function(a){var d=void 0;try{d=a.then}catch(q){this.f(q);return}"function"==typeof d?this.w(d,a):this.j(a)};k.prototype.f=function(a){this.l(2,a)};k.prototype.j=function(a){this.l(1,a)};k.prototype.l=function(a,e){if(0!=this.b)throw Error("Cannot settle("+a+", "+e+"): Promise already settled in state"+this.b);this.b=a;this.g=e;this.m()};k.prototype.m=function(){if(null!=this.a){for(var a=0;a<this.a.length;++a)l.b(this.a[a]);this.a=null}};var l=new e;k.prototype.v=function(a){var d=this.c();
a.B(d.resolve,d.reject)};k.prototype.w=function(a,e){var d=this.c();try{a.call(e,d.resolve,d.reject)}catch(D){d.reject(D)}};k.prototype.then=function(a,e){function d(a,d){return"function"==typeof a?function(d){try{g(a(d))}catch(C){h(C)}}:d}var g,h,l=new k(function(a,d){g=a;h=d});this.B(d(a,g),d(e,h));return l};k.prototype.catch=function(a){return this.then(void 0,a)};k.prototype.B=function(a,e){function d(){switch(k.b){case 1:a(k.g);break;case 2:e(k.g);break;default:throw Error("Unexpected state: "+
k.b);}}var k=this;null==this.a?l.b(d):this.a.push(d)};k.resolve=h;k.reject=function(a){return new k(function(d,e){e(a)})};k.race=function(a){return new k(function(d,e){for(var k=J(a),g=k.next();!g.done;g=k.next())h(g.value).B(d,e)})};k.all=function(a){var e=J(a),d=e.next();return d.done?h([]):new k(function(a,k){function g(d){return function(e){l[d]=e;q--;0==q&&a(l)}}var l=[],q=0;do l.push(void 0),q++,h(d.value).B(g(l.length-1),k),d=e.next();while(!d.done)})};return k});
(function(g,k,e){var h;(h=e.define)&&h.amd?h([],function(){return k}):(h=e.modules)?h[g.toLowerCase()]=k:"object"===typeof exports?module.exports=k:e[g]=k})("FlexSearch",function X(g){function e(b){E(b)&&((b=K[b])||console.warn("Preset not found: "+b));b||(b=x);this.id=b.id||Y++;this.init(b);h(this,"index",function(){return this.a});h(this,"length",function(){return Object.keys(this.a).length})}function h(b,c,a){Object.defineProperty(b,c,{get:a})}function a(b){return new RegExp(b,"g")}function l(b,
c){for(var a=0;a<c.length;a+=2)b=b.replace(c[a],c[a+1]);return b}function d(b,c,a,f,d,L,e){if(c[a])return c[a];d=d?(9-(e||6))*L+(e||6)*d:L;c[a]=d;d>=e&&(b=b[9-(d+.5>>0)],b=b[a]||(b[a]=[]),b[b.length]=f);return d}function G(b,c){if(b)for(var a=Object.keys(b),f=0,d=a.length;f<d;f++){var e=a[f],g=b[e];if(g)for(var A=0,h=g.length;A<h;A++)if(g[A]===c){1===h?delete b[e]:g.splice(A,1);break}else"object"===typeof g[A]&&G(g[A],c)}}function q(b){for(var c="",a="",f="",d=0;d<b.length;d++){var e=b[d];if(e!==
a)if(d&&"h"===e){if(f="a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,("a"===a||"e"===a||"i"===a||"o"===a||"u"===a||"y"===a)&&f||" "===a)c+=e}else c+=e;f=d===b.length-1?"":b[d+1];a=e}return c}function D(b,c){var a=y();if(b)for(var f=0;f<b.length;f++){var d=c?c(b[f]):b[f];a[d]=String.fromCharCode(65E3-b.length+f)}return a}function T(b,c){var d=[];if(b)for(var f in b)if(b.hasOwnProperty(f)){var e=c?c(f):f;d.push(a("(?=.{"+(e.length+3)+",})"+e+"$"),c?c(b[f]):b[f])}return d}function W(b,c){b=b.length-
c.length;return 0>b?1:b?-1:0}function U(b,c){b=b.length-c.length;return 0>b?-1:b?1:0}function V(b,c,a){var f=[],d=b.length;if(1<d){b.sort(U);for(var e=y(),z=b[0],A=z.length,g=0;g<A;)e["@"+z[g++]]=1;for(var h,l=0,t=0;++t<d;){var r=!1,u=t===d-1;var n=[];z=b[t];A=z.length;for(g=0;g<A;){h=z[g++];var m="@"+h;if(e[m]){var p=e[m];if(p===t){if(u){if(f[l++]=h,c&&l===c)return f}else e[m]=t+1;r=!0}else a&&(m=n[p]||(n[p]=[]),m[m.length]=h)}}if(!r&&!a)break}if(a&&(l=f.length,(t=n.length)&&(!c||l<c)))for(;t--;)if(h=
n[t])for(b=0,a=h.length;b<a;b++)if(f[l++]=h[b],c&&l===c)return f}else d&&(f=b[0],c&&f.length>c&&(f=f.slice(0,c)));return f}function E(b){return"string"===typeof b}function C(b){return"function"===typeof b}function w(b){return"undefined"===typeof b}function M(b){for(var c=Array(b),a=0;a<b;a++)c[a]=y();return c}function y(){return Object.create(null)}function Z(b,c,a,f){b=g("flexsearch","id"+b,function(){var b,c;self.onmessage=function(a){if(a=a.data)if(a.search){var f=c.search(a.content,a.threshold?
{limit:a.limit,threshold:a.threshold}:a.limit);self.postMessage({id:b,content:a.content,limit:a.limit,result:f})}else a.add?c.add(a.id,a.content):a.update?c.update(a.id,a.content):a.remove?c.remove(a.id):a.clear?c.clear():a.info?(a=c.info(),a.worker=b,console.log(a)):a.register&&(b=a.id,a.options.cache=!1,a.options.async=!1,a.options.worker=!1,c=(new Function(a.register.substring(a.register.indexOf("{")+1,a.register.lastIndexOf("}"))))(),c=new c(a.options))}},function(b){(b=b.data)&&b.result&&f(b.id,
b.content,b.result,b.limit)},c);var d=X.toString();a.id=c;b.postMessage({register:d,options:a,id:c});return b}var x={encode:"icase",h:"forward",A:!1,cache:!1,async:!1,i:!1,threshold:0,depth:0},K={memory:{encode:"extra",h:"strict",threshold:7},speed:{encode:"icase",h:"strict",threshold:7,depth:2},match:{encode:"extra",h:"full"},score:{encode:"extra",h:"strict",threshold:5,depth:4},balance:{encode:"balance",h:"strict",threshold:6,depth:3},fastest:{encode:"icase",h:"strict",threshold:9,depth:1}},F=[],
Y=0,N=a("\\W+"),O={},P={};(function(){for(var b=Object.getOwnPropertyNames({}.__proto__),c=y(),a=0;a<b.length;a++)c[b[a]]=1;return c})();e.create=function(b){return new e(b)};e.registerMatcher=function(b){for(var c in b)b.hasOwnProperty(c)&&F.push(a(c),b[c]);return this};e.registerEncoder=function(b,c){B[b]=c.bind(B);return this};e.registerLanguage=function(b,c){O[b]=c.filter;P[b]=c.stemmer;return this};e.encode=function(b,c){return B[b](c)};e.prototype.init=function(b){this.l=[];b||(b=x);var c=b.profile,
a=c?K[c]:{};a||console.warn("Preset not found: "+c);if(c=b.worker)if("undefined"!==typeof Worker){var f=this,d=parseInt(c,10)||4;f.v=-1;f.m=0;f.f=[];f.w=null;f.g=Array(d);for(var e=0;e<d;e++)f.g[e]=Z(f.id,e,b,function(b,c,a,d){if(f.m!==f.i)return f.f=f.f.concat(a),f.m++,d&&f.f.length>=d&&(f.m=f.i),f.w&&f.m===f.i&&(f.cache&&f.j.set(c,f.f),f.w(f.f),f.f=[]),f})}else b.worker=!1,this.g=null;this.h=b.tokenize||a.h||this.h||x.h;this.async="undefined"===typeof Promise||w(c=b.async)?this.async||x.async:c;
this.i=w(c=b.worker)?this.i||x.i:c;this.threshold=w(c=b.threshold)?a.threshold||this.threshold||x.threshold:c;this.depth=w(c=b.depth)?a.depth||this.depth||x.depth:c;this.A=w(c=b.suggest)?this.A||x.A:c;this.o=(c=w(c=b.encode)?a.encode:c)&&B[c]&&B[c].bind(B)||(C(c)?c:this.o||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter=D(O[c]||c,this.o);if(c=b.stemmer)this.stemmer=T(P[c]||c,this.o);this.b=M(10-(this.threshold||0));this.c=y();this.a=y();this.u=!0;this.j=(this.cache=c=w(c=b.cache)?
this.cache||x.cache:c)?new aa(c):!1;return this};e.prototype.encode=function(b){b&&F.length&&(b=l(b,F));b&&this.l.length&&(b=l(b,this.l));b&&this.o&&(b=this.o(b));b&&this.stemmer&&(b=l(b,this.stemmer));return b};e.prototype.addMatcher=function(b){var c=this.l,d;for(d in b)b.hasOwnProperty(d)&&c.push(a(d),b[d]);return this};e.prototype.add=function(b,c,a,f,e){if(c&&E(c)&&(b||0===b)){var g="@"+b;if(this.a[g]&&!f)return this.update(b,c);if(this.i)return++this.v>=this.g.length&&(this.v=0),this.g[this.v].postMessage({add:!0,
id:b,content:c}),this.a[g]=""+this.v,a&&a(),this;if(!e){if(this.async&&"function"!==typeof importScripts){var z=this;g=new Promise(function(a){setTimeout(function(){z.add(b,c,null,f,!0);z=null;a()})});if(a)g.then(a);else return g;return this}if(a)return this.add(b,c,null,f,!0),a(),this}c=this.encode(c);if(!c.length)return this;a=this.h;e=C(a)?a(c):c.split(N);var h=y();h._ctx=y();for(var l=this.threshold,H=this.depth,q=this.b,t=e.length,r=0;r<t;r++){var u=e[r];if(u){var n=u.length,m=(t-r)/t,p="";switch(a){case "reverse":case "both":for(var v=
n-1;1<=v;v--)p=u[v]+p,d(q,h,p,b,(n-v)/n,m,l);p="";case "forward":for(v=0;v<n;v++)p+=u[v],d(q,h,p,b,1,m,l);break;case "full":for(v=0;v<n;v++)for(var x=(n-v)/n,w=n;w>v;w--)p=u.substring(v,w),d(q,h,p,b,x,m,l);break;default:if(n=d(q,h,u,b,1,m,l),H&&1<t&&n>=l)for(n=h._ctx[u]||(h._ctx[u]=y()),u=this.c[u]||(this.c[u]=M(10-(l||0))),m=r-H,p=r+H+1,0>m&&(m=0),p>t&&(p=t);m<p;m++)m!==r&&d(u,n,e[m],b,0,10-(m<r?r-m:m-r),l)}}}this.a[g]=1;this.u=!1}return this};e.prototype.update=function(b,a,d){this.a["@"+b]&&E(a)&&
(this.remove(b),this.add(b,a,d,!0));return this};e.prototype.remove=function(b,a,d){var c="@"+b;if(this.a[c]){if(this.i)return this.g[this.a[c]].postMessage({remove:!0,id:b}),delete this.a[c],a&&a(),this;if(!d){if(this.async&&"function"!==typeof importScripts){var e=this;c=new Promise(function(a){setTimeout(function(){e.remove(b,null,!0);e=null;a()})});if(a)c.then(a);else return c;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<10-(this.threshold||0);a++)G(this.b[a],b);this.depth&&
G(this.c,b);delete this.a[c];this.u=!1}return this};e.prototype.search=function(a,c,d,e){var b=a,f=[];if("object"===typeof a){(d=a.callback||c)&&(b.callback=null);c=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);C(c)?(d=c,c=1E3):c||0===c||(c=1E3);if(this.i)for(this.w=d,this.m=0,this.f=[],f=0;f<this.i;f++)this.g[f].postMessage({search:!0,limit:c,threshold:g,content:a});else{if(!e){if(this.async&&"function"!==typeof importScripts){var h=this;a=new Promise(function(a){setTimeout(function(){a(h.search(b,
c,null,!0));h=null})});if(d)a.then(d);else return a;return this}if(d)return d(this.search(b,c,null,!0)),this}if(!a||!E(a))return f;b=a;if(this.cache)if(this.u){if(d=this.j.get(a))return d}else this.j.clear(),this.u=!0;b=this.encode(b);if(!b.length)return f;d=this.h;d=C(d)?d(b):b.split(N);e=d.length;var l=!0,z=[],q=y();if(1<e)if(this.depth){var t=!0;var r=d[0];q[r]=1}else d.sort(W);var u;if(!t||(u=this.c)[r])for(var n=t?1:0;n<e;n++){var m=d[n];if(m){if(!q[m]){var p=[],v=!1,w=0;if(r=t?u[r]:this.b)for(var x=
void 0,B=0;B<10-g;B++)if(x=r[B][m])p[w++]=x,v=!0;if(v)z[z.length]=1<w?p.concat.apply([],p):p[0];else if(!this.A){l=!1;break}q[m]=1}r=m}}else l=!1;l&&(f=V(z,c,this.A));this.cache&&this.j.set(a,f);return f}};e.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.g[a].postMessage({info:!0,id:this.id});else{for(var c,d=0,e=0,g=0,h=0;h<10-(this.threshold||0);h++){a=Object.keys(this.b[h]);for(var l=0;l<a.length;l++)c=this.b[h][a[l]].length,d+=1*c+2*a[l].length+4,e+=c,g+=2*a[l].length}a=Object.keys(this.a);
c=a.length;for(h=0;h<c;h++)d+=2*a[h].length+2;return{id:this.id,memory:d,items:c,sequences:e,chars:g,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:F.length+(this.l?this.l.length:0),worker:this.i,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.h}}};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.b=this.c=this.a=null;return this};e.prototype.export=function(){return JSON.stringify([this.b,
this.c,this.a])};e.prototype.import=function(a){a=JSON.parse(a);this.b=a[0];this.c=a[1];this.a=a[2]};var B={icase:function(a){return a.toLowerCase()},simple:function(){var b=[a("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",a("[\u00e8\u00e9\u00ea\u00eb]"),"e",a("[\u00ec\u00ed\u00ee\u00ef]"),"i",a("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",a("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",a("[\u00fd\u0177\u00ff]"),"y",a("\u00f1"),"n",a("\u00e7"),"c",a("\u00df"),"s",a(" & ")," and ",a("[-/]")," ",a("[^a-z0-9 ]"),
"",a("\\s+")," "];return function(a){a=l(a.toLowerCase(),b);return" "!==a?a:""}}(),advanced:function(){var b=[a("ae"),"a",a("ai"),"ei",a("ay"),"ei",a("ey"),"ei",a("oe"),"o",a("ue"),"u",a("ie"),"i",a("sz"),"s",a("zs"),"s",a("sh"),"s",a("ck"),"k",a("cc"),"k",a("dt"),"t",a("ph"),"f",a("pf"),"f",a("ou"),"o",a("uo"),"u"];return function(a,d){if(!a)return a;a=this.simple(a);2<a.length&&(a=l(a,b));d||1<a.length&&(a=q(a));return a}}(),extra:function(){var b=[a("p"),"b",a("z"),"s",a("[cgq]"),"k",a("n"),"m",
a("d"),"t",a("[vw]"),"f",a("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(var c=0;c<a.length;c++){var d=a[c];1<d.length&&(a[c]=d[0]+l(d.substring(1),b))}a=a.join(" ");a=q(a)}return a}}(),balance:function(){var b=[a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s+")," "];return function(a){return q(l(a.toLowerCase(),b))}}()},aa=function(){function a(a){this.clear();this.C=!0!==a&&a}a.prototype.clear=function(){this.cache=y();this.count=y();this.index=
y();this.s=[]};a.prototype.set=function(a,b){if(this.C&&w(this.cache[a])){var c=this.s.length;if(c===this.C){c--;var d=this.s[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=c;this.s[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};a.prototype.get=function(a){var b=this.cache[a];if(this.C&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var g=this.s,h=e;this.count[g[--e]]<=c&&-1!==e;);e++;if(e!==h){for(c=h;c>e;c--)h=g[c-1],g[c]=h,d[h]=
c;g[e]=a;d[a]=e}}}return b};return a}();return e}(function(){var g={},k="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,h,a,l,d){a=k?URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"})):e+".es5.js";e+="-"+h;g[e]||(g[e]=[]);g[e][d]=new Worker(a);g[e][d].onmessage=l;console.log("Register Worker: "+e+"@"+d);return g[e][d]}}()),this);

View File

@@ -12,7 +12,7 @@
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<!--<script src="../node_modules/mocha-phantomjs-core/browser-shim.js"></script>-->
<script src="flexsearch.es5.js"></script>
<script src="../dist/flexsearch.es5.js"></script>
<script>
window.initMochaPhantomJS && initMochaPhantomJS();
mocha.ui('bdd');

View File

@@ -16,7 +16,7 @@
<h2>Presets Relevance Scoring Comparison</h2>
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<hr>
<script src="../flexsearch.min.js"></script>
<script src="../dist/flexsearch.min.js"></script>
<script src="../data/gulliver.js"></script>
<div id="container">
<table>

View File

@@ -201,7 +201,7 @@
<div style="display:inline-block; width:16px; height:16px; background: #0a0"></div> Most relevant results was successfully found in the first place.<br>
<b>Note:</b> Open console and type e.g. <i>data[493]</i>
</div>
<script src="../flexsearch.min.js"></script>
<script src="../dist/flexsearch.min.js"></script>
<script src="https://rawgit.com/nextapps-de/bulksearch/master/bulksearch.min.js"></script>
<script src="https://cdn.rawgit.com/weixsong/elasticlunr.js/master/example/elasticlunr.min.js"></script>
<script src="https://unpkg.com/lunr@2.1.6/lunr.js"></script>

View File

@@ -8,7 +8,7 @@ if(typeof module !== "undefined"){
var env = process.argv[3] === "test" ? "min" : process.argv[3] === "test/" ? "light" : "";
var expect = require("chai").expect;
var FlexSearch = require("../flexsearch" + (env ? "." + env : "") + ".js");
var FlexSearch = require("../" + (env ? "dist/": "") + "flexsearch" + (env ? "." + env : "") + ".js");
}
var flexsearch_default;