blob: 61ec8e05d096a83a33b6d2a73a70070ec7805b62 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001# object-inspect
2
3string representations of objects in node and the browser
4
5[![build status](https://secure.travis-ci.com/inspect-js/object-inspect.png)](https://travis-ci.com/inspect-js/object-inspect)
6
7# example
8
9## circular
10
11``` js
12var inspect = require('object-inspect');
13var obj = { a: 1, b: [3,4] };
14obj.c = obj;
15console.log(inspect(obj));
16```
17
18## dom element
19
20``` js
21var inspect = require('object-inspect');
22
23var d = document.createElement('div');
24d.setAttribute('id', 'beep');
25d.innerHTML = '<b>wooo</b><i>iiiii</i>';
26
27console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ]));
28```
29
30output:
31
32```
33[ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [ ... ] ] ] ] } ]
34```
35
36# methods
37
38``` js
39var inspect = require('object-inspect')
40```
41
42## var s = inspect(obj, opts={})
43
44Return a string `s` with the string representation of `obj` up to a depth of `opts.depth`.
45
46Additional options:
47 - `quoteStyle`: must be "single" or "double", if present. Default `'single'` for strings, `'double'` for HTML elements.
48 - `maxStringLength`: must be `0`, a positive integer, `Infinity`, or `null`, if present. Default `Infinity`.
49 - `customInspect`: When `true`, a custom inspect method function will be invoked. Default `true`.
50 - `indent`: must be "\t", `null`, or a positive integer. Default `null`.
51
52# install
53
54With [npm](https://npmjs.org) do:
55
56```
57npm install object-inspect
58```
59
60# license
61
62MIT