{"library":"object-inspect","title":"Object Inspection Utility","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install object-inspect"],"cli":null},"imports":["const inspect = require('object-inspect');","import inspect from 'object-inspect';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const inspect = require('object-inspect');\n\n// Example 1: Circular reference handling\nconst obj = { a: 1, b: [3, 4] };\nobj.c = obj;\nconsole.log('Circular object:', inspect(obj));\n// Expected output: Circular object: { a: 1, b: [ 3, 4 ], c: [Circular] }\n\n// Example 2: Deep object with truncation and custom quote style\nconst deepObj = {\n  a: {\n    b: {\n      c: [1, 2, { d: 'hello world string longer than max length example' }],\n    },\n  },\n  func: function myFunc() {},\n  sym: Symbol('test'),\n};\nconsole.log('\\nDeep object (default):', inspect(deepObj));\nconsole.log('Deep object (depth=2, maxStringLength=10, quoteStyle=\\'single\\'):', inspect(deepObj, {\n  depth: 2,\n  maxStringLength: 10,\n  quoteStyle: 'single'\n}));\n\n// Example 3: BigInt, Date, and Map objects with numeric separators and indent\nconst mixedData = {\n  id: 123456789012345678901234567890n, // BigInt\n  date: new Date('2023-10-26T10:00:00Z'),\n  map: new Map([['key1', 'val1'], ['key2', 'val2']]),\n};\nconsole.log('\\nMixed data (numericSeparator=true, indent=\\'  \\'):', inspect(mixedData, {\n  numericSeparator: true,\n  indent: '  '\n}));","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}