JSON-style CKT config language parsing/stringification.
npm install cktjsreviver and replacer.For syntax highlighting try the cktvs extension for Visual Studio Code.
sh
npm install cktjs
`For Deno users, you can get the module from deno.land/x/cktjs:
`typescript
import * as CKT from "https://deno.land/x/cktjs@1.0/mod.ts";
`If you're working with a browser, you can use the IIFE build directly from a CDN.
Currently, cktjs officially supports unpkg and jsdelivr:
`html
`Usage
$3
`javascript
// CommonJS
const CKT = require("cktjs");
// ESModules
import * as CKT from "cktjs";
`$3
`javascript
const config = CKT.parse();
`
`javascript
{
"rate limits": {
"/*": {
"request limit": 100,
"window length": "2s"
},
"/api/upload": {
"size limit": "100mb",
"request limit": 6,
"window length": "5s"
}
}
}
`$3
`javascript
const menu = {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{ "value": "New" , "onclick": "CreateNewDoc()" },
{ "value": "Open" , "onclick": "OpenDoc()" },
{ "value": "Close", "onclick": "CloseDoc()" },
],
},
};
const text = CKT.stringify(menu, 2);
`
`lua
id = file
value = File
popup = [
menuitem = [
[
value = New
onclick = "CreateNewDoc()"
]
[
value = Open
onclick = "OpenDoc()"
]
[
value = Close
onclick = "CloseDoc()"
]
]
]
``