npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sourceregistry/cel-lite

v1.1.1

Published

Common Expression Language Lite.

Readme

@sourceregistry/cel-lite

CEL-lite is a small, safe, dependency-free expression language inspired by Google’s Common Expression Language (CEL), designed specifically for identity, policy, and mapping use-cases.

It is not a full CEL implementation — by design. CEL-lite focuses on determinism, auditability, and sandbox safety.

✨ Features

  • ✅ Expression evaluation (no side effects)
  • ✅ Safe property access (prototype-poisoning protected)
  • ✅ Ternary operator (condition ? a : b)
  • ✅ Logical operators (&&, ||, !)
  • ✅ Comparison operators (==, !=, <, <=, >, >=)
  • in operator (arrays, strings, objects)
  • ✅ Function allow-list (no arbitrary calls)
  • ✅ Built-in explain / trace mode
  • ✅ Hard limits (depth, size, complexity)
  • ✅ Zero runtime dependencies
  • ✅ Node & browser compatible

Designed for:

  • Identity Provider attribute mapping (SAML / OIDC)
  • Group assignment rules
  • Policy preconditions
  • Safe multi-tenant configuration

❌ Explicitly NOT included

CEL-lite intentionally does not support:

  • Loops or comprehensions
  • User-defined functions
  • Mutation or side effects
  • Access to globals, IO, network, or time
  • Arbitrary JavaScript execution

This keeps it safe to evaluate on authentication paths.

📦 Installation

npm install @sourceregistry/cel-lite

🚀 Basic usage

import { compileCel } from "@sourceregistry/cel-lite";

const expr = compileCel("has(user.email) ? lower(user.email) : null");

const result = expr.eval({
  user: { email: "[email protected]" }
});

console.log(result);
// → "[email protected]"

🧠 Supported syntax

Literals

true, false, null
123, -1, 3.14
"string", 'string'
[1, 2, "a"]

Operators

==  !=  <  <=  >  >=
&&  ||  !
+   in
?: (ternary)

Property access

user.email
saml.attributes["urn:mace:dir:attribute-def:mail"][0]

Missing properties resolve to undefined (safe).

🧩 Built-in functions

| Function | Description | | -------------------------- | ----------------------------- | | has(x) / exists(x) | Checks defined / non-empty | | size(x) | Length of array/string/object | | first(x) | First element or value | | lower(s) / upper(s) | String casing | | trim(s) | Trim whitespace | | contains(a, b) | Array or string containment | | containsAny(arr, values) | Any value matches | | startsWith(s, prefix) | String prefix | | endsWith(s, suffix) | String suffix | | matches(s, regex) | Regex test | | regexReplace(s, r, repl) | Regex replace | | coalesce(a, b, ...) | First non-empty value | | join(arr, sep) | Join array | | split(s, sep) | Split string |

Only allow-listed functions are callable.

🔍 Explain / trace mode

CEL-lite can explain how a result was produced.

const program = compileCel("size(groups) > 0 ? groups[0] : null");

const explained = program.explain({
  groups: ["Students", "Staff"]
});

console.log(explained.result);
// → "Students"

console.log(explained.trace);
// → evaluation steps (for UI / audit)

Useful for:

  • admin UIs
  • debugging mappers
  • audit logging

🛡️ Safety guarantees

CEL-lite enforces:

  • maximum expression length
  • maximum AST nodes
  • maximum call depth
  • maximum trace entries
  • blocked access to __proto__, constructor, prototype

It is safe to run on:

  • login flows
  • onboarding pipelines
  • multi-tenant systems

📚 Related packages

  • @sourceregistry/monaco-cel-lite Monaco Editor language + IntelliSense for CEL-lite

📄 License

Apache-2.0