eventemitter timing

node v8.17.0
version: 1.0.0
endpointsharetweet
const EventEmitter = require('events'); class Emitter extends EventEmitter { } const maxIterations = 10; let iterations = 0; const timings = []; const emitter = new Emitter(); const now = () => Date.now(); emitter.on('start', (timing) => { timing.receive = now(); emitter.emit('end', timing); }); setInterval(() => { if (iterations === maxIterations) { console.dir(timings); process.exit(); } emitter.emit('start', { start: now() }); }, 30); emitter.on('end', (timing) => { iterations++; timing.end = now(); timings.push(timing); });
Loading…

no comments

    sign in to comment