synchronous-autocomplete
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -1,2 +0,2 @@ | ||
Copyright (c) 2019, Jannis R | ||
Copyright (c) 2022, Jannis R | ||
@@ -3,0 +3,0 @@ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. |
{ | ||
"name": "synchronous-autocomplete", | ||
"description": "Fast, simple autocompletion.", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"main": "index.js", | ||
@@ -40,3 +40,3 @@ "files": [ | ||
"tap-min": "^1.2.2", | ||
"tape": "^4.8.0" | ||
"tape": "^5.0.0" | ||
}, | ||
@@ -43,0 +43,0 @@ "scripts": { |
@@ -8,4 +8,4 @@ # synchronous-autocomplete | ||
![ISC-licensed](https://img.shields.io/github/license/derhuerst/synchronous-autocomplete.svg) | ||
[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](https://gitter.im/derhuerst) | ||
[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst) | ||
[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst) | ||
[![chat with me on Twitter](https://img.shields.io/badge/chat%20with%20me-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst) | ||
@@ -12,0 +12,0 @@ |
@@ -39,7 +39,2 @@ // This file is auto generated by the protocol-buffers compiler | ||
function defineToken () { | ||
var enc = [ | ||
encodings.string, | ||
encodings.int32 | ||
] | ||
Token.encodingLength = encodingLength | ||
@@ -52,3 +47,3 @@ Token.encode = encode | ||
if (defined(obj.name)) { | ||
var len = enc[0].encodingLength(obj.name) | ||
var len = encodings.string.encodingLength(obj.name) | ||
length += 1 + len | ||
@@ -59,3 +54,3 @@ } | ||
if (!defined(obj.ids[i])) continue | ||
var len = enc[1].encodingLength(obj.ids[i]) | ||
var len = encodings.int32.encodingLength(obj.ids[i]) | ||
length += 1 + len | ||
@@ -73,4 +68,4 @@ } | ||
buf[offset++] = 10 | ||
enc[0].encode(obj.name, buf, offset) | ||
offset += enc[0].encode.bytes | ||
encodings.string.encode(obj.name, buf, offset) | ||
offset += encodings.string.encode.bytes | ||
} | ||
@@ -81,4 +76,4 @@ if (defined(obj.ids)) { | ||
buf[offset++] = 16 | ||
enc[1].encode(obj.ids[i], buf, offset) | ||
offset += enc[1].encode.bytes | ||
encodings.int32.encode(obj.ids[i], buf, offset) | ||
offset += encodings.int32.encode.bytes | ||
} | ||
@@ -109,8 +104,8 @@ } | ||
case 1: | ||
obj.name = enc[0].decode(buf, offset) | ||
offset += enc[0].decode.bytes | ||
obj.name = encodings.string.decode(buf, offset) | ||
offset += encodings.string.decode.bytes | ||
break | ||
case 2: | ||
obj.ids.push(enc[1].decode(buf, offset)) | ||
offset += enc[1].decode.bytes | ||
obj.ids.push(encodings.int32.decode(buf, offset)) | ||
offset += encodings.int32.decode.bytes | ||
break | ||
@@ -125,7 +120,2 @@ default: | ||
function defineScore () { | ||
var enc = [ | ||
encodings.string, | ||
encodings.float | ||
] | ||
Score.encodingLength = encodingLength | ||
@@ -138,7 +128,7 @@ Score.encode = encode | ||
if (defined(obj.token)) { | ||
var len = enc[0].encodingLength(obj.token) | ||
var len = encodings.string.encodingLength(obj.token) | ||
length += 1 + len | ||
} | ||
if (defined(obj.score)) { | ||
var len = enc[1].encodingLength(obj.score) | ||
var len = encodings.float.encodingLength(obj.score) | ||
length += 1 + len | ||
@@ -155,9 +145,9 @@ } | ||
buf[offset++] = 10 | ||
enc[0].encode(obj.token, buf, offset) | ||
offset += enc[0].encode.bytes | ||
encodings.string.encode(obj.token, buf, offset) | ||
offset += encodings.string.encode.bytes | ||
} | ||
if (defined(obj.score)) { | ||
buf[offset++] = 21 | ||
enc[1].encode(obj.score, buf, offset) | ||
offset += enc[1].encode.bytes | ||
encodings.float.encode(obj.score, buf, offset) | ||
offset += encodings.float.encode.bytes | ||
} | ||
@@ -187,8 +177,8 @@ encode.bytes = offset - oldOffset | ||
case 1: | ||
obj.token = enc[0].decode(buf, offset) | ||
offset += enc[0].decode.bytes | ||
obj.token = encodings.string.decode(buf, offset) | ||
offset += encodings.string.decode.bytes | ||
break | ||
case 2: | ||
obj.score = enc[1].decode(buf, offset) | ||
offset += enc[1].decode.bytes | ||
obj.score = encodings.float.decode(buf, offset) | ||
offset += encodings.float.decode.bytes | ||
break | ||
@@ -203,9 +193,2 @@ default: | ||
function defineIndex () { | ||
var enc = [ | ||
Token, | ||
encodings.int32, | ||
Score, | ||
encodings.string | ||
] | ||
Index.encodingLength = encodingLength | ||
@@ -220,3 +203,3 @@ Index.encode = encode | ||
if (!defined(obj.tokens[i])) continue | ||
var len = enc[0].encodingLength(obj.tokens[i]) | ||
var len = Token.encodingLength(obj.tokens[i]) | ||
length += varint.encodingLength(len) | ||
@@ -229,3 +212,3 @@ length += 1 + len | ||
if (!defined(obj.weights[i])) continue | ||
var len = enc[1].encodingLength(obj.weights[i]) | ||
var len = encodings.int32.encodingLength(obj.weights[i]) | ||
length += 1 + len | ||
@@ -237,3 +220,3 @@ } | ||
if (!defined(obj.nr_of_tokens[i])) continue | ||
var len = enc[1].encodingLength(obj.nr_of_tokens[i]) | ||
var len = encodings.int32.encodingLength(obj.nr_of_tokens[i]) | ||
length += 1 + len | ||
@@ -245,3 +228,3 @@ } | ||
if (!defined(obj.scores[i])) continue | ||
var len = enc[2].encodingLength(obj.scores[i]) | ||
var len = Score.encodingLength(obj.scores[i]) | ||
length += varint.encodingLength(len) | ||
@@ -254,3 +237,3 @@ length += 1 + len | ||
if (!defined(obj.original_ids[i])) continue | ||
var len = enc[3].encodingLength(obj.original_ids[i]) | ||
var len = encodings.string.encodingLength(obj.original_ids[i]) | ||
length += 1 + len | ||
@@ -270,6 +253,6 @@ } | ||
buf[offset++] = 10 | ||
varint.encode(enc[0].encodingLength(obj.tokens[i]), buf, offset) | ||
varint.encode(Token.encodingLength(obj.tokens[i]), buf, offset) | ||
offset += varint.encode.bytes | ||
enc[0].encode(obj.tokens[i], buf, offset) | ||
offset += enc[0].encode.bytes | ||
Token.encode(obj.tokens[i], buf, offset) | ||
offset += Token.encode.bytes | ||
} | ||
@@ -281,4 +264,4 @@ } | ||
buf[offset++] = 16 | ||
enc[1].encode(obj.weights[i], buf, offset) | ||
offset += enc[1].encode.bytes | ||
encodings.int32.encode(obj.weights[i], buf, offset) | ||
offset += encodings.int32.encode.bytes | ||
} | ||
@@ -290,4 +273,4 @@ } | ||
buf[offset++] = 24 | ||
enc[1].encode(obj.nr_of_tokens[i], buf, offset) | ||
offset += enc[1].encode.bytes | ||
encodings.int32.encode(obj.nr_of_tokens[i], buf, offset) | ||
offset += encodings.int32.encode.bytes | ||
} | ||
@@ -299,6 +282,6 @@ } | ||
buf[offset++] = 34 | ||
varint.encode(enc[2].encodingLength(obj.scores[i]), buf, offset) | ||
varint.encode(Score.encodingLength(obj.scores[i]), buf, offset) | ||
offset += varint.encode.bytes | ||
enc[2].encode(obj.scores[i], buf, offset) | ||
offset += enc[2].encode.bytes | ||
Score.encode(obj.scores[i], buf, offset) | ||
offset += Score.encode.bytes | ||
} | ||
@@ -310,4 +293,4 @@ } | ||
buf[offset++] = 42 | ||
enc[3].encode(obj.original_ids[i], buf, offset) | ||
offset += enc[3].encode.bytes | ||
encodings.string.encode(obj.original_ids[i], buf, offset) | ||
offset += encodings.string.encode.bytes | ||
} | ||
@@ -343,12 +326,12 @@ } | ||
offset += varint.decode.bytes | ||
obj.tokens.push(enc[0].decode(buf, offset, offset + len)) | ||
offset += enc[0].decode.bytes | ||
obj.tokens.push(Token.decode(buf, offset, offset + len)) | ||
offset += Token.decode.bytes | ||
break | ||
case 2: | ||
obj.weights.push(enc[1].decode(buf, offset)) | ||
offset += enc[1].decode.bytes | ||
obj.weights.push(encodings.int32.decode(buf, offset)) | ||
offset += encodings.int32.decode.bytes | ||
break | ||
case 3: | ||
obj.nr_of_tokens.push(enc[1].decode(buf, offset)) | ||
offset += enc[1].decode.bytes | ||
obj.nr_of_tokens.push(encodings.int32.decode(buf, offset)) | ||
offset += encodings.int32.decode.bytes | ||
break | ||
@@ -358,8 +341,8 @@ case 4: | ||
offset += varint.decode.bytes | ||
obj.scores.push(enc[2].decode(buf, offset, offset + len)) | ||
offset += enc[2].decode.bytes | ||
obj.scores.push(Score.decode(buf, offset, offset + len)) | ||
offset += Score.decode.bytes | ||
break | ||
case 5: | ||
obj.original_ids.push(enc[3].decode(buf, offset)) | ||
offset += enc[3].decode.bytes | ||
obj.original_ids.push(encodings.string.decode(buf, offset)) | ||
offset += encodings.string.decode.bytes | ||
break | ||
@@ -366,0 +349,0 @@ default: |
28483
680