An implementation of Common Expression Language (CEL) for ECMAScript.
Let's create a CEL environment, and define the variable name
:
import { createEnv } from "@bufbuild/cel";
import { createRegistry } from "@bufbuild/protobuf";
const env = createEnv("", createRegistry());
env.set("name", "tacocat");
That's it. The environment is ready to be used for parsing and evaluation.
To parse and evaluate an expression, call run
:
env.run(`
name.startsWith('taco')
`); // true
- @bufbuild/cel: Provides a CEL evaluator for ECMAScript.
- @bufbuild/cel-spec: Provides CEL definitions and test data from github.com/google/cel-spec.
This project is in beta.
Offered under the Apache 2 license.