isolated-vm icon indicating copy to clipboard operation
isolated-vm copied to clipboard

Add more examples

Open 7y1o opened this issue 3 years ago • 9 comments

Good afternoon!

Please, could you add at least one example to the README file?

Specifically, I would like to see how to make a two-way function between the main and isolated environments, where an instance of the class is fed to the isolated environment, and the same instance is returned to the main process, but with changed parameters.

Such a funny implementation is needed to be sure that the class fields have changed.

Thank you in advance for your answer!

7y1o avatar Aug 11 '21 16:08 7y1o

I second this, having trouble finding any examples and the documentation, while it technically covers everything, is limited in how to piece it all together. I'm switching out from node:VM for security and just trying to figure out how to do it all the isolated-vm way.

Thanks!

curtisburns avatar Jul 19 '22 11:07 curtisburns

Yes please. I have been stuck for a while trying to properly load modules in the IVMs, an example of that would be so great. Also maybe an explanation of why IVM doesn't implement it out of the box. Is it just not implemented or there is some underlying problem that I'm not aware of that prevents it entirely.

tiagozortea avatar Mar 10 '23 18:03 tiagozortea

What kind of example(s) would you love to see?

idleman avatar Mar 10 '23 23:03 idleman

For example, how to transfer complex nested objects in and out from an isolate

marcoancona avatar Jul 04 '23 19:07 marcoancona

You would use ExternalCopy for that https://github.com/laverdet/isolated-vm#class-externalcopy-transferable

laverdet avatar Jul 04 '23 19:07 laverdet

Thanks, @laverdet, I was guessing that, but can't figure out how exactly, especially to bring values out. Some examples would be very useful here.

marcoancona avatar Jul 04 '23 20:07 marcoancona

You can also use copy:true https://github.com/laverdet/isolated-vm#transferoptions

laverdet avatar Jul 04 '23 20:07 laverdet

Oh, totally missed that flag. This worked like a charm, thanks! Again, some (even trivial) examples could help people new to isolated-vm a lot in my opinion!

marcoancona avatar Jul 04 '23 20:07 marcoancona

I'm new to this library today (vm2 discontinued) and it is really hard to find just a trivial example. Some variables in, run code, get result out. Use some modules inside.

asokani avatar Jul 11 '23 14:07 asokani