@indiekitai/inspect
v0.1.0
Published
Rich-style inspect() for JavaScript/TypeScript - pretty-print any object's attributes, methods, and docs
Downloads
100
Maintainers
Readme
@indiekitai/inspect
Rich-style inspect() for JavaScript/TypeScript. Pretty-print any object's attributes, methods, and docs with colored output. Zero dependencies.
Inspired by Python's Rich inspect() function.
Install
npm install @indiekitai/inspectUsage
import { inspect } from '@indiekitai/inspect';
class User {
/** User's full name */
name: string = 'Alice';
/** User's age */
age: number = 30;
greet() { return `Hi, I'm ${this.name}`; }
}
inspect(new User());Output:
╭──────────────────────────────────────────────────────────────╮
│ User │
├──────────────────────────────────────────────────────────────┤
│ • age number = 30 │
│ • name string = "Alice" │
│ λ greet function = ƒ greet() │
╰──────────────────────────────────────────────────────────────╯Options
inspect(obj, {
methods: true, // Show methods (default: true)
private: false, // Show _private members (default: false)
values: true, // Show property values (default: true)
sort: true, // Sort alphabetically (default: true)
maxStringLength: 80, // Truncate long strings (default: 80)
maxDepth: 2, // Nested object depth (default: 2)
json: false, // Output as JSON (default: false)
color: true, // ANSI colors (default: auto-detect)
title: '', // Custom title
print: true, // Print to console (default: true)
});CLI
npx @indiekitai/inspect '{"hello":"world"}'
npx @indiekitai/inspect --json '{"hello":"world"}'
npx @indiekitai/inspect --no-color '{"hello":"world"}'Supports
- Class instances with prototype chain display
- Plain objects, Arrays, Maps, Sets
- Functions (with argument signatures)
- Dates, RegExps, Errors
- Getters/setters
- Nested objects with depth control
- BigInt, Symbol
License
MIT
