Skip to content

Commit da9caa5

Browse files
AmbratolmAmbratolm
Ambratolm
authored and
Ambratolm
committed
Initial Commit
0 parents  commit da9caa5

8 files changed

+306
-0
lines changed

.gitignore

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Project
2+
# ...
3+
4+
# Editor
5+
.vscode
6+
*.sublime-*
7+
8+
# Logs
9+
logs
10+
*.log
11+
npm-debug.log*
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# node-waf configuration
32+
.lock-wscript
33+
34+
# Compiled binary addons (http://nodejs.org/api/addons.html)
35+
build/Release
36+
37+
# Dependency directories
38+
node_modules
39+
jspm_packages
40+
41+
# Optional npm cache directory
42+
.npm
43+
44+
# Optional REPL history
45+
.node_repl_history

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Ambratolm
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 👀 0inspect
2+
3+
[![NPM version](https://badge.fury.io/js/0inspect.svg)](https://npmjs.org/package/0inspect)
4+
5+
Simple utility for displaying a pretty eye-friendly colorful representation of an object for inspection purposes.
6+
7+
![Screenshot](./screenshot.jpg?raw=true)
8+
9+
# 📥 Install
10+
11+
```
12+
npm i 0inspect
13+
```
14+
15+
# 🏁 Use
16+
17+
```js
18+
const $inspect = require("0inspect");
19+
20+
$inspect(someObj);
21+
```
22+
23+
# 📕 API
24+
25+
`$inspect(obj?: Any, options?: Object);`
26+
- `obj: Any`: Object to inspect.
27+
- `options: Object` Options object.
28+
- `color: Boolean`: If true, colorful output. Default: `true`.
29+
30+
# 📃 License
31+
32+
[MIT](./LICENSE) © [Ambratolm](https://github.com/Ambratolm)

index.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
///══════════════════════════════════════════════════════════════════════════════
2+
// ■ Inspect (inspect/index.js)
3+
//┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
4+
// Pretty string representation of object.
5+
//══════════════════════════════════════════════════════════════════════════════
6+
const check = require("check-types");
7+
const chalk = require("chalk");
8+
9+
//──────────────────────────────────────────────────────────────────────────────
10+
// ● Inspect
11+
//──────────────────────────────────────────────────────────────────────────────
12+
function inspect(obj, options = {}) {
13+
console.log(obj);
14+
}
15+
16+
//──────────────────────────────────────────────────────────────────────────────
17+
// ► Exports
18+
//──────────────────────────────────────────────────────────────────────────────
19+
module.exports = inspect;

package-lock.json

+56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "0inspect",
3+
"version": "0.0.0",
4+
"description": "Pretty string representation of object",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "nodemon test.js"
8+
},
9+
"keywords": [
10+
"inspect",
11+
"util",
12+
"object",
13+
"string",
14+
"stringify",
15+
"pretty",
16+
"log",
17+
"color"
18+
],
19+
"author": "Ambratolm <[email protected]>",
20+
"license": "MIT",
21+
"dependencies": {
22+
"chalk": "^4.1.2",
23+
"check-types": "^11.1.2"
24+
},
25+
"devDependencies": {},
26+
"repository": {
27+
"type": "git",
28+
"url": "git+https://github.com/simple-works/0inspect.git"
29+
},
30+
"bugs": {
31+
"url": "https://github.com/simple-works/0inspect/issues"
32+
},
33+
"homepage": "https://github.com/simple-works/0inspect#readme"
34+
}

test.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
///══════════════════════════════════════════════════════════════════════════════
2+
// ■ Test (test.js)
3+
//┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
4+
// This file is for test purposes only.
5+
//══════════════════════════════════════════════════════════════════════════════
6+
const inspect = require("./index");
7+
const values = require("./values.test");
8+
9+
//──────────────────────────────────────────────────────────────────────────────
10+
// ● Test
11+
//──────────────────────────────────────────────────────────────────────────────
12+
function test() {
13+
for (const key in values) {
14+
console.log("─".repeat(80));
15+
console.log("■", key, ":");
16+
console.log("-".repeat(80));
17+
for (const value of values[key]) {
18+
inspect(value);
19+
}
20+
console.log();
21+
}
22+
}
23+
24+
//──────────────────────────────────────────────────────────────────────────────
25+
// ► Execute
26+
//──────────────────────────────────────────────────────────────────────────────
27+
process.stdout.write("\x1Bc");
28+
test();

values.test.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
///══════════════════════════════════════════════════════════════════════════════
2+
// ■ Test-Values (values.test.js)
3+
//┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
4+
// This file is for test purposes only.
5+
//══════════════════════════════════════════════════════════════════════════════
6+
7+
///──────────────────────────────────────────────────────────────────────────────
8+
// ► Exports
9+
//──────────────────────────────────────────────────────────────────────────────
10+
module.exports = {
11+
void: [undefined],
12+
booleans: [false, true, new Boolean(), new Boolean("Peace")],
13+
numbers: [0, 7_000_000_000, new Number(), new Number(7), Infinity, NaN],
14+
strings: ["", "Peace upon You!", new String(), new String("Peace")],
15+
symbols: [Symbol(), Symbol("Be in Peace :)")],
16+
objects: [
17+
null,
18+
{},
19+
{
20+
a: "A",
21+
b: "B",
22+
c: {
23+
x: "X",
24+
z() {
25+
return "Z";
26+
},
27+
},
28+
o() {
29+
return "O";
30+
},
31+
},
32+
new Object(),
33+
new Object({ a: "A", b: "B" }),
34+
],
35+
arrays: [
36+
[],
37+
[undefined, undefined, undefined],
38+
[null, null, null],
39+
[{}, {}, {}],
40+
[undefined, null, {}],
41+
[
42+
{
43+
a: "A",
44+
b: "B",
45+
c: {
46+
x: "X",
47+
z() {
48+
return "Z";
49+
},
50+
},
51+
o() {
52+
return "O";
53+
},
54+
},
55+
null,
56+
{
57+
a: "A",
58+
b: "B",
59+
},
60+
],
61+
],
62+
functions: [
63+
() => {},
64+
() => "Peaceful arrow function",
65+
function () {},
66+
function fn() {},
67+
function fn() {
68+
return "Peaceful function";
69+
},
70+
],
71+
};

0 commit comments

Comments
 (0)