bare-inspect
Inspect objects as strings for debugging
v3.1.11bare-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
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. |
Constants and variables
inspect.styles
inspect.styles: {
bigint: string
boolean: string
date: string
module: string
name: string
null: string
number: string
regexp: string
special: string
string: string
symbol: string
undefined: string
}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 {
}A function that applies a named style (such as 'string' or 'number') to a value before it's included in the output.
Threat model
bare-inspect is one of the addons Bare compiles into its binary, so it inherits Bare's threat model. The module's own threat model, added in v3.1.11, says where it sits in that one.
See also
- Builds on
bare-ansi-escapesandbare-type. - Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.
Last updated on