JSPM

hypersim-parser

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q32485F
  • License AGPL-3.0-or-later

Log parser and aggregator for hyper-simulator output

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

Build Status JavaScript Style Guide

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