Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
duktape-eval
Advanced tools
A safe **eval** library based on WebAssembly build of [Duktape](https://duktape.org/).
A safe eval library based on WebAssembly build of Duktape.
In node:
const { getInstance } = require('duktape-eval')
getInstance().then(mod => {
console.log(mod.eval('1+1')) // 2
const add = mod.newFunction(['a', 'b'], 'return a+b')
console.log(add(1, 2)) // 3
})
In browser:
<script src="https://cdn.jsdelivr.net/gh/maple3142/duktape-eval/duktapeEval.js"></script>
<script>
duktapeEval.getInstance().then(mod => {
console.log(mod.eval('1+1')) // 2
const add = mod.newFunction(['a', 'b'], 'return a+b')
console.log(add(1, 2)) // 3
})
</script>
duktapeEval.getInstance(): Promise<Instance>
Returns a Promise to resolve the module instance.
Instance
Instance#eval(code: string): any
Evaluate JavaScript string in Duktape engine, and return a value.
Instance#newFunction(argnames: string[], body: string): (...any) => any
Create a function like new Function
to be called afterward.
Whatever Duktape can run. Basically ES5 syntax and some ES6, ES7 capabilities.
JSON.stringify
is your friend.
Just like normal eval
, for example var a={};a.prop=1;a
will return { prop: 1 }
. But keep in mind, only JSON serializable data can be returned.
Script size: 348kB Gzipped size: 154kB
FAQs
A safe **eval** library based on WebAssembly build of [Duktape](https://duktape.org/).
The npm package duktape-eval receives a total of 11 weekly downloads. As such, duktape-eval popularity was classified as not popular.
We found that duktape-eval demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.