confbox
Config parsers for:
✅ YAML (with js-yaml
)
✅ TOML (with toml
✅ JSONC (with jsonc-parser
)
✅ JSON5 (with json5
)
With perfect bundling:
✨ Types exported out of the box
✨ Zero config and compact redistribution
✨ Dual ESM/CJS build
✨ Consistent and tested API
✨ Handpicked best libraries (bundle+perf)
[!NOTE]
Use unjs/c12 for a full featured configuration loader!
Usage
Install package:
npx nypm i confbox
npm install confbox
yarn add confbox
pnpm install confbox
bun install confbox
Import:
import {
parseJSON5,
parseJSONC,
parseToml,
parseYaml,
stringifyYaml,
} from "confbox";
import { parseYaml, stringifyYaml } from "confbox/yaml";
import { parseToml } from "confbox/toml";
import { parseJSON5 } from "confbox/json5";
import { parseJSONC } from "confbox/jsonc";
const {
parseJSON5,
parseJSONC,
parseToml,
parseYaml,
stringifyYaml,
} = require("confbox");
parseJSON5(text, options?)
Converts a JSON5 string into an object.
parseJSONC(text, options?)
Converts a JSONC string into an object.
parseToml(text)
Converts a TOML string into an object.
parseYaml(text, options?)
Converts a YAML string into an object.
stringifyYaml(value, options?)
Converts a JavaScript value to a YAML string.
Development
- Clone this repository
- Install the latest LTS version of Node.js
- Enable Corepack using
corepack enable
- Install dependencies using
pnpm install
- Run interactive tests using
pnpm dev
License
Made with 💛
Published under MIT License.