rstoml
toml-rs
re-exported via napi-rs
Install
pnpm add rstoml
yarn add rstoml
npm add rstoml
Usage
API interface is slightly different from the original rstoml
lib and more close to js conventions.
import toml from "rstoml"
toml.parse("foo = 'bar'")
// -> { foo: 'bar' }
toml.parse(`
ip = '127.0.0.1'
[keys]
github = 'xxxxxxxxxxxxxxxxx'
travis = 'yyyyyyyyyyyyyyyyy'
`)
// -> {
// ip: '127.0.0.1',
// keys: {
// github: 'xxxxxxxxxxxxxxxxx',
// travis: 'yyyyyyyyyyyyyyyyy',
// }
// }
toml.parseBuffer(Buffer.from("foo = 'bar'", "utf-8"))
// -> { foo: 'bar' }
toml.stringify({ foo: 'a\nb\nc' })
// -> `foo = "a\nb\nc"`
toml.stringify({ foo: 'a\nb\nc' }, { pretty: true })
// -> foo = '''
// a
// b
// c'''
Benchmark
you can find a benchmark at this moment here