Skip to content

simple-works/0inspect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‘€ 0inspect

NPM version

Simple utility for displaying a pretty eye-friendly colorful representation of an object for inspection purposes ๐Ÿ‘ฎ.

Screenshot

๐Ÿ“ฅ 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

๐Ÿ“ƒ License

MIT ยฉ Ambratolm