Crystal bindings for the Duktape JavaScript engine, enabling JavaScript evaluation and interoperability within Crystal applications.
Duktape.cr is a Crystal language binding for the Duktape JavaScript engine, allowing developers to evaluate and execute JavaScript code within Crystal applications. It solves the need for embedding JavaScript runtime capabilities in Crystal projects, enabling scripting, plugin systems, and dynamic code evaluation. The library provides both low-level Duktape API access and higher-level abstractions for safer and easier integration.
Crystal developers who need to integrate JavaScript evaluation, scripting, or plugin systems into their applications, particularly those working on tools requiring embedded JavaScript runtime or interoperability between Crystal and JavaScript.
Developers choose Duktape.cr for its comprehensive Duktape API coverage, sandboxed execution for security, and seamless integration with Crystal's ecosystem. Its unique selling point is the combination of low-level control with high-level safety features like timeouts and isolated contexts.
Evaluate JavaScript from Crystal!
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides isolated Sandbox contexts that restrict access to internal Duktape properties, making it safe for executing untrusted JavaScript code directly from Crystal, as emphasized in the README for security-critical use cases.
Allows setting millisecond limits on sandbox execution to prevent infinite loops, a crucial feature highlighted in the README for handling user-provided or untrusted scripts reliably.
Implements the majority of the native Duktape API, enabling fine-grained control over JavaScript execution and context manipulation, as noted in the README for advanced use cases.
Offers both raising and non-raising eval methods (eval! and eval) with error handling, plus a higher-level Runtime class similar to ExecJS for easier value retrieval, providing versatility for different integration needs.
The ability to call Crystal functions from JavaScript is marked experimental in the README, with warnings that syntax and functionality may change dramatically between releases, making it risky for production use.
Direct use of the Duktape API requires manual stack manipulation (e.g., push_global_object, get_prop), which the README shows can be error-prone and has a steeper learning curve compared to higher-level wrappers.
Duktape is a lightweight engine that may lack support for modern JavaScript features or have performance trade-offs compared to engines like V8, limiting its suitability for feature-rich or performance-sensitive applications.