JSPM

  • Created
  • Published
  • Downloads 2573711
  • Score
    100M100P100Q238764F
  • License MIT

TOML parser for Node.js

Package Exports

  • toml

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (toml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

TOML Parser for Node.js

Build Status

NPM

If you haven't heard of TOML, well you're just missing out. Go check it out now. Back? Good.

Installation

toml-node is available via npm.

npm install toml

Usage

Standalone

Say you have some awesome TOML in a variable called someTomlString. Maybe it came from the web; maybe it came from a file; wherever it came from, it came asynchronously! Let's turn that sucker into a JavaScript object.

var toml = require('toml');
var data = toml.parse(someTomlString);
console.dir(data);

Streaming

As of toml-node version 1.0, the streaming interface has been removed. Instead, use a module like concat-stream:

var toml = require('toml');
var concat = require('concat-stream');
var fs = require('fs');

fs.createReadStream('tomlFile.toml', 'utf8').pipe(concat(function(data) {
  var parsed = toml.parse(data);
}));

Thanks @ForbesLindesay for the suggestion.

Live Demo

You can experiment with TOML online at http://binarymuse.github.io/toml-node/, which uses the latest version of this library.

TOML Spec Support

toml-node supports the TOML spec as specified by mojombo/toml@v0.1.0

Building & Testing

toml-node uses the PEG.js parser generator.

npm install
./generate.sh
npm test

Any changes to src/toml.peg requires a regeneration of the parser with ./generate.sh.

toml-node is tested on Travis CI and is tested against:

  • Node 0.6
  • Node 0.8
  • Node 0.10
  • Node 0.11

License

toml-node is licensed under the MIT license agreement. See the LICENSE file for more information.