I want to have the same object as JSON
in my embedded v8. So I can have several static methods and use it like this:
MyGlobalObject.methodOne();
MyGlobalObject.methodTwo();
I know how to use Function template for the global function but I can not find any example for global object with static methods.
In short: use
ObjectTemplate
s, just like for the global object you're setting up.There are several examples of this in V8's d8 shell. The relevant excerpts are:
That snippet results in a function
d8.file.read(...)
being available.