Minimal reproducing example:
import { init, edit } from "@rainbowatcher/toml-edit-js"
const toml = `
[package]
# comment
rand = "1"
`
await init()
const edited = edit(toml, "package.rand", "2")
console.log(edited)
Gives
Where the comment line # comment is removed. By contrast, the following Rust code using the toml_edit crate
use toml_edit::{DocumentMut, value};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let toml = r#"
[package]
# comment
rand = "1"
"#;
let mut doc = toml.parse::<DocumentMut>()?;
doc["package"]["rand"] = value("2");
println!("{}", doc.to_string());
Ok(())
}
Gives
[package]
# comment
rand = "2"
where the comment line is preserved, which is what we expected.
Minimal reproducing example:
Gives
Where the comment line
# commentis removed. By contrast, the following Rust code using thetoml_editcrateGives
where the comment line is preserved, which is what we expected.