bare-inspect
Inspect objects as strings for debugging
stable
Source
Source
Source
bare-inspect — Inspect objects as strings for debugging. It is a native addon and requires Bare >=1.18.0.
npm i bare-inspectUsage
const inspect = require('bare-inspect')
console.log(inspect(globalThis))API
Functions
inspect(value: unknown, opts?: InspectOptions): string
Source
Returns a string representation of value for debugging, similar to Node's util.inspect(). If value has a Symbol.for('bare.inspect') or Symbol.for('nodejs.util.inspect.custom') method, it is used to produce the output.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
value | unknown | — | The value to produce a string representation of. |
opts? | InspectOptions | — | Formatting options; see InspectOptions. |
Types
InspectOptions
interface InspectOptions {
colors?: boolean
depth?: number
breakLength?: number
stylize?: InspectStylize
}Options for inspect(). colors enables ANSI styling, depth limits how many levels of nested objects are inspected (defaults to 2), breakLength sets the line-wrap width (defaults to 80), and stylize is a custom function for applying styles to values.
InspectStylize
interface InspectStylize {
(value: string, style: keyof typeof inspect.styles): string
}A function that applies a named style (such as 'string' or 'number') to a value before it's included in the output.
See also
- Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.