https://github.com/simple-works/0inspect
👀 Pretty string representation of object.
https://github.com/simple-works/0inspect
color console inspect javascript js log node-js nodejs object pretty string stringify util-inspect
Last synced: 21 days ago
JSON representation
👀 Pretty string representation of object.
- Host: GitHub
- URL: https://github.com/simple-works/0inspect
- Owner: simple-works
- License: mit
- Created: 2022-03-19T05:37:47.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-29T20:38:01.000Z (about 4 years ago)
- Last Synced: 2025-10-02T04:18:27.413Z (7 months ago)
- Topics: color, console, inspect, javascript, js, log, node-js, nodejs, object, pretty, string, stringify, util-inspect
- Language: JavaScript
- Homepage:
- Size: 563 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 👀 0inspect
[](https://npmjs.org/package/0inspect)
Simple utility for displaying a pretty eye-friendly colorful representation of an object for inspection purposes 👮.

## 📥 Install
```
npm i 0inspect
```
## 🏁 Use
```js
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](https://github.com/chalk) for console colors, the color support control is automatic, but you can still override it this way:
```js
const chalk = require("chalk"); // Chalk v4.1.2
chalk.level = 0; // No color
```
💡 See: [chalk # chalk.level](https://github.com/chalk/chalk#chalklevel)
## 🔣 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](./LICENSE) © [Ambratolm](https://github.com/Ambratolm)