Package Exports
- hypersim-parser
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 (hypersim-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hypersim-parser
Streaming ndjson parser and metrics aggregator for hyper-simulator
Install
npm install hypersim-parser
Usage
const { createReadStream } = require('fs')
const { BasicTimeline } = require('hypersim-parser')
const parser = new BasicTimeline()
// Register a custom aggregator
parser.pushReducer('version', (prev, { type, event, seq }) => {
if (type !== 'custom' && event !== 'block') return 0
return seq
})
// 'snapshot' event is emitted once for each tick in the simulation's timeline
parser.once('snapshot', (snapshot, iteration) => {
console.log(snapshot)
snapshot.version // contains the result the custom reducer/aggregator.
})
// 'close' is fired once all events has been traversed.
parser.once('close', () => console.log('Parsing complete'))
// The parser implements a Writable stream, and accepts
// ndjson in chunks of Buffer | Uint8Array | string
const readable = fs.createReadStream('swarm-log.json')
readable.pipe(parser)
Contributing
Ideas and contributions to the project are welcome. You must follow this guideline.
License
GNU AGPLv3 © Tony Ivanov