Loupe is a robust, cross-platform utility for converting JavaScript objects into string representations, designed to work consistently in both Node.js and browser environments. It provides functionality similar to Node.js' built-in `util.inspect()`, making it a valuable tool for debugging and generating human-readable output of complex data structures. The current stable major version is `4.x`, with `v4.0.0` introducing significant breaking changes regarding custom inspection methods. The package maintains a moderate release cadence, with minor and patch updates preceding major version increments, reflecting ongoing development and refinement. As a core component within the Chai.js assertion library ecosystem, Loupe's key differentiator is its unified inspection behavior across diverse JavaScript runtimes, addressing the common challenge of inconsistent object serialization.
npm install loupeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the `inspect` function with various data types, including objects, arrays, dates, regexes, functions, and a custom-inspectable object (v4.x style).
Migrate custom inspect functions to use `Symbol('nodejs.util.inspect.custom')` or `Symbol('chai/inspect')` instead. This aligns with Node.js' `util.inspect` behavior.Loupe's `inspect` function accepts options for controlling depth and truncation. Consider using `inspect(obj, { depth: 2, maxLineLength: 80 })` to limit output size.No direct fix needed, but be aware of changes in build output if you were relying on these declaration maps for debugging or tooling purposes in older versions. For v4.0.0+, declaration maps are no longer shipped.
Use named import `import { inspect } from 'loupe';` for ESM or destructuring `const { inspect } = require('loupe');` for CommonJS.For `loupe` v4.0.0 and above, custom inspect methods must be defined using the `Symbol('nodejs.util.inspect.custom')` or `Symbol('chai/inspect')` symbol keys. Example: `obj[Symbol('nodejs.util.inspect.custom')] = function() { /* ... */ };`No dependency data recorded yet.