ivm-inspect
v4.0.0
Published
[](https://www.npmjs.com/package/ivm-inspect) [](https://github.com/laverdet/ivm-inspect/blob/master/LICENSE) [
isolate- An isolate created withinisolated-vmcontext- A context- return
{ formatWithOptions, inspect }
This returns an object with two named Reference instances to the built-in nodejs functions
util.formatWithOptions
and util.inspect. These
references belong to the isolate and maintain internal handles to the context. You can use these
functions in any context created within this isolate-- you do not need to call this once per
context.
async forwardConsole(context, util)
context- A contextutil- The return value ofawait create(...)
This function configures a context's console to output directly to the process's stdout and
stderr.
EXAMPLES
const ivm = require('isolated-vm');
const ivmInspect = require('ivm-inspect');
(async() => {
const isolate = new ivm.Isolate;
const context = await isolate.createContext();
const util = await ivmInspect.create(isolate, context);
await ivmInspect.forwardConsole(context, util);
await context.eval('console.log("Here is an object: %O", { foo: "bar" })');
})().catch(console.error);
Wow!

