Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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 4 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.