https://github.com/thinkmill/parse-toml-stream
Parse TOML files in streams chunked by [sections]
https://github.com/thinkmill/parse-toml-stream
nodejs stream toml
Last synced: 10 months ago
JSON representation
Parse TOML files in streams chunked by [sections]
- Host: GitHub
- URL: https://github.com/thinkmill/parse-toml-stream
- Owner: Thinkmill
- License: mit
- Created: 2017-08-22T00:34:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-22T00:43:57.000Z (over 8 years ago)
- Last Synced: 2025-04-12T00:17:10.316Z (10 months ago)
- Topics: nodejs, stream, toml
- Language: JavaScript
- Size: 28.3 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parse-toml-stream
> Parse TOML files in streams chunked by `[sections]`
```toml
# data.toml
foo = "bar"
[baz]
boz = "boy"
[bat]
bam = "boo"
```
```js
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' } },
// ]
```