Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use destructuring? #261

Closed
F1LT3R opened this issue Dec 21, 2023 · 2 comments
Closed

Can we use destructuring? #261

F1LT3R opened this issue Dec 21, 2023 · 2 comments

Comments

@F1LT3R
Copy link

F1LT3R commented Dec 21, 2023

I'm not sure if I'm doing something wrong, or whether this is not supported.

I expected the value of a inside resolve to be the location.

import interpreter from '/lib/shadow/vendor/interpreter.mjs'

window.log = function (result) {
	console.log({result})
}

var myCode = `
    function resolve ({a}) {
        return a;
    };
    log(resolve({a: url}));

`
var initFunc = function (interpreter, globalObject) {
	interpreter.setProperty(globalObject, 'url', String(location))

	var wrapper = function log(text) {
		return window.log(text)
	}
	interpreter.setProperty(globalObject, 'log', interpreter.createNativeFunction(wrapper))
}
var myInterpreter = new interpreter(myCode, initFunc)
myInterpreter.run()

image

@NeilFraser
Copy link
Owner

Destructuring is a feature of ES6: http://es6-features.org/#ParameterContextMatching

JS-Interpreter is ES5 only: #186

@NeilFraser NeilFraser closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2023
@F1LT3R
Copy link
Author

F1LT3R commented Dec 21, 2023

Got it. Thanks Neil.

Congrats on the great code here and all the work that went into it.

Very impressive!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants