object-inspect

string representations of objects in node and the browser

MIT 39 个版本
安装
npm install object-inspect
yarn add object-inspect
pnpm add object-inspect
bun add object-inspect
README

object-inspect Version Badge

string representations of objects in node and the browser

github actions coverage License Downloads

npm badge

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.

Additional options:

  • quoteStyle: must be "single" or "double", if present. Default 'single' for strings, 'double' for HTML elements.
  • maxStringLength: must be 0, a positive integer, Infinity, or null, if present. Default Infinity.
  • 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.
  • indent: must be "\t", null, or a positive integer. Default null.
  • 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')

install

With npm do:

npm install object-inspect

license

MIT

版本列表
1.13.4 2025-02-05
1.13.3 2024-11-09
1.13.2 2024-06-22
1.13.1 2023-10-19
1.13.0 2023-10-15
1.12.3 2023-01-12
1.12.2 2022-05-26
1.12.1 2022-05-21
1.12.0 2021-12-18
1.11.1 2021-12-06
1.11.0 2021-07-12
1.10.3 2021-05-08
1.10.2 2021-04-18
1.10.1 2021-04-17
1.10.0 2021-04-17
1.9.0 2020-12-01
1.8.0 2020-06-19
1.7.0 2019-11-11
1.6.0 2018-05-02
1.5.0 2017-12-26
1.4.1 2017-12-20
1.4.0 2017-10-25
1.3.0 2017-07-31
1.2.2 2017-03-25
1.2.1 2016-04-09
1.2.0 2016-04-09
1.1.0 2015-12-15
1.0.2 2015-08-07
1.0.1 2015-07-19
1.0.0 2014-08-05
0.4.0 2014-03-22
0.3.1 2014-03-05
0.3.0 2014-03-05
0.2.0 2014-03-05
0.1.3 2013-07-26
0.1.2 2013-07-26
0.1.1 2013-07-26
0.1.0 2013-07-26
0.0.0 2013-07-26