Constantinople Constant Expression Evaluator
JSON →Constantinople is a JavaScript utility package, currently at stable version 4.0.1, designed to determine if a given JavaScript expression evaluates to a constant. It parses the expression into an Abstract Syntax Tree (AST) using Babylon (now part of Babel's parser) to analyze its predictability. The library prioritizes safety, conservatively returning `false` if there's any uncertainty, ensuring reliability for build tools and static analysis where incorrect constant detection could cause issues. It also provides a `toConstant` function to safely evaluate expressions identified as constant, throwing an error if the expression is not constant. The package ships with TypeScript type definitions, enhancing developer experience for TypeScript users.
Traffic · last 30 days ↑40% vs prev 7d
top countries 🇨🇦 Canada · 🇸🇬 Singapore · 🇺🇸 United States · 🇩🇪 Germany · 🇫🇷 France