UNPKG

noxon

Version:

Better JSON parsing and manipulation in TypeScript.

102 lines (93 loc) 2.49 kB
import { addKey } from "./mods/keys"; import { colormatic } from "./show/display"; import { exportJSON, exportJS } from "./fileHandling/export"; import { fetchJSON } from "./fileHandling/fetch"; import { format, formatFill, minifyJSON } from "./formats/formatter"; import { addKey as addKey2, removeKey, renameKey, modifyKeyValue } from "./mods/keys"; import { merge, mergeFiles } from "./mods/merge"; import { encrypt, decrypt, getPKAdvanced, getPKBasic } from "./secure/security"; import { display, colormatic as colormatic2 } from "./show/display"; import { parseJSON } from "./utils/parse"; import { sortObjectArray } from "./utils/sort"; import { stringifyJSON } from "./utils/stringify"; import { validate, compareKeys, typeSchema } from "./utils/validate"; const user = { name: "Alex", age: 25, email: "alex@example.com", isAdmin: false, preferences: { theme: "dark", notifications: true, cookie: "cookie" }, hobbies: ["reading", "gaming", "coding"] }; console.log( await addKey({ object: user, newKey: "aaa", keyValue: 123, security: "encrypt", securityLevel: "advanced" }) ); await colormatic( `export const colormatic = <Value extends any>( value: Value, lang: HLJSLanguage, selector: string ): void => { try { const wrapper = document.querySelector(selector); if (!wrapper) throw new Error("Wrapper element not found"); if (value === undefined || value === null) throw new Error("Value is undefined or null"); if (!lang) throw new Error("Language is undefined or null"); const stringified: string | undefined = typeof value === "string" ? value : format(value, 2); const highlighted: string = hljs.highlight(stringified!, { language: lang, }).value; const pre = document.createElement("pre"); const code = document.createElement("code"); code.classList.add("hljs", lang); code.innerHTML += highlighted; pre.appendChild(code); wrapper.appendChild(pre); } catch (error) { console.error(error); return undefined; } }; `, "typescript", "#app", "base16-grayscale-light" ); export { addKey2 as addKey, colormatic2 as colormatic, compareKeys, decrypt, display, encrypt, exportJS, exportJSON, fetchJSON, format, formatFill, getPKAdvanced, getPKBasic, merge, mergeFiles, minifyJSON, modifyKeyValue, parseJSON, removeKey, renameKey, sortObjectArray, stringifyJSON, typeSchema, validate };