implement uneval function

Aug 6, 2014 at 5:36 PM
how is it possible to implement an uneval function?
Coordinator
Aug 6, 2014 at 7:46 PM
Perhaps you could start with JSON.stringify() and incorporate Function.prototype.toString()?
Aug 6, 2014 at 8:58 PM
Edited Aug 6, 2014 at 9:16 PM
i would like to implement it in c# as a function for js
Coordinator
Aug 7, 2014 at 4:22 PM
Hi furesoft,

You can use DynamicObject.GetDynamicMemberNames() to enumerate the properties of a script object.

However, you'll have to invoke script functions to retrieve various information such as function source code, whether an object is a function, whether one object is the same as another (for cycle detection), etc. A full uneval() implementation without the script engine's help may not be possible.

Consider also that script invocations are expensive, whereas uneval() can be implemented fully in JavaScript without any hops across the host-script boundary.

Good luck!