something's rotten in the state of vermiparous
This commit is contained in:
parent
35af0d5847
commit
46d1fc128c
@ -1,5 +1,6 @@
|
||||
const KEYWORDS = ["asset", "code"];
|
||||
const MIN_KW_LENGTH = Math.min(...KEYWORDS.map((x) => x.length));
|
||||
const MAX_KW_LENGTH = Math.max(...KEYWORDS.map((x) => x.length));
|
||||
const SEMICOLON_CHARCODE = ";".charCodeAt(0);
|
||||
|
||||
function isKeyword(buffer) {
|
||||
@ -15,7 +16,6 @@ export class Vermiparous {
|
||||
static en(code, assets) {
|
||||
const ret = [];
|
||||
for (const asset of assets) {
|
||||
console.log(asset);
|
||||
ret.push(...strToBytes("asset"));
|
||||
ret.push(...strToBytes(asset.name.length.toString()));
|
||||
ret.push(...strToBytes(";"));
|
||||
@ -41,11 +41,10 @@ export class Vermiparous {
|
||||
let idx = 0;
|
||||
while (idx < bytes.length) {
|
||||
buffer.push(bytes[idx]);
|
||||
if (buffer.length < MIN_KW_LENGTH) {
|
||||
++idx;
|
||||
continue;
|
||||
if (buffer.length >= MAX_KW_LENGTH) {
|
||||
throw new Error("unreachable: something went wrong !");
|
||||
}
|
||||
if (!isKeyword(buffer)) {
|
||||
if (buffer.length < MIN_KW_LENGTH || !isKeyword(buffer)) {
|
||||
++idx;
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user