-
Notifications
You must be signed in to change notification settings - Fork 4
/
object-format.js
48 lines (37 loc) · 903 Bytes
/
object-format.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint no-console : 0 */
/* eslint no-unused-vars : 0 */
const colorize = require('json-colorizer');
// 24bit color chalk-style palette
const chalk = {
black : '#303030',
blue : '#3398db',
cyan : '#00c8c8',
green : '#2fdf64',
gray : '#acacac',
orange : '#ff9932',
pink : '#b2008c',
purple : '#7253b2',
red : '#e74c3c',
white : '#e0e0e0',
yellow : '#ffcc32',
};
function object_format(object) {
const json = {
str : JSON.stringify(object, null, 2),
opt : {
colors : {
BOOLEAN_LITERAL : '#FF9932', // italic
BRACE : '#ACACAC',
BRACKET : 'green',
COLON : 'whiteBright.bold',
COMMA : 'whiteBright.bold',
NULL_LITERAL : 'gray.italic',
NUMBER_LITERAL : '#00C8C8',
STRING_KEY : 'magenta.bold',
STRING_LITERAL : '#FFCC32',
},
},
};
console.log(colorize(json.str, json.opt));
}
module.exports = object_format;