Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 9bb45cf

Browse files
committed
Cleaner eval
1 parent cad34d2 commit 9bb45cf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

composer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function validate(options) {
4646
*/
4747
function encode({ name, action }) {
4848
if (action.exec.kind !== 'composition') return { name, action }
49-
const code = `${conductor}(${JSON.stringify(action.exec.composition)})\n` // invoke conductor on composition
49+
const code = `${conductor}(eval,${JSON.stringify(action.exec.composition)})\n` // invoke conductor on composition
5050
return { name, action: { exec: { kind: 'nodejs:default', code }, annotations: [{ key: 'conductor', value: action.exec.composition }] } }
5151
}
5252

@@ -303,9 +303,9 @@ module.exports = new Composer()
303303

304304
// conductor action
305305

306-
const conductor = `const __eval__ = main => eval(main)\nconst main = (${uglify.minify(`${init}`).code})`
306+
const conductor = `const main=(${uglify.minify(`${init}`).code})`
307307

308-
function init(composition) {
308+
function init(__eval__, composition) {
309309
function chain(front, back) {
310310
front.slice(-1)[0].next = 1
311311
front.push(...back)
@@ -442,7 +442,7 @@ function init(composition) {
442442

443443
// collapse stack for invocation
444444
const env = stack.reduceRight((acc, cur) => typeof cur.let === 'object' ? Object.assign(acc, cur.let) : acc, {})
445-
let main = '(function main(){try{'
445+
let main = '(function(){try{'
446446
for (const name in env) main += `var ${name}=arguments[1]['${name}'];`
447447
main += `return eval((${f}))(arguments[0])}finally{`
448448
for (const name in env) main += `arguments[1]['${name}']=${name};`

0 commit comments

Comments
 (0)