We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
What's the best way to pass objects to isolate that contain Reference.
Reference
const ivm = require('isolated-vm'); const isolate = new ivm.Isolate({ memoryLimit: 128 }); const context = isolate.createContextSync(); const globalReference = context.globalReference(); const obj = { a: 1, b: 2, c: new ivm.Reference(function() {}) } globalReference.setSync('obj', new ivm.ExternalCopy(obj).copyInto()); let r = isolate.compileScriptSync('obj.a + obj.b').runSync(context); console.log(r);
This gives an error:
#<Reference> could not be cloned.
As I understand Reference can't be passed to ExternalCopy. What's the best way to transfer objects that contain functions?
ExternalCopy
The text was updated successfully, but these errors were encountered:
Right now you would have to do this manually for each object you want to pass:
global.setSync('obj', new ivm.ExternalCopy({}).copyInto()); let obj = global.getSync('obj'); obj.setSync('c', new ivm.Reference(function() {})); // ... more
You could also call a function with an array of references using apply or applySync.
apply
applySync
I'm going to keep this open because I think it may be possible to allow references in deep copies in the future.
Sorry, something went wrong.
e160f61
No branches or pull requests
What's the best way to pass objects to isolate that contain
Reference
.This gives an error:
As I understand
Reference
can't be passed toExternalCopy
. What's the best way to transfer objects that contain functions?The text was updated successfully, but these errors were encountered: