string representations of objects in node and the browser
JavaScript
Latest commit 8fdeb49 Mar 25, 2017 @ljharb ljharb v1.2.2
 - [Fix] differentiate -0 from 0 (#8)
 - [Robustness] cache `Object.prototype.toString`
 - [Performance] avoid recreating `lowbyte` function every time
 - [Performance] check for primitive types as early as possible.
 - [Robustness] use `typeof` instead of comparing to literal `undefined`
 - [Refactor] explicitly coerce Error objects to strings
 - [Refactor] remove unneeded `else`s
 - [Refactor] consolidate wrapping logic for boxed primitives into a function
 - [Refactor] consolidate Map/Set notations.
 - [Refactor] split up `var` declarations for debuggability
 - [Refactor] move object key gathering into separate function
 - [Tests] up to `node` `v7.7`, `v6.10`, `v5.12`, `v4.8`; improve test matrix
 - [Tests] ensure that this function remains anonymous, despite ES6 name inference.
 - [Dev Deps] update `tape`

readme.markdown

object-inspect

string representations of objects in node and the browser

testling badge

build status

example

circular

var inspect = require('object-inspect');
var obj = { a: 1, b: [3,4] };
obj.c = obj;
console.log(inspect(obj));

dom element

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, [ ... ] ] ] ] } ]

methods

var inspect = require('object-inspect')

var s = inspect(obj, opts={})

Return a string s with the string representation of obj up to a depth of opts.depth.

install

With npm do:

npm install object-inspect

license

MIT