https://github.com/rainbowatcher/toml-edit-js
brings toml-edit to the JavaScript world
https://github.com/rainbowatcher/toml-edit-js
edit toml wasm webassembly
Last synced: about 1 year ago
JSON representation
brings toml-edit to the JavaScript world
- Host: GitHub
- URL: https://github.com/rainbowatcher/toml-edit-js
- Owner: rainbowatcher
- License: mit
- Created: 2024-07-27T08:37:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-26T13:41:32.000Z (over 1 year ago)
- Last Synced: 2025-03-18T21:52:52.542Z (over 1 year ago)
- Topics: edit, toml, wasm, webassembly
- Language: TypeScript
- Homepage:
- Size: 1.59 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: license
Awesome Lists containing this project
README
# Toml edit for JavaScript
This repo is built on top of the `toml-edit` crate. It brings `toml-edit` to the JavaScript world through WebAssembly.
## Usage
```sh
npm install @rainbowatcher/toml-edit-js
```
```js
import init, { edit, parse, stringify } from "@rainbowatcher/toml-edit-js"
const toml = `
[package]
rand = "1"
[profile.release]
strip = "symbols"
lto = true
codegen-units = 1
`
await init({})
const parsed = parse(toml)
/*
the const parsed will be as follow
{
"package": {
"rand": "1"
},
"profile": {
"release": {
"strip": "symbols",
"lto": true,
"codegen-units": 1
}
}
}
*/
const edited = edit(toml, "package.rand", { version: "1.0" })
/*
the const edited will be as follow
[package]
rand = { version = "1.0" }
[profile.release]
strip = "symbols"
lto = true
codegen-units = 1
*/
const str = stringify(parsed)
/* same as const toml */
```
## Options
edit method can receive a options
```ts
type IEditOptions = {
finalNewline: boolean
}
```
# License
[MIT](https://github.com/rainbowatcher/toml-edit-js/blob/main/LICENSE).