object-inspect is a robust JavaScript utility that provides string representations of arbitrary JavaScript objects, designed for both Node.js and browser environments. Its primary function is to serialize objects into a human-readable string, handling complex data structures like circular references, DOM elements, and various built-in types (e.g., Map, Set, WeakMap, WeakSet, BigInt, WeakRef). The current stable version is 1.13.4. While there isn't a strict release cadence, the project actively incorporates support for new JavaScript features and addresses edge cases, with recent updates adding WeakRef and BigInt support. Key differentiators include its configurable output through options like `depth`, `quoteStyle`, `maxStringLength`, `customInspect`, `indent`, and `numericSeparator`, allowing fine-grained control over the serialization process, making it a versatile alternative or complement to Node.js's built-in `util.inspect` where cross-environment compatibility or customizability is paramount.
npm install object-inspectVerified import paths — ran on the pinned version, not inferred.
Demonstrates `object-inspect`'s ability to handle circular references, control output depth and formatting, and serialize various built-in and primitive types like BigInt, Date, and Map.
Use `inspect(obj, { customInspect: false })` to ignore custom inspect methods, or `inspect(obj, { customInspect: 'symbol' })` to only respect symbol-based custom methods.For critical Node.js-specific inspection, prefer `require('util').inspect` if the environment is guaranteed to be Node.js. Use `object-inspect` when cross-environment consistency or specific custom options are prioritized.If detailed HTML or full DOM tree serialization is required, use browser-native APIs like `element.outerHTML` or `new XMLSerializer().serializeToString(document)`.
In CommonJS modules, use `const inspect = require('object-inspect');`. In ES Modules, use `import inspect from 'object-inspect';`. Verify module type configuration if using TypeScript.Increase the `depth` option (e.g., `inspect(obj, { depth: Infinity })` for full depth) and/or adjust `maxStringLength` (e.g., `inspect(obj, { maxStringLength: null })` for no string truncation) in the `inspect` function call.No dependency data recorded yet.