0.0.2 ⢠Published 4 years ago
0inspect v0.0.2
š 0inspect
Simple utility for displaying a pretty eye-friendly colorful representation of an object for inspection purposes š®.

š„ Install
npm i 0inspectš Use
const inspect = require("0inspect");
// or const { inspect, log } = require("0inspect");
const objString = inspect(someObj);
console.log(objString);
// or shorter
inspect.log(someObj);š API
inspect(obj?: Any, options?: Object);
obj: Any: Object to inspect.options: Object: Options object.depth: Number: Object nesting depth. Default:10.
inspect.log(obj?: Any, options?: Object);
- Just a wrapper for
console.log(inspect(obj, options)).
šØ Colors
| Color | Meaning |
|---|---|
| Green | Truthy Primitive |
| Red | Falsy Primitive |
| Cyan | Full Object |
| Yellow | Empty Object |
| Magenta | Function |
As this is using Chalk for console colors, the color support control is automatic, but you can still override it this way:
const chalk = require("chalk"); // Chalk v4.1.2
chalk.level = 0; // No colorš” See: chalk # chalk.level
š£ Symbols
| Symbol | Meaning |
|---|---|
| ā | Truthy Primitive |
| ā | Falsy Primitive |
| ā | Full Object |
| ā | Empty Object |
| ā | Function |
| Ć | No Class |
| ā | Value |
š Examples
| Input | Category | Output | Output Color |
|---|---|---|---|
1n | Truthy Primitive | ā BigInt ā 1 | Green |
NaN | Falsy Primitive | ā Number ā NaN | Red |
undefined | Falsy Primitive | ā Ć ā undefined | Red |
{ a:"" } | Full Object | ā Object ā {1} | Cyan |
{} | Empty Object | ā Object ā {} | Yellow |
() => "" | Function | ā Function ā (anonymous)() | Magenta |