replay-emitter
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Replay-emitter

Replay-emitter is a simple tool to record/replay events from a file to nodejs EventEmitter.

CI

Installation

npm install replay-emitter
yarn add replay-emitter

Options

Option Type Default Description
offset number 0 time offset
mode auto | manual auto Specify the mode
events string[] [] If manual mode, the events you wanna record

Usage

Record events

import handler, { replayEnd } from 'replay-emitter';
import { EventEmitter } from 'events';
// After registering all the `.on` and `.once` listeners

const emitter = new EventEmitter();
handler(emitter)

// When you did finish recording enough sample

setTimeout(async () => {
  await replayEnd()
  console.log('REPLAY END')
  
  // This function is gonna save the events to the replay.txt file at the root of the project
}, 10000)

Replay events

import handler, { replayEnd } from 'replay-emitter';
import { EventEmitter } from 'events';
// After registering all the `.on` and `.once` listeners

const emitter = new EventEmitter();

const startFunction = await execute(emitter, 'pathtothefile/replay.txt');

// start the replay
await startFunction();

Readme

Keywords

none

Package Sidebar

Install

npm i replay-emitter

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

10.2 kB

Total Files

8

Last publish

Collaborators

  • oktapodia