{"library":"punyexpr","title":"punyexpr","description":"A minimalist (5144 bytes), zero-dependency expression compiler and evaluator for JavaScript. Current stable version is 1.3.1, released on an ongoing basis with fixes and features. It compiles expression strings into reusable functions that evaluate against a context object, supporting arithmetic, string operations, member access, function calls, and ternary expressions. It does NOT support bitwise, async, coalesce, new, this, or object literals. Regular expressions are disabled by default for security (ReDoS) and can be enabled via an option. The library includes TypeScript type definitions and is compliant with Content Security Policy (CSP). It is a safer alternative to eval() or new Function() for dynamic expressions.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install punyexpr"],"cli":null},"imports":["import { punyexpr } from 'punyexpr'","import { compile } from 'punyexpr'","import { propertyOf } from 'punyexpr'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { punyexpr } from 'punyexpr';\n\n// Compile an expression\nconst inc = punyexpr('value + 1');\n\n// Evaluate with a context\nconsole.log(inc({ value: 1 })); // 2\n\n// Compile with options (regex disabled by default)\nconst withRegex = punyexpr('name.match(/^A/i)', { regex: true });\nconsole.log(withRegex({ name: 'Alice' })); // ['Alice']\n\n// Use propertyOf hook (since v1.3.0)\nconst ctx = {\n  [Symbol.for('punyexpr.propertyOf')]: (value, prop) =>\n    value === undefined ? undefined : value[prop]\n};\nconsole.log(punyexpr('a.b')(ctx)); // undefined (a is undefined)","lang":"typescript","description":"Shows basic usage: compile and evaluate, custom regex option, and the propertyOf hook.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}