Skip to content

Parse TOML files in streams chunked by [sections]

License

Notifications You must be signed in to change notification settings

Thinkmill/parse-toml-stream

Repository files navigation

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' } },
// ]

About

Parse TOML files in streams chunked by [sections]

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published