Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 12 days 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 (4 months ago)
- Default Branch: main
- Last Pushed: 2024-10-25T03:54:27.000Z (23 days ago)
- Last Synced: 2024-11-03T09:18:53.964Z (14 days ago)
- Topics: edit, toml, wasm, webassembly
- Language: TypeScript
- Homepage:
- Size: 1.52 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
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).