javascripttypescriptdenoinspect

Equivalent of `util.inspect` in Deno


Does Deno have a utility function that dumps a Object or primitive to a string like Node.js util.inspect?

For example in Node.js I create an json object and want to dump out its contents in Node:

> m = {k1:'v1', k2:'v2'}
{ k1: 'v1', k2: 'v2' }
> util.inspect(m)
'{ k1: \'v1\', k2: \'v2\' }'

Solution

  • Deno's equivalent of Node's util.inspect is Deno.inspect.

    For example in the deno REPL:

    > m = {k1:'v1', k2:'v2'}
    { k1: "v1", k2: "v2" }
    > Deno.inspect(m)
    { k1: "v1", k2: "v2" }