string representations of objects in node and the browser
var inspect = require('object-inspect');
var obj = { a: 1, b: [3,4] };
obj.c = obj;
console.log(inspect(obj));var inspect = require('object-inspect');
var d = document.createElement('div');
d.setAttribute('id', 'beep');
d.innerHTML = '<b>wooo</b><i>iiiii</i>';
console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ]));output:
[ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [ ... ] ] ] ] } ]
var inspect = require('object-inspect')Return a string s with the string representation of obj up to a depth of opts.depth.
Additional options:
quoteStyle: must be "single" or "double", if present. Default'single'for strings,'double'for HTML elements.maxStringLength: must be0, a positive integer,Infinity, ornull, if present. DefaultInfinity.maxCollectionLength: must be0, a positive integer,Infinity, ornull, if present. DefaultInfinity. The maximum number of elements to include when formatting Arrays, TypedArrays, Maps, and Sets; the remaining elements are summarized as... N more items.customInspect: Whentrue, a custom inspect method function will be invoked (either undere theutil.inspect.customsymbol, or theinspectproperty). When the string'symbol', only the symbol method will be invoked. Defaulttrue.indent: must be "\t",null, or a positive integer. Defaultnull.numericSeparator: must be a boolean, if present. Defaultfalse. Iftrue, all numbers will be printed with numeric separators (eg,1234.5678will be printed as'1_234.567_8')multilineStrings: must be a boolean, if present. Defaultfalse. Iftrue, newlines (\n) in strings will be printed as actual line breaks, inside the quotes, rather than as\n. Other control characters, including\r, are still escaped.breakLength: must be0, a positive integer, orInfinity, if present. When present, line breaks are decided the same way as node'sutil.inspectwith the samebreakLength: entries are put on one line when they fit withinbreakLengthcharacters (counting indentation) and fewer than 3 levels of objects are nested below, and arrays with more than 6 entries are grouped into aligned columns. Usesindentif provided, otherwise 2 spaces. When absent, output is unchanged.
With npm do:
npm install object-inspect
MIT
