mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-08-24 06:33:51 +02:00
fix package
This commit is contained in:
@@ -1,555 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark Presets</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table td{
|
||||
padding: 1em 2em;
|
||||
}
|
||||
button{
|
||||
padding: 5px 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Document Index Benchmark Comparison</h2>
|
||||
<h4>Indexed Text: Movie Documents</h4>
|
||||
<hr>
|
||||
<div id="container"></div>
|
||||
<hr>
|
||||
<script src="../dist/flexsearch.min.js"></script>
|
||||
<script src="../data/movies.js"></script>
|
||||
<script>
|
||||
|
||||
(function(){
|
||||
|
||||
var index = {};
|
||||
var index_doc = {};
|
||||
var flexsearch_doc;
|
||||
var flexsearch_doc_field;
|
||||
var flexsearch_where;
|
||||
var flexsearch_where_custom;
|
||||
var flexsearch_tag;
|
||||
var flexsearch_static;
|
||||
var flexsearch_static_tag;
|
||||
var flexsearch_static_tag_query;
|
||||
var flexsearch_static_query;
|
||||
var flexsearch_index_tag;
|
||||
var flexsearch_index_ref;
|
||||
var flexsearch_find;
|
||||
|
||||
function add(id, cat, content){
|
||||
(index[cat] || (
|
||||
index[cat] = new FlexSearch("fast")
|
||||
)).add(id, content);
|
||||
}
|
||||
|
||||
function search(cat, query){
|
||||
return index[cat].search(query);
|
||||
}
|
||||
|
||||
function add_doc(cat, content){
|
||||
(index_doc[cat] || (
|
||||
index_doc[cat] = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
})
|
||||
)).add(content);
|
||||
}
|
||||
|
||||
function search_doc(cat, query){
|
||||
return index_doc[cat].search(query, {
|
||||
field: "title"
|
||||
});
|
||||
}
|
||||
|
||||
var tests = {
|
||||
|
||||
"helper-no-doc": {
|
||||
|
||||
init: function(){},
|
||||
add: function(content){
|
||||
|
||||
add(content.id, content.genre, content.title);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return search("Adventure", query);
|
||||
},
|
||||
loops: 400000
|
||||
},
|
||||
|
||||
"helper-doc": {
|
||||
|
||||
init: function(){},
|
||||
add: function(content){
|
||||
|
||||
add_doc(content.genre, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return search_doc("Adventure", query);
|
||||
},
|
||||
loops: 300000
|
||||
},
|
||||
|
||||
"doc-no-cat-no-field": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_doc = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_doc.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_doc.search(query);
|
||||
},
|
||||
loops: 250000
|
||||
},
|
||||
|
||||
"doc-no-cat-field": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_doc_field = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_doc_field.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_doc_field.search(query, {
|
||||
field: "title"
|
||||
});
|
||||
},
|
||||
loops: 250000
|
||||
},
|
||||
|
||||
"where-cat": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_where = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_where.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_where.search(query, {
|
||||
field: "title",
|
||||
where: {
|
||||
genre: "Adventure"
|
||||
}
|
||||
});
|
||||
},
|
||||
loops: 250000
|
||||
},
|
||||
|
||||
"where-custom": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_where_custom = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_where_custom.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_where_custom.search(query, {
|
||||
field: "title",
|
||||
where: function(val){
|
||||
return val.genre === "Adventure";
|
||||
}
|
||||
});
|
||||
},
|
||||
loops: 250000
|
||||
},
|
||||
|
||||
"where-tag": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_tag = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: ["title"],
|
||||
tag: ["genre"]
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_tag.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_tag.search(query, {
|
||||
field: "title",
|
||||
where: {
|
||||
genre: "Adventure"
|
||||
}
|
||||
});
|
||||
},
|
||||
loops: 250000
|
||||
},
|
||||
|
||||
"where-indexed-manual": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_index_ref = new FlexSearch({
|
||||
encode: false,
|
||||
tokenize: function(doc){
|
||||
return [doc];
|
||||
},
|
||||
doc:{
|
||||
id: "id",
|
||||
field: ["genre"]
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_index_ref.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_index_ref.search("Adventure", {
|
||||
|
||||
field: "genre"
|
||||
});
|
||||
},
|
||||
loops: 300000
|
||||
},
|
||||
|
||||
/*
|
||||
"where-indexed-tag": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_index_tag = new FlexSearch({
|
||||
preset: "fastest",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: ["title"],
|
||||
tag: ["genre"]
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_index_tag.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_index_tag.search("Adventure", {
|
||||
|
||||
field: "genre"
|
||||
});
|
||||
},
|
||||
loops: 250000
|
||||
},
|
||||
*/
|
||||
|
||||
"static-where": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_static = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_static.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_static.where({
|
||||
|
||||
genre: "Adventure"
|
||||
});
|
||||
},
|
||||
loops: 400
|
||||
},
|
||||
|
||||
"static-where-tag": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_static_tag = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: "title",
|
||||
tag: "genre"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_static_tag.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_static_tag.where({
|
||||
|
||||
genre: "Adventure"
|
||||
});
|
||||
},
|
||||
loops: 5000000
|
||||
},
|
||||
|
||||
"static-where-query": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_static_query = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_static_query.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_static_query.where({
|
||||
|
||||
title: query,
|
||||
genre: "Adventure"
|
||||
});
|
||||
},
|
||||
loops: 400
|
||||
},
|
||||
|
||||
"static-where-tag-query": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_static_tag_query = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: "title",
|
||||
tag: "genre"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_static_tag_query.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_static_tag_query.where({
|
||||
|
||||
title: query,
|
||||
genre: "Adventure"
|
||||
});
|
||||
},
|
||||
loops: 5000
|
||||
},
|
||||
|
||||
"static-find-id": {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_find = new FlexSearch({
|
||||
preset: "fast",
|
||||
doc:{
|
||||
id: "id",
|
||||
field: "title"
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(content){
|
||||
|
||||
flexsearch_find.add(content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_find.find(10000);
|
||||
},
|
||||
loops: 20000000
|
||||
}
|
||||
};
|
||||
|
||||
function init_container(target){
|
||||
|
||||
var html = "<table>" +
|
||||
"<tr>" +
|
||||
"<th>Preset </th>" +
|
||||
"<th>Single Phrase </th>" +
|
||||
"<th>Multi Phrase </th>" +
|
||||
"<th>Not Found </th>" +
|
||||
"</tr>";
|
||||
|
||||
for(var test in tests){
|
||||
|
||||
if(tests.hasOwnProperty(test)){
|
||||
|
||||
html += "<tr>" +
|
||||
"<td>" + test + "</td>" +
|
||||
"<td id=\"test-" + test + "\">indexing ...</td>" +
|
||||
"<td id=\"test-multi-" + test + "\"></td>" +
|
||||
"<td id=\"test-notfound-" + test + "\"></td>" +
|
||||
"</tr>"
|
||||
}
|
||||
}
|
||||
|
||||
html += "</table>";
|
||||
|
||||
target.innerHTML = html;
|
||||
}
|
||||
|
||||
var is_mobile = navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/);
|
||||
var genres = ["Comedy", "Adventure", "Comic", "Horror"];
|
||||
|
||||
function init_tests(index, keys){
|
||||
|
||||
var key = keys[index];
|
||||
var test = tests[key];
|
||||
|
||||
test.init();
|
||||
|
||||
if(is_mobile && (test.loops > 1)){
|
||||
|
||||
test.loops = (test.loops / 5) >> 0;
|
||||
}
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
|
||||
test.add({
|
||||
id: i,
|
||||
genre: genres[i % 4],
|
||||
title: data[i]
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById("test-" + key).textContent = "ready ...";
|
||||
|
||||
if(++index < keys.length){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
init_tests(index, keys);
|
||||
|
||||
}, 100);
|
||||
}
|
||||
else{
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
start_tests(0, 0, keys);
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function start_tests(suite, index, keys){
|
||||
|
||||
var phrase = suite === 0 ? "mermaid" : (suite === 1 ? "little mermaid" : "undefined");
|
||||
var key = keys[index];
|
||||
var test = tests[key];
|
||||
var loops = test.loops;
|
||||
var query = test.query;
|
||||
var start = Date.now();
|
||||
|
||||
for(var x = 0; x < loops; x++){
|
||||
|
||||
query(phrase);
|
||||
}
|
||||
|
||||
var duration = Date.now() - start;
|
||||
|
||||
console.log("[Suite " + suite + "] " + key + ":", duration);
|
||||
|
||||
document.getElementById("test-" + (suite === 1 ? "multi-" : (suite === 2 ? "notfound-" : "")) + key).textContent = format_number(((1000 / duration * loops * 10 + 0.5) >> 0) / 10) + " op/s";
|
||||
|
||||
if(++index >= keys.length){
|
||||
|
||||
if(++suite < 3){
|
||||
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(index < keys.length){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
start_tests(suite, index, keys);
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
init_container(document.getElementById("container"));
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
init_tests(0, Object.keys(tests));
|
||||
|
||||
}, 100);
|
||||
|
||||
function format_number(num){
|
||||
|
||||
return ("" + num).replace(/(\d)(?=(\d{3})+\b)/g, '$1,');
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
//window.tests = tests;
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,275 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark Presets</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table td{
|
||||
padding: 1em 2em;
|
||||
}
|
||||
button{
|
||||
padding: 5px 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Presets Benchmark Comparison</h2>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<hr>
|
||||
<div id="container"></div>
|
||||
<hr>
|
||||
<script src="../dist/flexsearch.compact.js"></script>
|
||||
<script src="../demo/data/gulliver.js"></script>
|
||||
<script>
|
||||
|
||||
(function(){
|
||||
|
||||
var flexsearch_default = new FlexSearch();
|
||||
var flexsearch_memory = new FlexSearch("memory");
|
||||
var flexsearch_speed = new FlexSearch("speed");
|
||||
var flexsearch_fast = new FlexSearch("fast");
|
||||
var flexsearch_match = new FlexSearch("match");
|
||||
var flexsearch_score = new FlexSearch("score");
|
||||
var flexsearch_balance = new FlexSearch("balance");
|
||||
|
||||
var tests = {
|
||||
|
||||
"fast": {
|
||||
|
||||
init: function(){},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_fast.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_fast.search(query);
|
||||
},
|
||||
loops: 250000
|
||||
},
|
||||
|
||||
"speed": {
|
||||
|
||||
init: function(){},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_speed.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_speed.search(query);
|
||||
},
|
||||
loops: 150000
|
||||
},
|
||||
|
||||
"default": {
|
||||
|
||||
init: function(){},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_default.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_default.search(query);
|
||||
},
|
||||
loops: 100000
|
||||
},
|
||||
|
||||
"balance": {
|
||||
|
||||
init: function(){},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_balance.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_balance.search(query);
|
||||
},
|
||||
loops: 75000
|
||||
},
|
||||
|
||||
"memory": {
|
||||
|
||||
init: function(){},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_memory.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_memory.search(query);
|
||||
},
|
||||
loops: 20000
|
||||
},
|
||||
|
||||
"match": {
|
||||
|
||||
init: function(){},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_match.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_match.search(query);
|
||||
},
|
||||
loops: 20000
|
||||
},
|
||||
|
||||
"score": {
|
||||
|
||||
init: function(){},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_score.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_score.search(query);
|
||||
},
|
||||
loops: 30000
|
||||
}
|
||||
};
|
||||
|
||||
function init_container(target){
|
||||
|
||||
var html = "<table>" +
|
||||
"<tr>" +
|
||||
"<th>Preset </th>" +
|
||||
"<th>Benchmark (Single Phrase) </th>" +
|
||||
"<th>Benchmark (Multi Phrase) </th>" +
|
||||
"<th>Benchmark (Not Found) </th>" +
|
||||
"</tr>";
|
||||
|
||||
for(var test in tests){
|
||||
|
||||
if(tests.hasOwnProperty(test)){
|
||||
|
||||
html += "<tr>" +
|
||||
"<td>" + test + "</td>" +
|
||||
"<td id=\"test-" + test + "\">indexing ...</td>" +
|
||||
"<td id=\"test-multi-" + test + "\"></td>" +
|
||||
"<td id=\"test-notfound-" + test + "\"></td>" +
|
||||
"</tr>"
|
||||
}
|
||||
}
|
||||
|
||||
html += "</table>";
|
||||
|
||||
target.innerHTML = html;
|
||||
}
|
||||
|
||||
var is_mobile = navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/);
|
||||
|
||||
function init_tests(index, keys){
|
||||
|
||||
var key = keys[index];
|
||||
var test = tests[key];
|
||||
|
||||
test.init();
|
||||
|
||||
if(is_mobile && (test.loops > 1)){
|
||||
|
||||
test.loops = (test.loops / 5) >> 0;
|
||||
}
|
||||
|
||||
for(var i = 0; i < text_data.length; i++){
|
||||
|
||||
test.add(i, text_data[i]);
|
||||
}
|
||||
|
||||
document.getElementById("test-" + key).textContent = "ready ...";
|
||||
|
||||
if(++index < keys.length){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
init_tests(index, keys);
|
||||
|
||||
}, 100);
|
||||
}
|
||||
else{
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
start_tests(0, 0, keys);
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
var text_queries_notfound = [
|
||||
|
||||
"undefined1 undefined2 undefined3",
|
||||
"undefined"
|
||||
];
|
||||
|
||||
function start_tests(suite, index, keys){
|
||||
|
||||
var queries = suite === 0 ? text_queries : (suite === 1 ? text_queries_multi : text_queries_notfound);
|
||||
var len = queries.length;
|
||||
var key = keys[index];
|
||||
var test = tests[key];
|
||||
var loops = test.loops;
|
||||
var query = test.query;
|
||||
var start = Date.now();
|
||||
|
||||
for(var i = 0; i < len; i++){
|
||||
|
||||
var phrase = queries[i];
|
||||
|
||||
for(var x = 0; x < loops; x++){
|
||||
|
||||
query(phrase);
|
||||
}
|
||||
}
|
||||
|
||||
var duration = Date.now() - start;
|
||||
|
||||
console.log("[Suite " + suite + "] " + key + ":", duration);
|
||||
|
||||
document.getElementById("test-" + (suite === 1 ? "multi-" : (suite === 2 ? "notfound-" : "")) + key).textContent = format_number(((1000 / duration * loops * 10 + 0.5) >> 0) / 10) + " op/s";
|
||||
|
||||
if(++index >= keys.length){
|
||||
|
||||
if(++suite < 3){
|
||||
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(index < keys.length){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
start_tests(suite, index, keys);
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
init_container(document.getElementById("container"));
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
init_tests(0, Object.keys(tests));
|
||||
|
||||
}, 100);
|
||||
|
||||
function format_number(num){
|
||||
|
||||
return ("" + num).replace(/(\d)(?=(\d{3})+\b)/g, '$1,');
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
//window.tests = tests;
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,479 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table td{
|
||||
padding: 1em 2em;
|
||||
}
|
||||
button{
|
||||
padding: 5px 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark Comparison</h2>
|
||||
<h4>Indexed Text: Movie Titles</h4>
|
||||
<hr>
|
||||
<div id="container"></div>
|
||||
<hr>
|
||||
Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least 8 matches for the query "The Spirit", 4. result should be ordered by relevance
|
||||
<script src="../dist/flexsearch.light.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/nextapps-de/bulksearch@master/bulksearch.light.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/weixsong/elasticlunr.js@0.9.6/example/elasticlunr.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/lunr@2.3.5/lunr.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/kbrsh/wade@0.3.3/dist/wade.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/krisk/Fuse@3.3.0/dist/fuse.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/js-search@1.4.2/dist/umd/js-search.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/BitSet.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
|
||||
<script src="https://gistcdn.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
|
||||
<script src="https://rawcdn.githack.com/jeancroy/FuzzySearch/cbcdd8307d70a209b1cbf17a535158d5c21840d7/dist/FuzzySearch.min.js"></script>
|
||||
<script src="../data/movies.js"></script>
|
||||
<script>
|
||||
|
||||
(function(){
|
||||
|
||||
var bulksearch;
|
||||
var flexsearch;
|
||||
// var flexsearch_cache;
|
||||
// var flexsearch_worker;
|
||||
// var flexsearch_cache_scale;
|
||||
var elasticsearch;
|
||||
var lunrsearch;
|
||||
var wade;
|
||||
var fuse;
|
||||
var jssearch;
|
||||
var jsii;
|
||||
var bm25;
|
||||
var fuzzysearch;
|
||||
|
||||
var tests = {
|
||||
|
||||
flexsearch: {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch = new FlexSearch({
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
threshold: 8,
|
||||
resolution: 9,
|
||||
depth: 1,
|
||||
async: false,
|
||||
cache: false,
|
||||
worker: false
|
||||
});
|
||||
},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch.search(query);
|
||||
},
|
||||
loops: 350000
|
||||
},
|
||||
|
||||
/*
|
||||
flexsearch_cache_unbound: {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_cache = new FlexSearch({
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
threshold: 9,
|
||||
depth: 1,
|
||||
async: false,
|
||||
cache: true,
|
||||
worker: false
|
||||
});
|
||||
},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_cache.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_cache.search(query);
|
||||
},
|
||||
loops: 1000000
|
||||
},
|
||||
*/
|
||||
|
||||
/*
|
||||
flexsearch_cache_balanced: {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_cache_scale = new FlexSearch({
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
threshold: 9,
|
||||
depth: 1,
|
||||
async: false,
|
||||
cache: 100,
|
||||
worker: false
|
||||
});
|
||||
},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_cache_scale.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return flexsearch_cache_scale.search(query);
|
||||
},
|
||||
loops: 1000000
|
||||
},
|
||||
*/
|
||||
|
||||
/*
|
||||
flexsearch_worker: {
|
||||
|
||||
init: function(){
|
||||
|
||||
flexsearch_worker = new FlexSearch({
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
threshold: 9,
|
||||
depth: 1,
|
||||
async: true,
|
||||
cache: false,
|
||||
worker: 4
|
||||
});
|
||||
},
|
||||
add: function(index, content){
|
||||
|
||||
flexsearch_worker.add(index, content);
|
||||
},
|
||||
query: async function(query){
|
||||
|
||||
return await new Promise(function(resolve){
|
||||
|
||||
flexsearch_worker.search(query, resolve);
|
||||
});
|
||||
},
|
||||
loops: 5000
|
||||
},
|
||||
*/
|
||||
|
||||
bulksearch: {
|
||||
|
||||
init: function(){
|
||||
|
||||
bulksearch = new BulkSearch({
|
||||
type: "short",
|
||||
encode: "icase",
|
||||
multi: false,
|
||||
async: false,
|
||||
cache: false,
|
||||
worker: false
|
||||
});
|
||||
},
|
||||
add: function(index, content){
|
||||
|
||||
bulksearch.add(index, content);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return bulksearch.search(query);
|
||||
},
|
||||
loops: 2800
|
||||
},
|
||||
|
||||
elasticlunr: {
|
||||
|
||||
init: function(){
|
||||
|
||||
elasticsearch = elasticlunr(function(){
|
||||
this.setRef("id");
|
||||
this.addField("content");
|
||||
});
|
||||
},
|
||||
add: function(index, content){
|
||||
|
||||
elasticsearch.addDoc({id: index, content: content});
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return elasticsearch.search(query);
|
||||
},
|
||||
loops: 700
|
||||
},
|
||||
|
||||
lunr: {
|
||||
|
||||
init: function(){
|
||||
|
||||
lunrsearch = lunr(function(){
|
||||
this.ref("id");
|
||||
this.field("content");
|
||||
for(var i = 0; i < data.length; i++){
|
||||
this.add({id: i, content: data[i]});
|
||||
}
|
||||
});
|
||||
},
|
||||
add: function(index, content){},
|
||||
query: function(query){
|
||||
|
||||
return lunrsearch.search(query);
|
||||
},
|
||||
loops: 2400
|
||||
},
|
||||
|
||||
wade: {
|
||||
|
||||
init: function(){
|
||||
|
||||
wade = Wade(data.slice(0));
|
||||
},
|
||||
sort: function(a, b){
|
||||
|
||||
var sum = a.score - b.score;
|
||||
return sum < 0 ? 1 : sum ? -1 : 0;
|
||||
},
|
||||
add: function(index, content){},
|
||||
query: function(query){
|
||||
|
||||
return wade(query).sort(this.sort);
|
||||
},
|
||||
loops: 10000
|
||||
},
|
||||
|
||||
fuse: {
|
||||
|
||||
init: function(){
|
||||
|
||||
var payload = [];
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
fuse = new Fuse(payload, {
|
||||
keys: ["content"],
|
||||
id: "id",
|
||||
shouldSort: true,
|
||||
tokenize: true,
|
||||
matchAllTokens: true,
|
||||
threshold: 0.2
|
||||
});
|
||||
},
|
||||
add: function(index, content){},
|
||||
query: function(query){
|
||||
|
||||
return fuse.search(query);
|
||||
},
|
||||
loops: 1
|
||||
},
|
||||
|
||||
jssearch: {
|
||||
|
||||
init: function(){
|
||||
|
||||
var payload = [];
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
jssearch = new JsSearch.Search("id");
|
||||
jssearch.addIndex("content");
|
||||
jssearch.addDocuments(payload);
|
||||
},
|
||||
add: function(index, content){},
|
||||
query: function(query){
|
||||
|
||||
return jssearch.search(query);
|
||||
},
|
||||
loops: 8000
|
||||
},
|
||||
|
||||
jsii: {
|
||||
|
||||
init: function(){
|
||||
|
||||
var payload = [];
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
payload[i] = {id: i, text: data[i]};
|
||||
}
|
||||
|
||||
jsii = new JSii();
|
||||
jsii.feedDocs(payload);
|
||||
},
|
||||
add: function(index, content){},
|
||||
query: function(query){
|
||||
|
||||
return jsii.search(query);
|
||||
},
|
||||
loops: 100000
|
||||
},
|
||||
|
||||
bm25: {
|
||||
|
||||
init: function(){
|
||||
|
||||
bm25 = new BM25();
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
bm25.addDocument({id: i, body: data[i]});
|
||||
}
|
||||
|
||||
bm25.updateIdf();
|
||||
},
|
||||
add: function(index, content){},
|
||||
query: function(query){
|
||||
|
||||
return bm25.search(query);
|
||||
},
|
||||
loops: 50
|
||||
},
|
||||
|
||||
fuzzysearch: {
|
||||
|
||||
init: function(){
|
||||
|
||||
fuzzysearch = new FuzzySearch({source:data.slice(0)});
|
||||
},
|
||||
add: function(index, content){},
|
||||
query: function(query){
|
||||
|
||||
return fuzzysearch.search(query);
|
||||
},
|
||||
loops: 4
|
||||
}
|
||||
};
|
||||
|
||||
function init_container(target){
|
||||
|
||||
var html = "<table>" +
|
||||
"<tr>" +
|
||||
"<th>Library </th>" +
|
||||
"<th>Benchmark (Single Phrase) </th>" +
|
||||
"<th>Benchmark (Multi Phrase) </th>" +
|
||||
"<th>Benchmark (Not Found) </th>" +
|
||||
"</tr>";
|
||||
|
||||
for(var test in tests){
|
||||
|
||||
if(tests.hasOwnProperty(test)){
|
||||
|
||||
html += "<tr>" +
|
||||
"<td>" + test + "</td>" +
|
||||
"<td id=\"test-" + test + "\">indexing ...</td>" +
|
||||
"<td id=\"test-multi-" + test + "\"></td>" +
|
||||
"<td id=\"test-notfound-" + test + "\"></td>" +
|
||||
"</tr>"
|
||||
}
|
||||
}
|
||||
|
||||
html += "</table>";
|
||||
|
||||
target.innerHTML = html;
|
||||
}
|
||||
|
||||
var is_mobile = navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/);
|
||||
|
||||
function init_tests(index, keys){
|
||||
|
||||
var key = keys[index];
|
||||
var test = tests[key];
|
||||
|
||||
test.init();
|
||||
|
||||
if(is_mobile && (test.loops > 1)){
|
||||
|
||||
test.loops = (test.loops / 5) >> 0;
|
||||
}
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
|
||||
test.add(i, data[i]);
|
||||
}
|
||||
|
||||
document.getElementById("test-" + key).textContent = "ready ...";
|
||||
|
||||
if(++index < keys.length){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
init_tests(index, keys);
|
||||
|
||||
}, 100);
|
||||
}
|
||||
else{
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
start_tests(0, 0, keys);
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function start_tests(suite, index, keys){
|
||||
|
||||
var phrase = suite === 0 ? "mermaid" : (suite === 1 ? "little mermaid" : "undefined");
|
||||
var key = keys[index];
|
||||
var test = tests[key];
|
||||
var loops = test.loops;
|
||||
var query = test.query;
|
||||
var start = Date.now();
|
||||
|
||||
for(var x = 0; x < loops; x++){
|
||||
|
||||
query(phrase);
|
||||
}
|
||||
|
||||
var duration = Date.now() - start;
|
||||
|
||||
console.log("[Suite " + suite + "] " + key + ":", duration);
|
||||
|
||||
document.getElementById("test-" + (suite === 1 ? "multi-" : (suite === 2 ? "notfound-" : "")) + key).textContent = format_number(((1000 / duration * loops * 10 + 0.5) >> 0) / 10) + " op/s";
|
||||
|
||||
if(++index >= keys.length){
|
||||
|
||||
if(++suite < 3){
|
||||
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(index < keys.length){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
start_tests(suite, index, keys);
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
init_container(document.getElementById("container"));
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
init_tests(0, Object.keys(tests));
|
||||
|
||||
}, 100);
|
||||
|
||||
function format_number(num){
|
||||
|
||||
return ("" + num).replace(/(\d)(?=(\d{3})+\b)/g, '$1,');
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
//window.tests = tests;
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
18
bench/old/dist/flexsearch.light.js
vendored
18
bench/old/dist/flexsearch.light.js
vendored
@@ -1,18 +0,0 @@
|
||||
/**!
|
||||
* FlexSearch.js v0.7.0 (Light)
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
(function(){'use strict';var u;Object.assign||(Object.assign=function(){for(var a=arguments,b=a.length,c=a[0],e=1,d,h,g;e<b;e++){d=a[e];h=Object.keys(d);g=h.length;for(var f=0,m;f<g;f++)m=h[f],c[m]=d[m]}return c});function v(a){return"string"===typeof a}function y(a){for(var b=Array(a),c=0;c<a;c++)b[c]=B();return b}function B(){return Object.create(null)}function C(a,b){for(var c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a};var F=/[\W_]+/;function G(a){if(a=a.toLowerCase())if(a&&this.g&&(a=C(a,this.g)),this.h&&1<a.length&&(a=C(a,this.h)),a&&(F||""===F)&&(a=a.split(F),this.filter)){for(var b=this.filter,c=a.length,e=[],d=0,h=0;d<c;d++){var g=a[d];g&&!b[g]&&(e[h++]=g)}a=e}return a};var H=0,I={},J={};function K(a){if(!(this instanceof K))return new K(a);var b=a&&a.id;this.id=b||0===b?b:H++;this.init(a);L(this,"index",function(){return Object.keys(this.a)});L(this,"length",function(){return this.index.length})}K.registerCharset=function(a,b){J[a]=b;return K};K.registerLanguage=function(a,b){I[a]=b;return K};u=K.prototype;
|
||||
u.init=function(a){var b;a||(a={});var c=a.charset,e=a.lang;v(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=J[c]);v(e)&&(e=I[e]);this.j=b=c&&c.l||a.tokenize||"strict";this.depth="strict"===b&&a.depth||0;this.i=c&&c.i||a.rtl||!1;this.b=a.resolution||9;this.threshold=b=a.threshold||0;this.b<=b&&(this.b=b+1);this.encode=a.encode||c&&c.encode||G;this.g=(b=a.matcher||e&&e.g)&&M(b,!1);this.h=(b=a.stemmer||e&&e.h)&&M(b,!0);if(a=b=a.filter||e&&e.filter)for(a=B(),c=0,e=b.length;c<e;c++)a[b[c]]=1;this.filter=
|
||||
a;this.f=y(this.b-this.threshold);this.c=B();this.a=B();return this};
|
||||
u.add=function(a,b,c,e,d){if(b&&v(b)&&(a||0===a)){if(this.a[a]&&!e)return this.update(a,b);if(!d&&c)return this.add(a,b,null,e,!0),c(),this;b=this.encode(b);if(!b.length)return this;c=B();c._ctx=B();e=b.length;d=this.threshold;for(var h=this.depth,g=this.b,f=this.f,m=this.i,t,q=0;q<e;q++){var n=b[q];if(n){t=1;var p=n.length,r=(m?q+1:e-q)/e,l="";switch(this.j){case "reverse":case "both":for(var k=p;--k;)l=n[k]+l,N(f,c,l,a,m?1:(p-k)/p,r,d,g-1);l="";case "forward":for(k=0;k<p;k++)l+=n[k],N(f,c,l,a,m?
|
||||
(k+1)/p:1,r,d,g-1);break;case "full":for(k=0;k<p;k++)for(var w=(m?k+1:p-k)/p,z=p;z>k;z--)l=n.substring(k,z),N(f,c,l,a,w,r,d,g-1);break;default:if(p=N(f,c,n,a,1,r,d,g-1),h&&1<e&&p>=d)for(p=c._ctx[n]||(c._ctx[n]=B()),n=this.c[n]||(this.c[n]=y(g-(d||0))),r=q-h,l=q+h+1,0>r&&(r=0),l>e&&(l=e);r<l;r++)r!==q&&N(n,p,b[r],a,0,g-(r<q?q-r:r-q),d,g-1)}}}t&&(this.a[a]=1)}return this};u.update=function(a,b,c){this.a[a]&&v(b)&&(this.remove(a),this.add(a,b,c,!0));return this};
|
||||
u.remove=function(a,b,c){if(this.a[a]){if(!c&&b)return this.remove(a,null,!0),b(),this;for(b=0;b<this.b-(this.threshold||0);b++)Q(this.f[b],a);this.depth&&Q(this.c,a);delete this.a[a]}return this};
|
||||
u.search=function(a,b,c,e){b&&"function"===typeof b?(c=b,b=1E3):b||0===b||(b=1E3);var d=[],h=a;if("object"===typeof a){var g=!1;b=a.limit;var f=a.threshold;var m=!1;a=a.query}f||(f=this.threshold||0);if(!e&&c)return c(this.search(h,b,null,!0)),this;if(!a||!v(a))return d;h=this.encode(a);if(!h.length)return d;c=h;e=c.length;h=!0;a=[];var t=B(),q,n=0;1<e&&(this.depth?q=!0:c.sort(R));var p;if(!q||(p=this.c))for(var r=this.b;n<e;n++){var l=c[n];if(l){if(q){if(!k)if(p[l]){var k=l;t[l]=1}else if(!m)return d;
|
||||
if(m&&n===e-1&&!a.length)q=!1,l=k||l,t[l]=0;else if(!k)continue}if(!t[l]){var w=[],z=!1,O=0;if(k=q?p[k]:this.f)for(var P,E=0;E<r-f;E++)if(P=k[E]&&k[E][l])w[O++]=P,z=!0;if(z)k=l,a[a.length]=1<O?w.concat.apply([],w):w[0];else{h=!1;break}t[l]=1}}}else h=!1;if(h)a:{d=[];!0===g?(g="0",f=""):f=g&&g.split(":");m=a.length;if(1<m){q=B();k=0;r=!0;h=0;var A;for(f&&(2===f.length?f=!1:f=A=parseInt(f[0],10));k<m;k++)if(t=k===m-1,p=a[k],e=p.length){if(r)if(x){n=x.length;for(c=0;c<n;c++)q["@"+x[c]]=1;var x=null;
|
||||
r=!1}else{x=p;continue}l=!1;for(c=0;c<e;c++)if(n=p[c],w="@"+n,(z=q[w]||0)&&z===k){if(t){if(!A||--A<h)if(d[h++]=n,b&&h===b){d=S(g,h+(f||0),d);break a}}else q[w]=k+1;l=!0}if(!l)break}else{d=S(g,D,p);break a}x&&(d=x)}else m&&(d=a[0],f&&(f=parseInt(f[0],10)));if(b){x=d.length;f&&f>x&&(f=0);A=f||0;var D=A+b;D<x?d=d.slice(A,D):(D=0,A&&(d=d.slice(A)))}d=S(g,D,d)}return d};u.clear=function(){return this.destroy().init()};u.destroy=function(){this.f=this.c=this.a=null;return this};
|
||||
function L(a,b,c){Object.defineProperty(a,b,{get:c})}function N(a,b,c,e,d,h,g,f){if(b[c])return b[c];d=d?(f-(g||f/1.5))*h+(g||f/1.5)*d:h;b[c]=d;d>=g&&(a=a[f-(d+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=e);return d}function Q(a,b){if(a)for(var c=Object.keys(a),e=0,d=c.length;e<d;e++){var h=c[e],g=a[h];if(g)for(var f=0,m=g.length;f<m;f++)if(g[f]===b){1===m?delete a[h]:g.splice(f,1);break}else"object"===typeof g[f]&&Q(g[f],b)}}
|
||||
function M(a,b){for(var c=Object.keys(a),e=c.length,d=[],h="",g=0,f=0,m;f<e;f++){var t=c[f];(m=a[t])?(d[g++]=new RegExp(b?"(?!\\b)"+t+"(\\b|_)":t,"g"),d[g++]=m):h+=(h?"|":"")+t}h&&(d[g++]=new RegExp(b?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),d[g]="");return d}function R(a,b){return b.length-a.length}function S(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c};(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return K}):"object"===typeof a.exports?a.module.exports=K:a.FlexSearch=K})();}).call(this);
|
37
bench/old/dist/flexsearch.min.js
vendored
37
bench/old/dist/flexsearch.min.js
vendored
@@ -1,37 +0,0 @@
|
||||
/**!
|
||||
* FlexSearch.js v0.7.0
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
(function(){'use strict';Object.assign||(Object.assign=function(){for(var a=arguments,b=a.length,c=a[0],d=1,e,f,g;d<b;d++){e=a[d];f=Object.keys(e);g=f.length;for(var h=0,k;h<g;h++)k=f[h],c[k]=e[k]}return c});window.requestAnimationFrame||(window.requestAnimationFrame=window.setTimeout);window.cancelAnimationFrame||(window.cancelAnimationFrame=window.clearTimeout);window.Promise||(window.Promise=function(){function a(b){this.b=null;var c=this;b(function(d){c.b&&(c.b(d),c.b=null)})}a.prototype.then=function(b){this.b=b};return a}());function t(a){return"string"===typeof a}function y(a){return a.constructor===Array}function z(a){return"function"===typeof a}function E(a){return"object"===typeof a}function F(a){return"undefined"===typeof a}function aa(a){for(var b=Array(a),c=0;c<a;c++)b[c]=G();return b}function G(){return Object.create(null)}function K(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function L(a){return new RegExp(a,"g")}
|
||||
function ba(a){for(var b="",c="",d=0,e=a.length,f=void 0;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b}function O(a,b,c,d){if(b&&(c&&b&&(b=K(b,c)),b&&a.u&&(b=K(b,a.u)),a.A&&1<b.length&&(b=K(b,a.A)),b&&(d||""===d)&&(b=b.split(d),a.filter))){a=a.filter;c=b.length;d=[];for(var e=0,f=0;e<c;e++){var g=b[e];g&&!a[g]&&(d[f++]=g)}b=d}return b};P.prototype.export=function(a){var b=!a||F(a.serialize)||a.serialize;if(this.a){var c=!a||F(a.doc)||a.doc,d=!a||F(a.index)||a.index;a=[];var e=0;if(d)for(d=this.a.keys;e<d.length;e++){var f=this.a.index[d[e]];a[e]=[f.j,f.i,Object.keys(f.f)]}c&&(a[e]=this.l)}else a=[this.j,this.i,Object.keys(this.f)];b&&(a=JSON.stringify(a));return a};
|
||||
P.prototype.import=function(a,b){if(!b||F(b.serialize)||b.serialize)a=JSON.parse(a);var c={};if(this.a){var d=!b||F(b.doc)||b.doc,e=0;if(!b||F(b.index)||b.index){b=this.a.keys;for(var f=b.length,g=a[0][2];e<g.length;e++)c[g[e]]=1;for(e=0;e<f;e++){g=this.a.index[b[e]];var h=a[e];h&&(g.j=h[0],g.i=h[1],g.f=c)}}d&&(this.l=E(d)?d:a[e])}else{d=a[2];for(e=0;e<d.length;e++)c[d[e]]=1;this.j=a[0];this.i=a[1];this.f=c}};P.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};
|
||||
P.prototype.where=function(a,b,c,d){var e=this.l,f=[],g=0,h;if(E(a)){c||(c=b);var k=Object.keys(a);var m=k.length;var q=!1;if(1===m&&"id"===k[0])return[e[a.id]];if((h=this.F)&&!d)for(var r=0;r<h.length;r++){var p=h[r],l=a[p];if(!F(l)){var n=this.w[p]["@"+l];if(0===--m)return n;k.splice(k.indexOf(p),1);delete a[p];break}}h=Array(m);for(r=0;r<m;r++)h[r]=k[r].split(":")}else{if(z(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)m=e[b[k]],a(m)&&(f[g++]=m);return f}if(F(b))return[e[a]];if("id"===a)return[e[b]];
|
||||
k=[a];m=1;h=[a.split(":")];q=!0}d=n||d||Object.keys(e);r=d.length;for(p=0;p<r;p++){l=n?d[p]:e[d[p]];for(var w=!0,v=0;v<m;v++){q||(b=a[k[v]]);var x=h[v],u=x.length,A=l;if(1<u)for(var B=0;B<u;B++)A=A[x[B]];else A=A[x[0]];if(A!==b){w=!1;break}}if(w&&(f[g++]=l,c&&g===c))break}return f};function S(a){this.clear();this.m=!0!==a&&a}S.prototype.clear=function(){this.cache=G();this.count=G();this.index=G();this.b=[]};S.prototype.set=function(a,b){if(this.m&&F(this.cache[a])){var c=this.b.length;if(c===this.m){c--;var d=this.b[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.b[c]=a;this.index[a]=c;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};
|
||||
S.prototype.get=function(a){var b=this.cache[a];if(this.m&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var f=this.b,g=e;this.count[f[--e]]<=c&&-1!==e;);e++;if(e!==g){for(c=g;c>e;c--)g=f[c-1],f[c]=g,d[g]=c;f[e]=a;d[a]=e}}}return b};var U={},da="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;function ea(a,b,c){var d=fa,e="flexsearch";d=da?URL.createObjectURL(new Blob(["("+d.toString()+")()"],{type:"text/javascript"})):e+".browser.js";e+="-"+a;U[e]||(U[e]=[]);U[e][c]=new Worker(d);U[e][c].onmessage=b;return U[e][c]}
|
||||
function fa(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}: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 ha(a,b,c,d){a=ea("id"+a,function(f){(f=f.data)&&f.result&&d(f.id,f.content,f.result,f.limit,f.where,f.cursor,f.suggest)},b);var e=P.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}P.prototype.G=function(a,b,c,d){this.s!==this.v&&(this.o=this.o.concat(c),this.s++,d&&this.o.length>=d&&(this.s=this.v),this.s===this.v&&(this.cache&&this.g.set(b,this.o),this.C&&this.C(this.o)));return this};var ia={memory:{charset:"latin:extra",threshold:0,c:1},speed:{threshold:1,c:3,depth:2},match:{charset:"latin:extra",B:"full",threshold:1,c:3},score:{charset:"latin:extra",threshold:1,c:9,depth:4},balance:{charset:"latin:balance",threshold:0,c:3,depth:3},fast:{threshold:8,c:9,depth:1}};var ka={encode:ja,h:!1},la=/[\W_]+/;function ja(a){return O(this,a.toLowerCase(),!1,la)};var ma=0,na={},V={};function P(a){if(!(this instanceof P))return new P(a);var b=a&&a.id;this.id=b||0===b?b:ma++;this.init(a);oa(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});oa(this,"length",function(){return this.index.length})}P.registerCharset=function(a,b){V[a]=b;return P};P.registerLanguage=function(a,b){na[a]=b;return P};
|
||||
P.prototype.init=function(a){var b,c;if(a)if(t(a))a=ia[a];else if(b=a.preset)a=Object.assign({},ia[b],a);a||(a={});if(b=a.worker){if("undefined"===typeof ea)a.worker=!1,this.m=null;else{var d=parseInt(b,10)||4;this.s=0;this.o=[];this.C=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=ha(this.id,e,a,this.G)}this.v=b}this.async=a.async;d=a.charset;e=a.lang;t(d)&&(-1===d.indexOf(":")&&(d+=":default"),d=V[d]);t(e)&&(e=na[e]);this.D=b=d&&d.B||a.tokenize||"strict";this.depth="strict"===b&&a.depth||0;
|
||||
this.h=d&&d.h||a.rtl||!1;this.c=a.resolution||9;this.threshold=b=a.threshold||0;this.c<=b&&(this.c=b+1);this.encode=a.encode||d&&d.encode||ja;this.u=(b=a.matcher||e&&e.u)&&pa(b,!1);this.A=(b=a.stemmer||e&&e.A)&&pa(b,!0);if(d=b=a.filter||e&&e.filter){d=b;e=G();var f=0;for(c=d.length;f<c;f++)e[d[f]]=1;d=e}this.filter=d;(this.a=c=(b=a.doc)&&qa(b))&&(a.doc=null);this.j=aa(this.c-this.threshold);this.i=G();this.f=G();if(c){this.l=G();d=c.index={};e=c.keys=[];f=c.field;var g=c.tag,h=c.store;y(c.id)||(c.id=
|
||||
c.id.split(":"));if(h){var k=G();if(t(h))k[h]=1;else if(y(h))for(var m=0;m<h.length;m++)k[h[m]]=1;else E(h)&&(k=h);c.store=k}if(g){this.w=G();h=G();if(f)if(t(f))h[f]=a;else if(y(f))for(k=0;k<f.length;k++)h[f[k]]=a;else E(f)&&(h=f);y(g)||(c.tag=g=[g]);for(f=0;f<g.length;f++)this.w[g[f]]=G();this.F=g;f=h}if(f){if(!y(f))if(E(f)){var q=f;c.field=f=Object.keys(f)}else c.field=f=[f];for(c=0;c<f.length;c++)g=f[c],y(g)||(q&&(a=q[g]),e[c]=g,f[c]=g.split(":")),d[g]=new P(a)}}this.b=!0;this.g=(b=a.cache)&&new S(b);
|
||||
return this};function qa(a){var b=G(),c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];b[c]=y(d)?d.slice(0):E(d)?qa(d):d}return b}
|
||||
P.prototype.add=function(a,b,c,d,e){if(this.a&&E(a))return W(this,"add",a,b);if(b&&t(b)&&(a||0===a)){if(this.f[a]&&!d)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){var f=this,g=new Promise(function(M){setTimeout(function(){f.add(a,b,null,d,!0);f=null;M()})});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=b;e=G();e._ctx=G();for(var h=c.length,k=this.threshold,m=this.depth,q=this.c,
|
||||
r=this.j,p=this.h,l=0;l<h;l++){var n=c[l];if(n){g=1;var w=n.length,v=(p?l+1:h-l)/h,x="";switch(this.D){case "reverse":case "both":for(var u=w;--u;)x=n[u]+x,X(r,e,x,a,p?1:(w-u)/w,v,k,q-1);x="";case "forward":for(u=0;u<w;u++)x+=n[u],X(r,e,x,a,p?(u+1)/w:1,v,k,q-1);break;case "full":for(u=0;u<w;u++)for(var A=(p?u+1:w-u)/w,B=w;B>u;B--)x=n.substring(u,B),X(r,e,x,a,A,v,k,q-1);break;default:if(w=X(r,e,n,a,1,v,k,q-1),m&&1<h&&w>=k)for(w=e._ctx[n]||(e._ctx[n]=G()),n=this.i[n]||(this.i[n]=aa(q-(k||0))),v=l-m,
|
||||
x=l+m+1,0>v&&(v=0),x>h&&(x=h);v<x;v++)v!==l&&X(n,w,c[v],a,0,q-(v<l?l-v:v-l),k,q-1)}}}g&&(this.f[a]=1);this.b=!1}return this};
|
||||
function W(a,b,c,d){if(y(c)){var e=c.length;if(e)for(var f=0;f<e;f++)W(a,b,c[f],f===e-1&&d)}else{var g=a.a.index,h=a.a.keys,k=a.a.tag;f=a.a.store;var m;var q=a.a.id;e=c;for(var r=0;r<q.length;r++)e=e[q[r]];if("remove"===b){if(delete a.l[e],c=h.length)for(f=0;f<c;f++)g[h[f]].remove(e,f===c-1&&d)}else{if(k){for(m=0;m<k.length;m++){var p=k[m];var l=c;q=p.split(":");for(r=0;r<q.length;r++)l=l[q[r]];l="@"+l}m=a.w[p];m=m[l]||(m[l]=[])}q=a.a.field;k=0;for(p=q.length;k<p;k++){r=q[k];l=c;for(var n=0;n<r.length;n++)l=
|
||||
l[r[n]];r=g[h[k]];"add"===b?r.add(e,l,k===p-1&&d):r.update(e,l,k===p-1&&d)}if(f){d=Object.keys(f);b=G();for(g=0;g<d.length;g++)if(h=d[g],f[h])for(h=h.split(":"),k=q=void 0,p=0;p<h.length;p++)l=h[p],q=(q||c)[l],k=(k||b)[l]=q;c=b}m&&(m[m.length]=c);a.l[e]=c}}return a}P.prototype.update=function(a,b,c){if(this.a&&E(a))return W(this,"update",a,b);this.f[a]&&t(b)&&(this.remove(a),this.add(a,b,c,!0));return this};
|
||||
P.prototype.remove=function(a,b,c){if(this.a&&E(a))return W(this,"remove",a,b);if(this.f[a]){if(!c){if(this.async&&"function"!==typeof importScripts){var d=this;c=new Promise(function(e){setTimeout(function(){d.remove(a,null,!0);d=null;e()})});if(b)c.then(b);else return c;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.c-(this.threshold||0);b++)ra(this.j[b],a);this.depth&&ra(this.i,a);delete this.f[a];this.b=!1}return this};var Y;
|
||||
function sa(a,b,c,d,e,f,g,h,k,m,q){d=ta(d,h?0:f,k,g,c,m,q);if(k){k=d.page;var r=d.next;d=d.result}if(h)d=a.where(h,null,f,d);else{c=d;d=a.l;f=c.length;g=Array(f);for(h=0;h<f;h++)g[h]=d[c[h]];d=g}e&&(z(e)||(Y=e.split(":"),e=1<Y.length?ua:va),d.sort(e));d=Z(k,r,d);a.g&&a.g.set(b,d);return d}
|
||||
P.prototype.search=function(a,b,c,d){if(E(b)){if(y(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=1E3}else b&&z(b)?(c=b,b=1E3):b||0===b||(b=1E3);var f=[],g=a;if(E(a)&&!y(a)){c||(c=a.callback)&&(g.callback=null);var h=a.sort;var k=a.page;b=a.limit;var m=a.threshold;var q=a.suggest;a=a.query}if(this.a){m=this.a.index;var r=g.where,p=g.bool||"or",l=g.field,n=p,w,v;if(l)y(l)||(l=[l]);else if(y(g)){var x=g;l=[];n=[];for(var u=0;u<g.length;u++)d=g[u],e=d.bool||p,l[u]=d.field,n[u]=e,"not"===
|
||||
e?w=!0:"and"===e&&(v=!0)}else l=this.a.keys;p=l.length;for(u=0;u<p;u++)x&&(g=x[u]),k&&!t(g)&&(g.page=null,g.limit=0),f[u]=m[l[u]].search(g,0);if(c)return c(sa(this,a,n,f,h,b,q,r,k,v,w));if(this.async){var A=this;return new Promise(function(ca){Promise.all(f).then(function(za){ca(sa(A,a,n,za,h,b,q,r,k,v,w))})})}return sa(this,a,n,f,h,b,q,r,k,v,w)}m||(m=this.threshold||0);if(!d){if(this.async&&"function"!==typeof importScripts){var B=this;m=new Promise(function(ca){setTimeout(function(){ca(B.search(g,
|
||||
b,null,!0));B=null})});if(c)m.then(c);else return m;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!t(a))return f;g=a;if(this.g)if(this.b){if(c=this.g.get(a))return c}else this.g.clear(),this.b=!0;g=this.encode(g);if(!g.length)return f;c=g;x=c.length;d=!0;e=[];var M=G(),Q=0;1<x&&(this.depth?p=!0:c.sort(wa));if(!p||(u=this.i))for(var T=this.c;Q<x;Q++){var C=c[Q];if(C){if(p){if(!l)if(u[C])l=C,M[C]=1;else if(!q)return f;if(q&&Q===x-1&&!e.length)p=!1,C=l||C,M[C]=0;else if(!l)continue}if(!M[C]){var D=
|
||||
[],N=!1,H=0,I=p?u[l]:this.j;if(I)for(var R=void 0,J=0;J<T-m;J++)if(R=I[J]&&I[J][C])D[H++]=R,N=!0;if(N)l=C,e[e.length]=1<H?D.concat.apply([],D):D[0];else if(!q){d=!1;break}M[C]=1}}}else d=!1;d&&(f=ta(e,b,k,q));this.g&&this.g.set(a,f);return f};P.prototype.info=function(){return{id:this.id,items:this.length,matcher:this.u.length,worker:this.v,threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.D}};P.prototype.clear=function(){return this.destroy().init()};
|
||||
P.prototype.destroy=function(){this.g&&(this.g.clear(),this.g=null);this.j=this.i=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.l=null}return this};function oa(a,b,c){Object.defineProperty(a,b,{get:c})}function X(a,b,c,d,e,f,g,h){if(b[c])return b[c];e=e?(h-(g||h/1.5))*f+(g||h/1.5)*e:f;b[c]=e;e>=g&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}
|
||||
function ra(a,b){if(a)for(var c=Object.keys(a),d=0,e=c.length;d<e;d++){var f=c[d],g=a[f];if(g)for(var h=0,k=g.length;h<k;h++)if(g[h]===b){1===k?delete a[f]:g.splice(h,1);break}else E(g[h])&&ra(g[h],b)}}function pa(a,b){for(var c=Object.keys(a),d=c.length,e=[],f="",g=0,h=0,k;h<d;h++){var m=c[h];(k=a[m])?(e[g++]=L(b?"(?!\\b)"+m+"(\\b|_)":m),e[g++]=k):f+=(f?"|":"")+m}f&&(e[g++]=L(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function wa(a,b){return b.length-a.length}
|
||||
function va(a,b){a=a[Y];b=b[Y];return a<b?-1:a>b?1:0}function ua(a,b){for(var c=Y.length,d=0;d<c;d++)a=a[Y[d]],b=b[Y[d]];return a<b?-1:a>b?1:0}function Z(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}
|
||||
function ta(a,b,c,d,e,f,g){var h=[];if(!0===c){c="0";var k=""}else k=c&&c.split(":");var m=a.length;if(1<m){var q=G(),r=[],p,l=0,n,w=!0,v=0,x;if(k)if(2===k.length){var u=k;k=!1}else k=x=parseInt(k[0],10);if(g){for(p=G();l<m;l++)if("not"===e[l]){var A=a[l];var B=A.length;for(n=0;n<B;n++)p["@"+A[n]]=1}else var M=l+1;if(F(M))return Z(c,J,h);l=0}else var Q=t(e)&&e;for(var T;l<m;l++){var C=l===(M||m)-1;if(!Q||!l)if((n=Q||e&&e[l])&&"and"!==n)if("or"===n)T=!1;else continue;else T=f=!0;A=a[l];if(B=A.length){if(w)if(H){var D=
|
||||
H.length;for(n=0;n<D;n++){w=H[n];var N="@"+w;g&&p[N]||(q[N]=1,f||(h[v++]=w))}var H=null;w=!1}else{H=A;continue}N=!1;for(n=0;n<B;n++){D=A[n];var I="@"+D,R=f?q[I]||0:l;if(!(!R&&!d||g&&p[I]||!f&&q[I]))if(R===l){if(C){if(!x||--x<v)if(h[v++]=D,b&&v===b)return Z(c,v+(k||0),h)}else q[I]=l+1;N=!0}else d&&(I=r[R]||(r[R]=[]),I[I.length]=D)}if(T&&!N&&!d)break}else if(T&&!d)return Z(c,J,A)}if(H)if(l=H.length,g)for(n=k?parseInt(k,10):0;n<l;n++)a=H[n],p["@"+a]||(h[v++]=a);else h=H;if(d)for(v=h.length,u?(l=parseInt(u[0],
|
||||
10)+1,n=parseInt(u[1],10)+1):(l=r.length,n=0);l--;)if(D=r[l]){for(B=D.length;n<B;n++)if(d=D[n],!g||!p["@"+d])if(h[v++]=d,b&&v===b)return Z(c,l+":"+n,h);n=0}}else!m||e&&"not"===e[0]||(h=a[0],k&&(k=parseInt(k[0],10)));if(b){g=h.length;k&&k>g&&(k=0);k=k||0;var J=k+b;J<g?h=h.slice(k,J):(J=0,k&&(h=h.slice(k)))}return Z(c,J,h)};var ya={encode:xa,h:!1},Aa=/[\W_]+/,Ba=[L("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",L("[\u00e8\u00e9\u00ea\u00eb]"),"e",L("[\u00ec\u00ed\u00ee\u00ef]"),"i",L("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",L("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",L("[\u00fd\u0177\u00ff]"),"y",L("\u00f1"),"n",L("[\u00e7c]"),"k",L("\u00df"),"s",L(" & ")," and "];function xa(a,b){return O(b||this,a.toLowerCase(),Ba,Aa)};var Ca=[L("ae"),"a",L("ai"),"ei",L("ay"),"ei",L("ey"),"ei",L("oe"),"o",L("ue"),"u",L("ie"),"i",L("sz"),"s",L("zs"),"s",L("sh"),"s",L("ck"),"k",L("cc"),"k",L("th"),"t",L("dt"),"t",L("ph"),"f",L("pf"),"f",L("ou"),"o",L("uo"),"u"];function Da(a,b,c){a&&(a=xa(a,b||this).join(" "),2<a.length&&(a=K(a,Ca)),c||(1<a.length&&(a=ba(a)),a&&(a=a.split(" "))));return a};var Fa={encode:Ea,h:!1},Ga=/[\W_]+/;function Ea(a){return O(this,a.toLowerCase(),!1,Ga)};var Ia={encode:Ha,h:!1},Ja=[L("(?!\\b)p"),"b",L("(?!\\b)z"),"s",L("(?!\\b)[cgq]"),"k",L("(?!\\b)n"),"m",L("(?!\\b)d"),"t",L("(?!\\b)[vw]"),"f",L("(?!\\b)[aeiouy]"),""];function Ha(a){a&&(a=Da(a,this,!0),1<a.length&&(a=K(a,Ja)),1<a.length&&(a=ba(a)),a&&(a=a.split(" ")));return a};var La={encode:Ka,h:!1,B:"strict"},Ma=/[^a-z]+/;function Ka(a){a=O(this,a.toLowerCase(),!1,!1);var b=[];if(a)for(var c=a.split(Ma),d=c.length,e=0,f=0;e<d;e++)if((a=c[e])&&2<a.length&&(!this.filter||!this.filter[a])){for(var g=a[0],h=Na(g),k=1;k<a.length;k++){var m=Na(a[k]);if(m!==h&&(g+=m,h=m,4===g.length))break}b[f++]=(g+"0000").substring(0,4)}return b}
|
||||
function Na(a){switch(a){case "b":case "f":case "p":case "v":return 1;case "c":case "g":case "j":case "k":case "q":case "s":case "x":case "z":return 2;case "d":case "t":return 3;case "l":return 4;case "m":case "n":return 5;case "r":return 6}return""};var Pa={encode:Oa,h:!0},Qa=/[\x00-\x7F]+/g;function Oa(a){return O(this,a.replace(Qa," "),!1," ")};var Sa={encode:Ra,h:!1,B:"strict"},Ta=/[\x00-\x7F]+/g;function Ra(a){return O(this,a.replace(Ta,""),!1,"")};var Va={encode:Ua,h:!1},Wa=/[\x00-\x7F]+/g;function Ua(a){return O(this,a.replace(Wa," "),!1," ")};V["latin:advanced"]={encode:Da,h:!1};V["latin:balance"]=Fa;V["latin:default"]=ka;V["latin:extra"]=Ia;V["latin:simple"]=ya;V["latin:soundex"]=La;V["arabic:default"]=Pa;V["cjk:default"]=Sa;V["cyrillic:default"]=Va;(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return P}):"object"===typeof a.exports?a.module.exports=P:a.FlexSearch=P})();}).call(this);
|
57
bench/old/dist/mikado.min.js
vendored
57
bench/old/dist/mikado.min.js
vendored
@@ -1,57 +0,0 @@
|
||||
/**!
|
||||
* Mikado.js v0.7.44
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
* https://github.com/nextapps-de/mikado
|
||||
*/
|
||||
(function(){'use strict';var k;function l(a,b,c,d){if("tap"===b){if(w||B){aa(a);return}ba=!0;b="click"}window[(a?"add":"remove")+"EventListener"](b,c,d||{passive:!0,capture:!0})}
|
||||
function D(a,b){b||(b=a.type);var c=a.target,d=c,e=c["_e_"+b];if(e)d=c["_r_"+b];else{for(;d!==ca;){"click"===b&&ba&&(e=d.getAttribute("tap"));e||(e=d.getAttribute(b));if(e){var f=e.indexOf(":");if(-1!==f){var g=e.substring(0,f);f=e.substring(f+1);e=0;for(d=d.parentElement;d!==ca;){if(d.hasAttribute(f)){e=g;break}d=d.parentElement}}break}d=d.parentElement}if(!e)return;c["_e_"+b]=e;c["_r_"+b]=d}if(b=E[e])a.preventDefault(),b(d,a,c);a.stopPropagation()}
|
||||
var F={},E={},ca=document.body,w="ontouchstart"in window,B=!w&&window.PointerEvent&&navigator.maxTouchPoints,ba;G.route=G.prototype.route=function(a,b){E[a]=b;return this};G.dispatch=G.prototype.dispatch=function(a,b,c,d){E[a](b,c,d);return this};var H,I,aa;
|
||||
if(w||B){var da=function(a,b){b&&(a=b[0]);H=a.clientX;I=a.clientY},ea=function(a){var b=H,c=I;da(a,a.changedTouches);50>Math.abs(H-b)&&50>Math.abs(I-c)&&D.call(this,a,"tap")},fa=function(a){da(a,a.touches)};aa=function(a){l(a,B?"pointerdown":"touchstart",fa,!1);l(a,B?"pointerup":"touchend",ea,!1)}}G.listen=G.prototype.listen=function(a,b){F[a]||(l(1,a,D,b||!0),F[a]=1);return this};G.unlisten=G.prototype.unlisten=function(a,b){F[a]&&(l(0,a,D,b||!0),F[a]=0);return this};k=G.prototype;k.move=function(a,b){if("number"===typeof a){var c=a;a=this.b[c]}else c=this.index(a);0>b&&(b=this.length+b-1);c!==b&&this.shift(a,b-c);return this};
|
||||
k.shift=function(a,b,c){if(!b)return this;if("number"===typeof a){var d=a;a=this.b[a]}else d=this.index(a);var e=0>b;if(e&&d||!e&&d<this.length-1){b=e?Math.max(d+b,0):Math.min(d+b,this.length-1);var f=this.b[b],g=e&&1<d-b||!e&&1<b-d;if(!g&&this.H&&(this.store||this.B)){var h=this.store?this.store[d]:a._m;this.update(a,this.store?this.store[b]:f._m,c,b);this.update(f,h,c,d)}else this.root.insertBefore(a,e?f:this.b[b+1]||null);if(g){a=this.b[d];f=this.store&&this.store[d];if(e)for(;d>b;d--)this.b[d]=
|
||||
this.b[d-1],this.store&&(this.store[d]=this.store[d-1]);else for(;d<b;d++)this.b[d]=this.b[d+1],this.store&&(this.store[d]=this.store[d+1]);this.b[b]=a;this.store&&(this.store[b]=f)}else c=this.b,e=this.store,c[d]=f,c[b]=a,e&&(a=e[b],e[b]=e[d],e[d]=a)}return this};k.up=function(a,b){(!b||0<b)&&this.shift(a,-(b||1));return this};k.down=function(a,b){(!b||0<b)&&this.shift(a,b||1);return this};k.first=function(a){return this.shift(a,-this.length)};k.last=function(a){return this.shift(a,this.length)};
|
||||
k.before=function(a,b){"number"!==typeof a&&(a=this.index(a));"number"!==typeof b&&(b=this.index(b));b!==a+1&&(0>b&&(b=this.length+b,0>a&&b--),0>a&&(a=this.length+a-1),this.shift(a,b-a-1));return this};k.after=function(a,b){"number"!==typeof a&&(a=this.index(a));"number"!==typeof b&&(b=this.index(b));b!==a-1&&(0>b&&(b=this.length+b-2,0>a&&b++),0>a&&(a=this.length+a-1),this.shift(a,b-a+1));return this};
|
||||
k.swap=function(a,b,c){if(a!==b){if("number"===typeof a){var d=a;a=this.b[a]}else d=this.index(a);if("number"===typeof b){var e=b;b=this.b[b]}else e=this.index(b);if(this.H&&(this.store||this.B)){var f=this.store?this.store[d]:a._m;this.update(a,this.store?this.store[e]:b._m,c,d);this.update(b,f,c,e)}else c=d+1!==e,this.root.insertBefore(c?a:b,c?b:a),c&&e+1!==d&&this.root.insertBefore(b,this.b[d+1]||null),this.b[d]=b,this.b[e]=a,this.store&&!this.K&&(a=this.store[e],this.store[e]=this.store[d],this.store[d]=
|
||||
a)}return this};var J={};function ha(a){return J[a]=new RegExp("(?:^|\\s)"+a+"(?!\\S)","g")}function ia(a,b){K(a,b)||(a.className+=" "+b,a._c+=" "+b);return this}function ja(a,b){b=(a._c||(a._c=a.className)).replace(J[b]||ha(b),"");a._c!==b&&(a.className=b,a._c=b);return this}function K(a,b){return!!(a._c||(a._c=a.className)).match(J[b]||ha(b))}function ka(a,b){var c=a._a||(a._a={}),d=c[b];return d||""===d?d:c[b]=a.getAttribute(b)};var la=window.localStorage;G.prototype.export=function(){if(this.store)var a=this.store;else if(this.B){a=Array(this.length);for(var b=0;b<this.length;b++)a[b]=this.b[b]._m}a&&la.setItem(this.l,JSON.stringify(a));return this};G.prototype.import=function(){var a=la.getItem(this.l);a&&(this.store=a=JSON.parse(a));return this};var L=Array.prototype,M=window.Proxy,N=0;function O(a){if(!(this instanceof O))return new O(a);if(a instanceof O)return a;this.view=this.w=null;var b=a?a.length:0;if(M){if(b)for(var c=0;c<b;c++)this[c]=a[c];this.length=b;this.D={splice:L.splice.bind(this),pop:L.pop.bind(this),shift:L.shift.bind(this),unshift:L.unshift.bind(this),push:L.push.bind(this)};return new Proxy(this,ma)}this.D=a||[];for(a=0;a<=b;a++)P(this,a);N=b;P(this,"length")}
|
||||
function P(a,b){Object.defineProperty(a,b,{get:function(){return this.D[b]},set:function(c){"number"===typeof b&&(b===N&&P(this,++N),ma.set(this,b,c))}})}
|
||||
var Q=!1,ma={set:function(a,b,c){if("number"===typeof b)var d=!0;else{var e=parseInt(b,10);b===""+e&&(b=e,d=!0)}if(!Q){Q=!0;if((e=a.w)&&!e.L){var f=a.length;if(d){var g=e.length;f!==g&&(a.length=g);if(e.A&&a[b]===c)return Q=!1,!0;d=a.view;b>=g?(e.add(c,d),a.length++):b<g&&(f=e.key,g=e.b[b],e.H||f&&g._k===c[f]?e.update(g,c,d,b):e.replace(g,c,d,b));if(e.proxy)return Q=!1,!0}else"length"===b&&c<f&&e.remove(c,f-c)}Q=!1}(M?a:a.D)[b]=c;return!0}};k=O.prototype;
|
||||
k.swap=function(a,b){Q=!0;this.w.swap(a,b,this.view);Q=!1;return this};k.splice=function(a,b,c){Q=!0;a||(a=0);"undefined"===typeof b&&(b=this.length-a,0>b&&(b=0));b&&this.w.remove(a,b);b=c?this.D.splice(a,b,c):this.D.splice(a,b);c&&this.w.add(c,a,this.view);Q=!1;return b};k.push=function(a){Q=!0;this.w.add(a,this.view);this.w.proxy||(this[this.length]=a);M&&this.length++;Q=!1};k.unshift=function(a){Q=!0;this.w.add(a,0,this.view);this.D.unshift(a);Q=!1};
|
||||
k.pop=function(){Q=!0;this.w.remove(this.length-1);var a=this.D.pop();Q=!1;return a};k.shift=function(){Q=!0;this.w.remove(0);var a=this.D.shift();Q=!1;return a};k.concat=function(a){for(var b=a.length,c=0;c<b;c++)this.push(a[c]);return this};k.sort=function(a){L.sort.call(this,a);return this};k.reverse=function(){L.reverse.call(this);return this};k.slice=L.slice;k.map=function(a,b){b&&(a=a.bind(this));b=0;for(var c=this.length;b<c;b++)this[b]=a(this[b]);return this};
|
||||
k.filter=function(a,b){b&&(a=a.bind(this));b=0;for(var c=this.length;b<c;b++)if(a(this[b]))e&&(this.splice(d,e),c-=e,b-=e,e=0);else if(e)e++;else{var d=b;var e=1}e&&this.splice(d,e);return this};k.indexOf=function(a){for(var b=0,c=this.length;b<c;b++)if(this[b]===a)return b;return-1};k.lastIndexOf=function(a){for(var b=this.length-1;0<=b;b--)if(this[b]===a)return b;return-1};k.forEach=function(a){for(var b=0,c=this.length;b<c;b++)a(this[b])};var oa=!window.Proxy&&function(){function a(b,c){this.path=c.path;this.M=c.M;c=Object.keys(b);for(var d=0,e=c.length;d<e;d++){var f=c[d];this.g(b,f,b[f])}return b}a.prototype._y=!0;a.prototype.g=function(b,c,d){var e=this;Object.defineProperty(b,c,{get:function(){return d},set:function(f){d!==f&&(na(e.M,e.path,c,f),d=f)}})};return a}(),pa={_x:function(a,b){a.nodeValue=b},_h:function(a,b){a.innerHTML=b},_c:function(a,b){a.className=b},_cs:function(a,b){(a._s||(a._s=a.style)).cssText=b},_a:function(a,
|
||||
b,c){a.setAttribute(c,b)}};function qa(a,b,c){return new (oa||Proxy)(a,{path:b,M:c,get:ra,set:sa})}function ra(a,b){return"_y"===b||a[b]}function sa(a,b,c){a[b]!==c&&(na(this.M,this.path,b,c),a[b]=c);return!0}function na(a,b,c,d){if(a=a["data."+c])for(var e=0,f=a.length,g;e<f;e++)g=a[e],pa[g[0]](b[g[1]],d,g[2]||c)};var ta=window,ua=ta.requestAnimationFrame,va=ta.cancelAnimationFrame,wa={},R={},S={},T={},U={};function G(a,b,c){if(!(this instanceof G))return new G(a,b,c);a.nodeType||(c=b,b=a,a=null);a?this.mount(a):(this.root=this.b=null,this.length=0);this.init(b,c)}var xa=G.register=function(a,b){b||(b=a,a=b.n);R[a]=b;return G};k=G.prototype;
|
||||
k.mount=function(a){this.root!==a&&(this.key&&this.root&&(this.root._o=this.g,this.g=a._o||{}),this.root=a,ya(this),this.b=a._d||(a._d=za(a.children)),this.length=this.b.length);return this};k.sync=function(a){this.root._d=this.b=za(this.root.children);this.length=this.b.length;if(a&&this.cache)for(a=0;a<this.length;a++){var b=this.b[a]._p;if(b)for(var c=0,d;c<b.length;c++)d=b[c],d._c=d._h=d._x=d._cs=d._a=null}return this};
|
||||
k.index=function(a){for(var b=0,c=this.length;b<c;b++)if(this.b[b]===a)return b;return-1};k.node=function(a){return this.b[a]};k.data=function(a){var b="object"===typeof a;return this.store?this.store[b?this.index(a):a]:(b?a:this.b[a])._m};k.find=function(a){if(this.key)return this.g["object"!==typeof a?a:a[this.key]];for(var b=0;b<this.length;b++)if(this.data(b)===a)return this.b[b]};
|
||||
k.search=function(a){a=Object.values(a).join("^");for(var b=0;b<this.length;b++)if(Object.values(this.data(b)).join("^")===a)return this.b[b]};k.where=function(a){for(var b=Object.keys(a),c=b.length,d=[],e=0,f,g;e<this.length;e++){f=this.data(e);g=1;for(var h=0,m;h<c;h++)if(m=b[h],f[m]!==a[m]){g=0;break}g&&(d[d.length]=this.b[e])}return d};
|
||||
k.init=function(a,b){"string"===typeof a?a=R[a]:(b||!a||a.n||(b=a,a=null),a?a.n&&xa(a):a=R[this.l]);b||(b=this.N||{});this.H=!1!==b.reuse;this.state=b.state||wa;this.cache=!1!==b.cache;this.async=b.async;this.C=0;this.J=b.on;var c=b.store||!1!==b.store;(this.K="object"===typeof c)?b.store=!0:c&&(c=[]);if(this.observe=c instanceof O)c.w=this;this.L=0;this.B=!this.K&&!1!==b.loose;this.store=!this.B&&c;this.N=b;c=a.n;this.l!==c&&(this.l=c,this.F=a.d,this.G=this.u=null,this.proxy=this.A=0,this.include=
|
||||
null,this.I=!1!==b.prefetch&&V(this,a),ya(this),this.g=(this.key=a.k)&&{},this.o=this.H&&!1!==b.pool&&(T[c]||(T[c]=[])),this.v=this.key&&(b.keep||this.o)&&(U[c]||(U[c]={})),this.size=this.o&&b.size);return this};G.once=function(a,b,c,d,e){var f=new G(a,b);"function"===typeof d&&(e=d,d=null);if(e){var g=e;e=function(){f.destroy(1);g()}}f.render(c,d,e);e||f.destroy(1);return G};function ya(a){if(a.root){var b=a.root._t;b!==a.l&&(a.root._t=a.l,b&&(a.g={},a.remove(0,a.length)))}}
|
||||
function za(a){for(var b=a.length,c=Array(b),d=0,e;d<b;d++)e=a[d],c[d]=e;return c}k=G.prototype;
|
||||
k.create=function(a,b,c){var d=this.key,e=d&&a[d],f,g;if(d&&(g=this.v)&&(f=g[e])){var h=1;if(g){if(g[e]=null,g=this.o){var m=f._n;f._n=null;var n=g.pop();n!==f&&(n._n=m,g[m]=n)}}else d=0}else if((f=this.o)&&f.length)f=f.pop(),g&&(f._n=null,g[f._k]=null);else{var y=1;f=this.I}h&&this.A&&!this.observe||this.apply(f,a,b,c);if(y){f=this.I.cloneNode(!0);var v;(v=this.J)&&(v=v.create)&&v(f)}d&&(f._k=e,this.g[e]=f);return f};
|
||||
k.apply=function(a,b,c,d){this.I||(this.I=a=V(this,R[this.l]));if(!this.F){b||(b=this.store?this.store[d]:a._m);c&&this.observe&&(this.store.view=c);this.G(a._p||Aa(this,a),!1,b,d,c);var e;(e=this.J)&&(e=e.change)&&a!==this.I&&e(a);return this}};
|
||||
k.refresh=function(a,b){if(this.A)return this;var c;"number"===typeof a?c=this.b[a]:b=a;if(c)return this.apply(c,null,b,a);a=this.length;if((c=this.store)&&this.B)return this.store=null,this.render(c,b);c=c?c.length:a;a=a<c?a:c;for(c=0;c<a;c++)this.apply(this.b[c],null,b,c);return this};
|
||||
k.render=function(a,b,c,d){if(!d){b&&"object"!==typeof b&&(c=b,b=null);this.C&&this.cancel();if(c){var e=this;this.C=ua(function(){e.C=0;e.render(a,b,null,1);"function"===typeof c&&c()});return this}if(this.async){var f=this;return new Promise(function(p){f.C=ua(function(){f.C=0;f.render(a,b,null,1);p()})})}}d=this.length;if(!a){if(this.F)return this.b[0]||this.add(),this;if(d)return this.refresh();if(!(a=this.store))return this}var g=a.length;if("undefined"===typeof g)a=[a],g=1;else if(!g)return this.remove(0,
|
||||
d);var h=(this.v||!this.H)&&this.key;h||this.H||(this.remove(0,d,g),d=0);var m=d<g?d:g,n=0;if(n<m)for(;n<m;n++){var y=this.b[n],v=a[n];if(h&&y._k!==v[h])return this.reconcile(a,b,n,1);this.update(y,v,b,n)}if(n<g)for(;n<g;n++)this.add(a[n],b);else g<d&&this.remove(g,d-g);return this};
|
||||
k.reconcile=function(a,b,c,d){var e=this.store&&!this.K,f=this.b,g=this.g,h=a.length,m=f.length,n=m>h?m:h,y=0,v=this.key;e&&(this.store=0);for(c||(c=0);c<n;c++){var p=void 0;if(c<h){var r=a[c],q=c>=m,t=void 0,z=void 0,x=void 0;if(!q&&(t=f[c],z=r[v],x=t._k,x===z)){d&&this.update(t,r,b,c);continue}if(d&&(q||!g[z])){q||!this.v?(m++,n=m>h?m:h,this.add(r,b,c)):this.replace(t,r,b,c);continue}for(var A=q=void 0,u=c+1;u<n;u++)if(!q&&u<m&&f[u]._k===z&&(q=u+1),!A&&u<h&&a[u][v]===x&&(A=u+1),q&&A){q>=A?(p=f[q-
|
||||
1],this.root.insertBefore(p,t),d&&this.update(p,r,b,c),q===A?(1<u-c&&this.root.insertBefore(t,f[q]),f[c]=f[u],f[u]=t):(W(f,q-1,c),y++)):(r=A-1+y,this.root.insertBefore(t,f[r]||null),W(f,c,(r>m?m:r)-1),y--,c--);p=1;break}}p||(this.remove(c),m--,n=m>h?m:h,c--)}e&&(this.store=a);return this};function W(a,b,c,d){var e=d||a[b];d&&b++;if(b<c)for(;b<c;b++)a[b]=a[b+1];else for(;b>c;b--)a[b]=a[b-1];a[c]=e}
|
||||
k.add=function(a,b,c,d){if(!d)if("number"===typeof b){c=b;b=null;var e=1}else if(c||0===c)e=1;c=d||e?c:this.length;b=this.create(a,b,c);var f;this.proxy&&(this.A&&this.B&&b._m===a?f=1:a._y||(a=qa(a,b._p||Aa(this,b),this.proxy)));f||(this.store?e&&!this.K?W(this.store,this.length-1,c,a):(this.L=1,this.store[c]=a,this.L=0):this.B&&(b._m=a));e?(this.root.insertBefore(b,this.b[c]),W(this.b,this.length-1,c,b),this.length++):(d?this.root.replaceChild(b,d):(this.root.appendChild(b),this.length++),this.b[c]=
|
||||
b);var g;(g=this.J)&&(g=g.insert)&&g(b);return this};k.clear=function(a){this.length&&this.remove(0,this.length);if(a){S[this.l+(this.cache?"$":"")]=null;if(this.key)if(this.length){a=Object.keys(this.g);for(var b=0,c=a.length,d=void 0;b<c;b++)this.key[d=a[b]]||delete this.key[d]}else this.g={};this.o&&(this.o=T[this.l]=[]);this.v&&(this.v=U[this.l]={})}return this};k.destroy=function(a){a&&this.unload();this.length=0;this.include=this.store=this.b=this.root=this.l=this.u=this.G=this.I=this.g=null};
|
||||
k.cancel=function(){this.C&&(va(this.C),this.C=null);return this};k.append=function(a,b,c){if("number"===typeof b){c=b;b=null;var d=1}else d=c||0===c;for(var e=a.length,f=0;f<e;f++)this.add(a[f],b,d?c++:null);return this};
|
||||
k.remove=function(a,b,c){var d=this.length;a&&("object"===typeof a?a=this.index(a):0>a&&(a=d+a-1));if(!d||a>=d)return this;b?0>b&&(a-=b+1,0>a&&(a=0),b*=-1):b=1;if(!a&&b>=d){this.store&&!this.K&&(this.store=c?Array(c):[]);if(this.include&&(this.v||this.o))for(b=0;b<this.include.length;b++)this.include[b].clear();a=this.b;b=a.length;this.root.textContent="";this.root._d=this.b=c?Array(c):[];d=0}else this.store&&!this.observe&&this.store.splice(a,b),a=this.b.splice(a,b),d-=b;var e;if((e=this.J)&&(e=
|
||||
e.remove))for(c=0;c<b;c++)e(a[c]);this.length=d;if(this.o&&!this.v&&1<b){e=a;c=e.length;for(var f=c/2|0,g=0,h;g<f;g++)h=e[g],e[g]=e[c-g-1],e[c-g-1]=h}for(e=0;e<b;e++)c=a[e],d&&this.root.removeChild(c),Ba(this,c);return this};function Ba(a,b){if(a.key){var c=b._k;a.g[c]=null;a.v&&(a.v[c]=b)}a.o&&(c=a.o.length,!a.size||c<a.size)&&(a.v&&(b._n=c),a.o[c]=b)}
|
||||
k.replace=function(a,b,c,d){"undefined"===typeof d&&("number"===typeof a?(d=a,a=this.b[d]):d=this.index(a));this.add(b,c,d,a);Ba(this,a);var e;(e=this.J)&&(e=e.remove)&&e(a);return this};
|
||||
k.update=function(a,b,c,d){"undefined"===typeof d&&("number"===typeof a?(d=a,a=this.b[a]):d=this.index(a));if(this.proxy){if(this.A&&(this.store?this.store[d]:a._m)===b)return this;b._y||(b=qa(b,a._p||Aa(this,a),this.proxy))}this.store?(this.L=1,this.store[d]=b,this.L=0):this.B&&(a._m=b);if(this.key){var e=a._k,f=b[this.key];e!==f&&(this.g[e]=null,this.g[f]=a,a._k=f)}var g;(g=this.J)&&(g=g.update)&&g(a);return this.apply(a,b,c,d)};
|
||||
function Aa(a,b){for(var c=a.u.length,d={},e=Array(c),f=0,g;f<c;f++){g=a.u[f];var h=f,m;if(!(m=d[g])){m=b;for(var n=0,y=g.length,v="";n<y;n++){var p=g[n];v+=p;d[v]?m=d[v]:(">"===p?m=m.firstElementChild:"+"===p?m=m.nextElementSibling:"|"===p&&(m=m.firstChild),d[v]=m)}}e[h]=m}return b._p=e}var X;
|
||||
function V(a,b,c,d,e){if(!c){var f=S[b.n+(a.cache?"$":"")];if(f)return a.G=f.G,a.F=f.F,a.A=f.A,a.proxy=f.proxy,a.include=f.O,a.u=f.u,f.node}f=document.createElement(b.t||"div");c||(c=0,d="&",X="",a.u=[],f._p=e=[]);var g=b.s,h=b.i,m=b.x,n=b.h,y=b.a,v=b.e,p=b.c,r=b.j,q=a.u.length,t=0,z=0,x="";r&&(x+=";"+r,-1<x.indexOf("self")&&(t=2));b.f&&(X+=";if("+b.f+"){self.hidden=false",t=2);p&&("object"===typeof p?(r=p[1],p=p[0],x+=a.cache?";v="+p+";if(self._c!==v){self._c=v;self.className=v}":";self.className="+
|
||||
p,r&&(Y(a,p,["_c",q]),z++),t++):f.className=p);if(y||v){var A;y&&(A=Object.keys(y));v&&(p=Object.keys(v),A=A?A.concat(p):p);for(p=0;p<A.length;p++){r=A[p];var u=void 0;y&&"undefined"!==typeof(u=y[r])||(u=v[r],a.listen(r));if("object"===typeof u){var Ia=u[1];u=u[0];x+=a.cache?";v="+u+";var _a=self._a||(self._a={});if(_a['"+r+"']!==v){_a['"+r+"']=v;self.setAttribute('"+r+"',v)}":";self.setAttribute('"+r+"',"+u+")";Ia&&(Y(a,u,["_a",q,r]),z++);t++}else f.setAttribute(r,u)}}g&&("string"===typeof g?f.style.cssText=
|
||||
g:g.length&&(A=g[1],g=g[0],x+=a.cache?";v="+g+";if(self._cs!==v){self._cs=v;(self._s||(self._s=self.style)).cssText=v}":";self.style.cssText="+g,A&&(Y(a,g,["_cs",q]),z++),t++));if(b["@"]||b.r){a.include||(a.include=[]);var C=b["@"]||b.i;b["@"]||(C.n=b["@"]=a.l+"@"+a.include.length,b.i=null);h=null;x+=";this.include["+a.include.length+"].mount(self).render("+b.r+(b.m?".slice("+(0<=b.m?"0,"+b.m:b.m)+")":"")+",view)";m=X;X="";a.include.push(new G(f,C,Object.assign({},a.N,{store:!1,async:0})));X=m;t++}else if(!h)if(b["+"])h=
|
||||
R[b["+"]];else if(m){if(n="object"===typeof m)C=m[1],m=m[0];g=document.createTextNode(m);n&&(t&&q++,a.u[q]=d+"|",e[q]=g,Ca(t,a.cache?";v="+m+";if(self._x!==v){self._x=v;self.nodeValue=v}":";self.nodeValue="+m,q,a.cache),C&&(Y(a,m,["_x",q]),z++),t&&q--);f.appendChild(g)}else n&&("object"===typeof n?(C=n[1],n=n[0],x+=a.cache?";v="+n+";if(self._h!==v){self._h=v;self.innerHTML=v}":";self.innerHTML="+n,C&&(Y(a,n,["_h",q]),z++),t++):f.innerHTML=n);t?(a.u[q]=d,e[q]=f,a.F=0,t===z&&(a.A=1),Ca(t,x,q,a.cache)):
|
||||
x&&(X+=x);if(h)if(h.length)for(x=">",C=0;C<h.length;C++){C&&(x+="+");m=h[C];if(z=m["+"])m=R[z];f.appendChild(V(a,m,c+C+1,d+x,e))}else{if(z=h["+"])h=R[z];f.appendChild(V(a,h,c+1,d+">",e))}b.f&&(X+="}else "+(1<t?"self":"p["+q+"]")+".hidden=true");c||(!a.F&&X&&(a.G=Function("p","s","data","index","view",'"use strict";var self,v'+X)),c={G:a.G,F:a.F,u:a.u,node:f},c.O=a.include,c.proxy=a.proxy,c.A=a.A,S[b.n+(a.cache?"$":"")]=c);return f}
|
||||
function Y(a,b,c){a.proxy||(a.proxy={});(a.proxy[b]||(a.proxy[b]=[])).push(c)}function Ca(a,b,c,d){X=d||1<a?X+(";self=p["+c+"]"+b):X+b.replace(/self/g,"p["+c+"]")}G.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.overrideMimeType("application/json");d.open("GET",a,!1!==b);d.onload=function(){var e=this.responseText;if(e){try{var f=JSON.parse(e);xa(f);c instanceof G&&c.init(f)}catch(h){var g=h}"function"===typeof b&&b(g)}};d.send();return this};G.load=G.prototype.load;
|
||||
G.prototype.unload=function(a){a?"object"===typeof a&&(a=a.n):a=this.l;a&&(R[a]=null,T[a]=U[a]=S[a]=null,S[a+"$"]=null);return this};G.unregister=G.unload=G.prototype.unload;var Da={tap:1,change:1,click:1,dblclick:1,input:1,keydown:1,keypress:1,keyup:1,mousedown:1,mouseenter:1,mouseleave:1,mousemove:1,mouseout:1,mouseover:1,mouseup:1,mousewheel:1,touchstart:1,touchmove:1,touchend:1,reset:1,select:1,submit:1,toggle:1,blur:1,error:1,focus:1,load:1,resize:1,scroll:1},Ea,Fa=0;
|
||||
function Ga(a,b){var c={};if(!b){Ea=!0;if("string"===typeof a)if(-1!==a.indexOf("<")){var d=document.createElement("div");d.innerHTML=a;a=d.firstElementChild;c.n=a.id||"tpl_"+Fa++}else c.n=a,a=document.getElementById(a);else c.n=a.id||"tpl_"+Fa++;a.content?a=a.content.firstElementChild:"TEMPLATE"===a.tagName&&(a=a.firstElementChild)}if(d=a.tagName){if("INCLUDE"===d)return b=a.getAttribute("from"),c["+"]=b?b:Ha(a.firstChild.nodeValue),c;"DIV"!==d&&(c.t=d.toLowerCase())}else return(b=a)&&(b=b.nodeValue)&&
|
||||
(b=b.replace(/\s+/g," "))&&b.trim()&&(a=b.indexOf("{{@"),-1!==a&&(d=b.indexOf("}}",a),c.j=b.substring(a+3,d),b=b.substring(0,a)+b.substring(d+2)),b&&b.trim()&&(-1!==b.indexOf("{{#")?Z(c,"h",b.replace(/{{#/g,"{{")):Z(c,"x",b))),c.j||b&&b.trim()?c:null;var e=a.attributes;if(e.length)for(var f=0;f<e.length;f++){var g=e[f].nodeName;if("class"===g)Z(c,"c",a.className);else{var h=a.getAttribute(g);"style"===g?Z(c,"s",h):"if"===g?Z(c,"f",h):"include"===g?a.hasAttribute("for")||(g={},(c.i||(c.i=[])).push(g),
|
||||
Z(g,"+",h)):"for"===g&&"LABEL"!==d?((g=a.getAttribute("include"))&&(c["@"]=Ha(g)),Z(c,"r",h)):"max"===g?Z(c,"m",h):"js"===g?c.j=Ha(h):"key"===g?Z(c,"k",h.replace("data.","")):("bind"===g&&(h=h.split(":"),2>h.length&&h.unshift("value"),g=h[0],h="{{=="+h[1]+"}}"),Da[g.substring(2)]&&-1!==h.indexOf("{{")&&(g=g.substring(2)),Da[g]?Z(c.e||(c.e={}),g,h):Z(c.a||(c.a={}),g,h))}}a=a.childNodes;if(d=a.length){for(f=e=0;f<d;f++)if(h=Ga(a[f],1))1===d&&3===a[f].nodeType?(h.j&&(c.j=h.j),h.h&&(c.h=h.h),h.x&&(c.x=
|
||||
h.x)):(c.i||(c.i=[]))[e++]=h;1===e&&(c.i=c.i[0])}b||(c.d=Ea);return c}function Z(a,b,c){if(-1!==c.indexOf("{{")&&-1!==c.indexOf("}}")){var d=-1!==c.indexOf("{{=="),e=d||-1!==c.indexOf("{{=");Ea=!1;c=c.replace(/{{==/g,"{{").replace(/{{=/g,"{{").replace(/"{{/g,"").replace(/}}"/g,"").replace(/{{/g,"' + ").replace(/}}/g," + '");a[b]=[("'"+c+"'").replace(/'' \+ /g,"").replace(/ \+ ''/g,"").trim()];d?a[b].push(2):e&&a[b].push(1)}else a[b]=c}
|
||||
function Ha(a){return a.replace(/{{/g,"").replace(/}}/g,"").trim()};G.compile=Ga;G.array=O;G.setText=function(a,b){3!==a.nodeType&&(a._h=null,a=a.firstChild||a.appendChild(document.createTextNode(a._x=b)));a._x!==b&&(a.nodeValue=b,a._x=b);return this};G.getText=function(a){if(3!==a.nodeType&&!(a=a.firstChild))return"";var b=a._x;return b||""===b?b:a._x=a.nodeValue};G.setHTML=function(a,b){a._h!==b&&(a.innerHTML=b,a._h=b);return this};G.getHTML=function(a){var b=a._h;return b||""===b?b:a._h=a.innerHTML};G.setClass=function(a,b){a._c!==b&&(a.className=b,a._c=b);return this};
|
||||
G.getClass=function(a){var b=a._c;return b||""===b?b:a._c=a.className};G.hasClass=K;G.toggleClass=function(a,b){K(a,b)?ja(a,b):ia(a,b);return this};G.removeClass=ja;G.addClass=ia;G.setCSS=function(a,b){a._cs!==b&&((a._s||(a._s=a.style)).cssText=b,a._cs=b);return this};G.getCSS=function(a){var b=a._cs;return b||""===b?b:a._cs=a.getAttribute("style")};G.setAttribute=function(a,b,c){var d=a._a||(a._a={});d[b]!==c&&(a.setAttribute(b,c),d[b]=c);return this};G.getAttribute=ka;
|
||||
G.hasAttribute=function(a,b){a=ka(a,b);return!!a||""===a};G.removeAttribute=function(a,b){var c=a._a||(a._a={});null!==c[b]&&(a.removeAttribute(b),c[b]=null);return this};(function(){var a=this||window,b;(b=a.define)&&b.amd?b([],function(){return G}):(b=a.modules)?b.mikado=G:"object"===typeof a.exports?a.module.exports=G:a.Mikado=G})();}).call(this);
|
@@ -1,339 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Presets Scoring Comparison</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table td{
|
||||
padding: 1em 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Presets Scoring Comparison</h2>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<hr>
|
||||
<script src="../dist/flexsearch.min.js"></script>
|
||||
<script src="../demo/data/gulliver.js"></script>
|
||||
<div id="container">
|
||||
<table>
|
||||
<tr>
|
||||
<th><b>Query</b></th>
|
||||
<th>default</th>
|
||||
<th>memory</th>
|
||||
<th>speed</th>
|
||||
<th>match</th>
|
||||
<th>score</th>
|
||||
<th>balance</th>
|
||||
<th>fast</th>
|
||||
</tr>
|
||||
<tr id="test-1">
|
||||
<td style="width: 200px">"without breach of modesty"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-2">
|
||||
<td>"went softly stream"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-3">
|
||||
<td>"princes of the ambition"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-4">
|
||||
<td>"five-thousand leagues"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-5">
|
||||
<td>"i already observed"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-6">
|
||||
<td>"let a of his"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-7">
|
||||
<td>"take that to the rocks"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-8">
|
||||
<td>"bignes of splaknuk"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-9">
|
||||
<td>"matematikal musikal instruments"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-10">
|
||||
<td>"matical sical strument"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-11">
|
||||
<td>"lalkon the camberlayhn"</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<hr>
|
||||
<div style="line-height: 2em">
|
||||
<div style="display:inline-block; width:16px; height:16px; background: #f00"></div> Either no results or relevant content was not included in results.<br>
|
||||
<div style="display:inline-block; width:16px; height:16px; background: orange"></div> Most relevant results was not found in the first place.<br>
|
||||
<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>
|
||||
|
||||
var data = [];
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
var new_data = text_data;
|
||||
var tmp = '';
|
||||
|
||||
for(var i = 0; i < new_data.length; i++){
|
||||
|
||||
if(new_data[i].length > 2) {
|
||||
|
||||
tmp += new_data[i] + '. ';
|
||||
|
||||
if((tmp.length > 1000) || (i === new_data.length - 1)){
|
||||
|
||||
data.push(tmp.replace(/{[^}]*}/g, ''));
|
||||
tmp = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var flexsearch_default = new FlexSearch();
|
||||
var flexsearch_memory = new FlexSearch("memory");
|
||||
var flexsearch_speed = new FlexSearch("speed");
|
||||
var flexsearch_fast = new FlexSearch("fast");
|
||||
var flexsearch_match = new FlexSearch("match");
|
||||
var flexsearch_score = new FlexSearch("score");
|
||||
var flexsearch_balance = new FlexSearch("balance");
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
console.time('flexsearch_default');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch_default.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch_default');
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
console.time('flexsearch_memory');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch_memory.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch_memory');
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
console.time('flexsearch_speed');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch_speed.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch_speed');
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
console.time('flexsearch_match');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch_match.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch_match');
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
console.time('flexsearch_score');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch_score.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch_score');
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
console.time('flexsearch_balance');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch_balance.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch_balance');
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
console.time('flexsearch_fast');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch_fast.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch_fast');
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
do_test('test-1', 'without breach of modesty', [493]);
|
||||
do_test('test-2', 'went softly stream', [446]);
|
||||
do_test('test-3', 'princes of the ambition', [72, 408]);
|
||||
do_test('test-4', 'five-thousand leagues', [2]);
|
||||
do_test('test-5', 'i already observed', [458, 346]);
|
||||
do_test('test-6', 'let a of his', [50]);
|
||||
do_test('test-7', 'take that to the rocks', [175]);
|
||||
do_test('test-8', 'bignes of splaknuk', [146]);
|
||||
do_test('test-9', 'matematikal musikal instruments', [267]);
|
||||
do_test('test-10', 'matical sical strument', [267]);
|
||||
do_test('test-11', 'lalkon the camberlayhn', [99]);
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
function do_test(id, query, ref){
|
||||
|
||||
var nodes = document.getElementById(id).getElementsByTagName('td');
|
||||
|
||||
for(var i = 1; i < nodes.length; i++){
|
||||
|
||||
var results;
|
||||
|
||||
switch(i){
|
||||
|
||||
case 1:
|
||||
results = flexsearch_default.search(query);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
results = flexsearch_memory.search(query);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
results = flexsearch_speed.search(query);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
results = flexsearch_match.search(query);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
results = flexsearch_score.search(query);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
results = flexsearch_balance.search(query);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
results = flexsearch_fast.search(query);
|
||||
break;
|
||||
}
|
||||
|
||||
for(var a = 0; a < ref.length; a++){
|
||||
|
||||
var current = ref[a];
|
||||
|
||||
nodes[i].innerHTML = results[0] || '-';
|
||||
nodes[i].style.color = '#fff';
|
||||
|
||||
if((results[0] === current) || (results[0] === String(current))){
|
||||
|
||||
nodes[i].style.backgroundColor = '#0a0';
|
||||
break;
|
||||
}
|
||||
else if(!results.length || ((results.indexOf(current) === -1) && (results.indexOf(String(current)) === -1))){
|
||||
|
||||
if(nodes[i].style.backgroundColor !== 'orange'){
|
||||
|
||||
nodes[i].style.backgroundColor = '#f00';
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
nodes[i].style.backgroundColor = 'orange';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, 50);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"server": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"google-closure-compiler": "^20210505.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"web-servo": "^0.5.1"
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var port = process.argv[2];
|
||||
|
||||
if(!port){
|
||||
|
||||
if(/^win/.test(process.platform)){
|
||||
|
||||
port = 80;
|
||||
}
|
||||
else{
|
||||
|
||||
port = 8080;
|
||||
}
|
||||
}
|
||||
|
||||
var ws = require('web-servo');
|
||||
|
||||
ws.config({
|
||||
|
||||
"server": {
|
||||
"port": port,
|
||||
"dir": "/",
|
||||
"exitOnError": false,
|
||||
"ssl": {
|
||||
"enabled": false,
|
||||
"key": "",
|
||||
"cert": ""
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"default": "index.html"
|
||||
},
|
||||
"methods": {
|
||||
"allowed": [
|
||||
"OPTIONS",
|
||||
"GET",
|
||||
"POST",
|
||||
"HEAD",
|
||||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE"
|
||||
//"COPY",
|
||||
//"LINK",
|
||||
//"UNLINK",
|
||||
//"TRACE",
|
||||
//"CONNECT"
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
//ws.setConfigVar('server.port', port);
|
||||
ws.silent().start();
|
||||
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("Hit CTRL-C to stop the server...");
|
@@ -1,74 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
<!--
|
||||
<script src="src/config.js"></script>
|
||||
<script type="module" src="src/bundle.js"></script>
|
||||
-->
|
||||
|
||||
<script src="../../../dist/flexsearch.light.js"></script>
|
||||
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
//import { text_data } from "../../../demo/data/gulliver.js";
|
||||
//import FlexSearch from "../../../node_modules/flexsearch/src/bundle.js";
|
||||
|
||||
let lib, split = /[^a-z]+/;
|
||||
|
||||
suite["flexsearch"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new FlexSearch({
|
||||
|
||||
// encode: str => str.toLowerCase().split(split),
|
||||
// tokenize: "strict",
|
||||
// threshold: 8,
|
||||
// resolution: 9,
|
||||
// depth: 1
|
||||
|
||||
encode: str => str.toLowerCase().split(split),
|
||||
tokenize: "strict",
|
||||
threshold: 8,
|
||||
resolution: 9,
|
||||
depth: 2
|
||||
});
|
||||
|
||||
//window.test = lib;
|
||||
//window.data = text_data;
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,105 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
|
||||
<script src="src/config.js"></script>
|
||||
<script type="module" src="src/bundle.js"></script>
|
||||
<!--
|
||||
<script src="../../dist/flexsearch.light.js"></script>
|
||||
-->
|
||||
<script type="module">
|
||||
|
||||
// import { encode, rtl, tokenize } from "./src/lang/latin/default.js";
|
||||
// import { stemmer, filter, matcher } from "./src/lang/de.js";
|
||||
|
||||
const index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: ["title", "subtitle"]
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
index.add({
|
||||
id: 0,
|
||||
title: "test1",
|
||||
subtitle: "test1"
|
||||
});
|
||||
|
||||
index.add({
|
||||
id: 1,
|
||||
title: "test2",
|
||||
subtitle: "test2"
|
||||
});
|
||||
|
||||
// index.search([{
|
||||
// field: ["title", "subtitle"],
|
||||
// query: "foo",
|
||||
// bool: "or"
|
||||
// },{
|
||||
// field: ["title", "subtitle"],
|
||||
// query: "bar",
|
||||
// bool: "or"
|
||||
// },{
|
||||
// field: ["title", "subtitle"],
|
||||
// query: "test",
|
||||
// bool: "or"
|
||||
// }]);
|
||||
//
|
||||
// index.search({
|
||||
// "and": [{
|
||||
// "or": [{
|
||||
// field: "title",
|
||||
// query: "foo"
|
||||
// },{
|
||||
// field: "title",
|
||||
// query: "bar"
|
||||
// }]
|
||||
// },{
|
||||
// "not": [{
|
||||
// field: "content",
|
||||
// query: "foo"
|
||||
// },{
|
||||
// field: "content",
|
||||
// query: "bar"
|
||||
// }]
|
||||
// }]
|
||||
// });
|
||||
//
|
||||
// index.search({
|
||||
// "and": [{
|
||||
// field: "title",
|
||||
// query: ["foo", "bar"]
|
||||
// },{
|
||||
// field: "content",
|
||||
// query: ["foo", "bar"],
|
||||
// bool: "not" // applies to the query array
|
||||
// }]
|
||||
// });
|
||||
|
||||
console.log(index.search(
|
||||
[{
|
||||
field: ["title", "subtitle"],
|
||||
query: "foo",
|
||||
bool: "or"
|
||||
},{
|
||||
field: ["title", "subtitle"],
|
||||
query: "bar",
|
||||
bool: "or"
|
||||
},{
|
||||
field: ["title", "subtitle"],
|
||||
query: "test",
|
||||
bool: "or"
|
||||
}]
|
||||
));
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user