用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.9 KiB

6 months ago
  1. # object-inspect <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. string representations of objects in node and the browser
  3. [![github actions][actions-image]][actions-url]
  4. [![coverage][codecov-image]][codecov-url]
  5. [![License][license-image]][license-url]
  6. [![Downloads][downloads-image]][downloads-url]
  7. [![npm badge][npm-badge-png]][package-url]
  8. # example
  9. ## circular
  10. ``` js
  11. var inspect = require('object-inspect');
  12. var obj = { a: 1, b: [3,4] };
  13. obj.c = obj;
  14. console.log(inspect(obj));
  15. ```
  16. ## dom element
  17. ``` js
  18. var inspect = require('object-inspect');
  19. var d = document.createElement('div');
  20. d.setAttribute('id', 'beep');
  21. d.innerHTML = '<b>wooo</b><i>iiiii</i>';
  22. console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ]));
  23. ```
  24. output:
  25. ```
  26. [ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [ ... ] ] ] ] } ]
  27. ```
  28. # methods
  29. ``` js
  30. var inspect = require('object-inspect')
  31. ```
  32. ## var s = inspect(obj, opts={})
  33. Return a string `s` with the string representation of `obj` up to a depth of `opts.depth`.
  34. Additional options:
  35. - `quoteStyle`: must be "single" or "double", if present. Default `'single'` for strings, `'double'` for HTML elements.
  36. - `maxStringLength`: must be `0`, a positive integer, `Infinity`, or `null`, if present. Default `Infinity`.
  37. - `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`.
  38. - `indent`: must be "\t", `null`, or a positive integer. Default `null`.
  39. - `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'`)
  40. # install
  41. With [npm](https://npmjs.org) do:
  42. ```
  43. npm install object-inspect
  44. ```
  45. # license
  46. MIT
  47. [package-url]: https://npmjs.org/package/object-inspect
  48. [npm-version-svg]: https://versionbadg.es/inspect-js/object-inspect.svg
  49. [deps-svg]: https://david-dm.org/inspect-js/object-inspect.svg
  50. [deps-url]: https://david-dm.org/inspect-js/object-inspect
  51. [dev-deps-svg]: https://david-dm.org/inspect-js/object-inspect/dev-status.svg
  52. [dev-deps-url]: https://david-dm.org/inspect-js/object-inspect#info=devDependencies
  53. [npm-badge-png]: https://nodei.co/npm/object-inspect.png?downloads=true&stars=true
  54. [license-image]: https://img.shields.io/npm/l/object-inspect.svg
  55. [license-url]: LICENSE
  56. [downloads-image]: https://img.shields.io/npm/dm/object-inspect.svg
  57. [downloads-url]: https://npm-stat.com/charts.html?package=object-inspect
  58. [codecov-image]: https://codecov.io/gh/inspect-js/object-inspect/branch/main/graphs/badge.svg
  59. [codecov-url]: https://app.codecov.io/gh/inspect-js/object-inspect/
  60. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/object-inspect
  61. [actions-url]: https://github.com/inspect-js/object-inspect/actions