Socket
Socket
Sign inDemoInstall

confbox

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    confbox

Compact and high quality YAML, TOML, JSONC and JSON5 parsers


Version published
Weekly downloads
1.2M
increased by109.41%
Maintainers
1
Install size
262 kB
Created
Weekly downloads
 

Changelog

Source

v0.1.7

compare changes

🚀 Enhancements

  • Json utilities with format and whitespace preservation (#7)
  • Preserve style for all utils (d4665b4)

🩹 Fixes

  • Fix stringifyTOML types (40e1ca4)

🏡 Chore

❤️ Contributors

Readme

Source

confbox

npm version bundle size

Config parsers for:

YAML (with js-yaml)

TOML (with smol-toml)

JSONC (with jsonc-parser)

JSON5 (with json5)

JSON

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)

✨ Auto detects indentation and whitespace when parsing and preservers when serializing

[!NOTE] Use unjs/c12 for a full featured configuration loader!

Usage

Install package:

# ✨ Auto-detect
npx nypm install confbox

# npm
npm install confbox

# yarn
yarn add confbox

# pnpm
pnpm install confbox

# bun
bun install confbox

Import:

ESM (Node.js, Bun)

import {
  parseJSON5,
  stringifyJSON5,
  parseJSONC,
  stringifyJSONC,
  parseYAML,
  stringifyYAML,
  parseJSON,
  stringifyJSON,
  parseTOML,
  stringifyTOML,
} from "confbox";

CommonJS (Legacy Node.js)

const {
  parseJSON5,
  stringifyJSON5,
  parseJSONC,
  stringifyJSONC,
  parseYAML,
  stringifyYAML,
  parseJSON,
  stringifyJSON,
  parseTOML,
  stringifyTOML,
} = require("confbox");

CDN (Deno, Bun and Browsers)

import {
  parseJSON5,
  stringifyJSON5,
  parseJSONC,
  stringifyJSONC,
  parseYAML,
  stringifyYAML,
  parseJSON,
  stringifyJSON,
  parseTOML,
  stringifyTOML,
} from "https://esm.sh/confbox";

parseJSON(text, options?)

Converts a JSON string into an object.

Indentation status is auto-detected and preserved when stringifying back using stringifyJSON

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.

stringifyJSON(value, options?)

Converts a JavaScript value to a JSON string.

Indentation status is auto detected and preserved when using value from parseJSON.

stringifyJSON5(value, options?)

Converts a JavaScript value to a JSON5 string.

stringifyJSONC(value, options?)

Converts a JavaScript value to a JSONC string.

stringifyTOML(value)

Converts a JavaScript value to a TOML string.

stringifyYAML(value, options?)

Converts a JavaScript value to a YAML string.

Contribution

Local development
  • Clone this repository
  • Install the latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run tests using pnpm dev or pnpm test

License

Published under the MIT license. Made by @pi0 and community 💛


🤖 auto updated with automd

Keywords

FAQs

Last updated on 17 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc