diff --git a/formats/toml/README.md b/formats/toml/README.md new file mode 100644 index 0000000..0c6dc1d --- /dev/null +++ b/formats/toml/README.md @@ -0,0 +1,3 @@ +# TOML Format + +Uses the [`smol-toml`](https://www.npmjs.com/package/smol-toml) npm package. diff --git a/formats/toml/index.js b/formats/toml/index.js new file mode 100644 index 0000000..116917a --- /dev/null +++ b/formats/toml/index.js @@ -0,0 +1,17 @@ +import Format from "../../src/format.js"; +import { parse, stringify } from "../../node_modules/smol-toml/dist/index.js"; + +export default class TOML extends Format { + static extensions = ["toml"]; + static mimeTypes = ["application/toml"]; + + static parse (str, options) { + options = this.resolveOptions(options, "parse"); + return parse(str, options); + } + + static stringify (obj, options) { + options = this.resolveOptions(options, "stringify"); + return stringify(obj, options); + } +} diff --git a/package-lock.json b/package-lock.json index cb4d187..f292abe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "csv": "^6.3.1", + "smol-toml": "^1.2.2", "urlpattern-polyfill": "^10.0.0", "yaml": "^2.3.1" }, @@ -7841,6 +7842,15 @@ "npm": ">= 3.0.0" } }, + "node_modules/smol-toml": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.2.2.tgz", + "integrity": "sha512-fVEjX2ybKdJKzFL46VshQbj9PuA4IUKivalgp48/3zwS9vXzyykzQ6AX92UxHSvWJagziMRLeHMgEzoGO7A8hQ==", + "license": "BSD-3-Clause", + "engines": { + "node": ">= 18" + } + }, "node_modules/socks": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", diff --git a/package.json b/package.json index fdd5737..475e389 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ }, "dependencies": { "csv": "^6.3.1", + "smol-toml": "^1.2.2", "urlpattern-polyfill": "^10.0.0", "yaml": "^2.3.1" }