0.0.2 ā€¢ Published 2 years ago

0inspect v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

šŸ‘€ 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

ColorMeaning
GreenTruthy Primitive
RedFalsy Primitive
CyanFull Object
YellowEmpty Object
MagentaFunction

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

SymbolMeaning
ā—†Truthy Primitive
ā—‡Falsy Primitive
ā—Full Object
ā—‹Empty Object
ā—‰Function
ƘNo Class
ā†’Value

šŸ’  Examples

InputCategoryOutputOutput Color
1nTruthy Primitiveā—† BigInt ā†’ 1Green
NaNFalsy Primitiveā—‡ Number ā†’ NaNRed
undefinedFalsy Primitiveā—‡ Ƙ ā†’ undefinedRed
{ a:"" }Full Objectā— Object ā†’ {1}Cyan
{}Empty Objectā—‹ Object ā†’ {}Yellow
() => ""Functionā—‰ Function ā†’ (anonymous)()Magenta

šŸ“ƒ License

MIT Ā© Ambratolm