@bonniernews/local-esi
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -13,2 +13,3 @@ "use strict"; | ||
function assign(value, context) { | ||
if (value === "true" || value === "false") return value; | ||
return evaluate(parse(value), context); | ||
@@ -15,0 +16,0 @@ } |
@@ -103,8 +103,8 @@ /* eslint-disable camelcase */ | ||
if (node.operator === "==") return left === right; | ||
if (node.operator === "!=") return left !== right; | ||
if (node.operator === ">=") return left >= right; | ||
if (node.operator === "<=") return left <= right; | ||
if (node.operator === "<") return left < right; | ||
if (node.operator === ">") return left > right; | ||
if (node.operator === "==") return left === castRight(left, right); | ||
if (node.operator === "!=") return left !== castRight(left, right); | ||
if (node.operator === ">=") return left >= castRight(left, right); | ||
if (node.operator === "<=") return left <= castRight(left, right); | ||
if (node.operator === "<") return left < castRight(left, right); | ||
if (node.operator === ">") return left > castRight(left, right); | ||
if (node.operator === "+") return left + right; | ||
@@ -189,1 +189,15 @@ if (node.operator === "-") return left - right; | ||
}; | ||
function castRight(left, right) { | ||
switch (typeof left) { | ||
case "string": | ||
return `${right}`; | ||
case "boolean": | ||
if (right === "false") return false; | ||
if (right === "true") return true; | ||
break; | ||
case "number": | ||
return Number(right); | ||
} | ||
return right; | ||
} |
@@ -25,2 +25,3 @@ /* eslint-disable prefer-template */ | ||
BLOCK, | ||
BOOLEAN, | ||
ENDMARK, | ||
@@ -224,2 +225,12 @@ FUNCTION, | ||
if (token.cargo === "true") { | ||
token.type = BOOLEAN; | ||
return next(); | ||
} | ||
if (token.cargo === "false") { | ||
token.type = BOOLEAN; | ||
return next(); | ||
} | ||
if (keywords.indexOf(token.cargo) === -1) { | ||
@@ -291,2 +302,8 @@ token.abort("Unknown keyword", token.cargo); | ||
} | ||
case BOOLEAN: { | ||
return { | ||
type: LITERAL, | ||
value: this.cargo === "true", | ||
}; | ||
} | ||
case IDENTIFIER: { | ||
@@ -293,0 +310,0 @@ return { |
@@ -7,2 +7,3 @@ "use strict"; | ||
BLOCK: "BlockStatement", | ||
BOOLEAN: "Boolean", | ||
ENDMARK: "EOL", | ||
@@ -9,0 +10,0 @@ EXPRESSION: "Expression", |
{ | ||
"name": "@bonniernews/local-esi", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Local Edge Side Includes parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
45967
1483
0