toml-patch
Patch, parse, and stringify TOML.
Installation
toml-patch is dependency-free and can be installed via npm or yarn.
$ npm install --save toml-patch
For browser usage, you can use unpkg:
API
# patch(existing, updated)
Patch an existing TOML string with the given updated JS/JSON value, while attempting to retain the format of the existing document, including comments, indentation, and structure.
const TOML = ;const assert = ; const existing = `# This is a TOML document title = "TOML example"owner.name = "Bob"`const patched = TOML; assert;
# parse(value)
Parse a TOML string into a JS/JSON value.
const TOML = ;const assert = ; const parsed = TOML; assert;
# stringify(value[, options])
Convert a JS/JSON value to a TOML string. options
can be provided for high-level formatting guidelines that follows prettier's configuration.
options
[printWidth = 80]
- (coming soon)[trailingComma = false]
- Add trailing comma to inline tables[bracketSpacing = true]
-true
:{ key = "value" }
,false
:{key = "value"}
const TOML = ;const assert = ; const toml = TOML; assert;