| [d24f17c] | 1 | # object-inspect <sup>[![Version Badge][2]][1]</sup>
|
|---|
| 2 |
|
|---|
| 3 | string representations of objects in node and the browser
|
|---|
| 4 |
|
|---|
| 5 | [![github actions][actions-image]][actions-url]
|
|---|
| 6 | [![coverage][codecov-image]][codecov-url]
|
|---|
| 7 | [![dependency status][5]][6]
|
|---|
| 8 | [![dev dependency status][7]][8]
|
|---|
| 9 | [![License][license-image]][license-url]
|
|---|
| 10 | [![Downloads][downloads-image]][downloads-url]
|
|---|
| 11 |
|
|---|
| 12 | [![npm badge][11]][1]
|
|---|
| 13 |
|
|---|
| 14 | # example
|
|---|
| 15 |
|
|---|
| 16 | ## circular
|
|---|
| 17 |
|
|---|
| 18 | ``` js
|
|---|
| 19 | var inspect = require('object-inspect');
|
|---|
| 20 | var obj = { a: 1, b: [3,4] };
|
|---|
| 21 | obj.c = obj;
|
|---|
| 22 | console.log(inspect(obj));
|
|---|
| 23 | ```
|
|---|
| 24 |
|
|---|
| 25 | ## dom element
|
|---|
| 26 |
|
|---|
| 27 | ``` js
|
|---|
| 28 | var inspect = require('object-inspect');
|
|---|
| 29 |
|
|---|
| 30 | var d = document.createElement('div');
|
|---|
| 31 | d.setAttribute('id', 'beep');
|
|---|
| 32 | d.innerHTML = '<b>wooo</b><i>iiiii</i>';
|
|---|
| 33 |
|
|---|
| 34 | console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ]));
|
|---|
| 35 | ```
|
|---|
| 36 |
|
|---|
| 37 | output:
|
|---|
| 38 |
|
|---|
| 39 | ```
|
|---|
| 40 | [ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [ ... ] ] ] ] } ]
|
|---|
| 41 | ```
|
|---|
| 42 |
|
|---|
| 43 | # methods
|
|---|
| 44 |
|
|---|
| 45 | ``` js
|
|---|
| 46 | var inspect = require('object-inspect')
|
|---|
| 47 | ```
|
|---|
| 48 |
|
|---|
| 49 | ## var s = inspect(obj, opts={})
|
|---|
| 50 |
|
|---|
| 51 | Return a string `s` with the string representation of `obj` up to a depth of `opts.depth`.
|
|---|
| 52 |
|
|---|
| 53 | Additional options:
|
|---|
| 54 | - `quoteStyle`: must be "single" or "double", if present. Default `'single'` for strings, `'double'` for HTML elements.
|
|---|
| 55 | - `maxStringLength`: must be `0`, a positive integer, `Infinity`, or `null`, if present. Default `Infinity`.
|
|---|
| 56 | - `customInspect`: When `true`, a custom inspect method function will be invoked (either undere the `util.inspect.custom` symbol, or the `inspect` property). When the string `'symbol'`, only the symbol method will be invoked. Default `true`.
|
|---|
| 57 | - `indent`: must be "\t", `null`, or a positive integer. Default `null`.
|
|---|
| 58 | - `numericSeparator`: must be a boolean, if present. Default `false`. If `true`, all numbers will be printed with numeric separators (eg, `1234.5678` will be printed as `'1_234.567_8'`)
|
|---|
| 59 |
|
|---|
| 60 | # install
|
|---|
| 61 |
|
|---|
| 62 | With [npm](https://npmjs.org) do:
|
|---|
| 63 |
|
|---|
| 64 | ```
|
|---|
| 65 | npm install object-inspect
|
|---|
| 66 | ```
|
|---|
| 67 |
|
|---|
| 68 | # license
|
|---|
| 69 |
|
|---|
| 70 | MIT
|
|---|
| 71 |
|
|---|
| 72 | [1]: https://npmjs.org/package/object-inspect
|
|---|
| 73 | [2]: https://versionbadg.es/inspect-js/object-inspect.svg
|
|---|
| 74 | [5]: https://david-dm.org/inspect-js/object-inspect.svg
|
|---|
| 75 | [6]: https://david-dm.org/inspect-js/object-inspect
|
|---|
| 76 | [7]: https://david-dm.org/inspect-js/object-inspect/dev-status.svg
|
|---|
| 77 | [8]: https://david-dm.org/inspect-js/object-inspect#info=devDependencies
|
|---|
| 78 | [11]: https://nodei.co/npm/object-inspect.png?downloads=true&stars=true
|
|---|
| 79 | [license-image]: https://img.shields.io/npm/l/object-inspect.svg
|
|---|
| 80 | [license-url]: LICENSE
|
|---|
| 81 | [downloads-image]: https://img.shields.io/npm/dm/object-inspect.svg
|
|---|
| 82 | [downloads-url]: https://npm-stat.com/charts.html?package=object-inspect
|
|---|
| 83 | [codecov-image]: https://codecov.io/gh/inspect-js/object-inspect/branch/main/graphs/badge.svg
|
|---|
| 84 | [codecov-url]: https://app.codecov.io/gh/inspect-js/object-inspect/
|
|---|
| 85 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/object-inspect
|
|---|
| 86 | [actions-url]: https://github.com/inspect-js/object-inspect/actions
|
|---|