2.0.0 • Published 7 years ago

parse-toml-stream v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

parse-toml-stream

Parse TOML files in streams chunked by [sections]

# data.toml
foo = "bar"

[baz]
boz = "boy"

[bat]
bam = "boo"
const createReadableTomlStream = require('toml-stream');
const path = require('path');
const fs = require('fs');

let fileStream = fs.createReadStream(path.join(__dirname, 'data.toml'));
let tomlStream = createReadableTomlStream(fileStream);

let chunks = [];

tomlStream.on('data', chunk => {
  chunks.push(chunk);
});

tomlStream.on('end', () => {
  console.log(chunks);
});
// chunks == [
//   { foo: 'bar' },
//   { baz: { boz: 'boy' } },
//   { bat: { bam: 'boo' } },
// ]