@apistudio/apim-cli
Version:
CLI for API Management Products
26 lines (23 loc) • 812 B
HTML
<html>
<head>
<meta charset="utf-8" />
<title>Filtrex Test</title>
</head>
<body style="background: red">
<script src="../dist/browser/filtrex.min.js"></script>
<script>
const expr = "(1 in (1, 2, 3), 1 + one(), PI)";
const extraFunctions = { one: () => 1 };
const f = filtrex.compileExpression(expr, { extraFunctions });
const result = f(Math);
if (!Array.isArray(result)) throw "Not an array";
if (result.length !== 3) throw "Incorrect length";
if (result[0] !== 1) throw "Should begin with 1";
if (result[1] !== 2) throw "Should contain 2";
if (result[2] !== Math.PI) throw "Should end with pi";
document.body.style.background = "green";
console.log("result: ", result);
</script>
</body>
</html>