vael:fmt/inspect
Human-readable value inspection for debugging and diagnostic output.
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite) runtimes.
Formats primitives, objects, arrays, maps, sets, typed arrays, dates,
regular expressions, errors, symbols, and circular references.
import ... from "vael:fmt/inspect"
Since v0.0.0-alpha.2 vjs (V8) vjs-lite (QuickJS)
Cargo feature:
vael-fmt (enabled by default in vaeljs-core and vaeljs-lite-core)Example
Section titled “Example”import { inspect } from "vael:fmt/inspect";
console.log(inspect({ user: "alice", scores: [95, 87, 92] }));console.log(inspect({ b: 1, a: 2 }, { sorted: true, compact: true }));API Symbols
Functions (1)
Functions
Section titled “Functions”inspect
Section titled “inspect”export function inspect(value: unknown, options?: InspectOptions): string;
Format any JavaScript value into a human-readable diagnostic string.
Handles circular references safely ([Circular]), respects depth and
iterableLimit, and avoids invoking getters unless options.getters is true.
Parameters
| Name | Type | Description |
|---|---|---|
value | unknown | Any value to inspect. |
options optional | InspectOptions | Optional formatting configuration. |
Returns
string — Formatted string representation of value.Exceptions
TypeError— whenoptionsis provided and not an object.
import { inspect } from "vael:fmt/inspect";
console.log(inspect("hello")); // "'hello'"console.log(inspect(new Map([["k", 1]]))); // "Map(1) { 'k' => 1 }"Interfaces
Section titled “Interfaces”InspectOptions
Section titled “InspectOptions”export interface InspectOptions {
colors?: boolean;
compact?: boolean;
depth?: number;
breakLength?: number;
escapeSequences?: boolean;
iterableLimit?: number;
showProxy?: boolean;
sorted?: boolean;
trailingComma?: boolean;
getters?: boolean;
showHidden?: boolean;
strAbbreviateSize?: number;
}
Formatting options accepted by inspect.
Properties
| Property | Type | Description | Since |
|---|---|---|---|
colors optional | boolean | Include ANSI color sequences in formatted output. Defaults to false. | v0.0.0-alpha.2 |
compact optional | boolean | Collapse nested objects onto fewer lines when true, or force multi-line expansion when false. | v0.0.0-alpha.2 |
depth optional | number | Maximum recursion depth when formatting nested objects and collections. Defaults to 4. | v0.0.0-alpha.2 |
breakLength optional | number | Maximum line length before breaking collections across multiple lines. Defaults to 80. | v0.0.0-alpha.2 |
escapeSequences optional | boolean | Escape control characters in string values. Defaults to true. | v0.0.0-alpha.2 |
iterableLimit optional | number | Maximum number of array, Map, Set, or object entries to display before truncating. Defaults to 100. | v0.0.0-alpha.2 |
showProxy optional | boolean | Inspect Proxy target and handler details when supported. | v0.0.0-alpha.2 |
sorted optional | boolean | Sort object property keys lexicographically. Defaults to false. | v0.0.0-alpha.2 |
trailingComma optional | boolean | Append a trailing comma on multi-line objects and arrays. Defaults to false. | v0.0.0-alpha.2 |
getters optional | boolean | Invoke getter properties when inspecting objects instead of printing [Getter]. Defaults to false. | v0.0.0-alpha.2 |
showHidden optional | boolean | Include non-enumerable and symbol-keyed properties. Defaults to false. | v0.0.0-alpha.2 |
strAbbreviateSize optional | number | Truncate string values longer than this character count with "...". | v0.0.0-alpha.2 |
