Skip to content

Commit b1fafd8

Browse files
committed
Integrate json-lexer
1 parent fd53d9a commit b1fafd8

File tree

6 files changed

+65
-8
lines changed

6 files changed

+65
-8
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
22
.idea
3-
3+
dist

example.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { colorize } = require('./dist');
2+
const pkg = require('./package.json');
3+
4+
console.log(colorize(pkg));

package-lock.json

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

package.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
"name": "json-colorizer",
33
"version": "3.0.0",
44
"description": "A library to format JSON with colors for display in the console",
5-
"main": "src/lib/index.js",
5+
"main": "dist/index.js",
66
"files": [
77
"src/lib"
88
],
9-
"types": "src/lib/index.d.ts",
9+
"types": "dist/index.d.ts",
1010
"scripts": {
11-
"test": "mocha src/test",
12-
"test:watch": "mocha -w src/test",
13-
"prettify": "prettier --write src/**/*.js",
14-
"lint": "eslint src"
11+
"build": "tsc"
1512
},
1613
"repository": {
1714
"type": "git",
@@ -26,5 +23,11 @@
2623
"license": "MIT",
2724
"bugs": {
2825
"url": "https://github.com/joeattardi/json-colorizer/issues"
26+
},
27+
"devDependencies": {
28+
"typescript": "^5.4.5"
29+
},
30+
"dependencies": {
31+
"json-lexer": "^1.2.0"
2932
}
3033
}

src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import lexer from 'json-lexer';
2+
3+
export function colorize(json: string | object) {
4+
const input = typeof json === 'string' ? json : JSON.stringify(json, null, 2);
5+
6+
const tokens = lexer(input);
7+
8+
}

tsconfig.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "commonjs",
5+
"esModuleInterop": true,
6+
"forceConsistentCasingInFileNames": true,
7+
"strict": true,
8+
"skipLibCheck": true,
9+
"declaration": true,
10+
"outDir": "dist"
11+
},
12+
"include":[
13+
"src/**/*.ts"
14+
],
15+
"exclude": [
16+
"node_modules"
17+
]
18+
}

0 commit comments

Comments
 (0)