rstoml
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i rstoml

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

7.01 kB

Total Files

5

Last publish

Collaborators

  • __yue__