eenewbsauce's notebooks

  • Dev.to (RunKit) - /eenewbsauce/dev-to-runkit
    Last edited 5 years ago
    const { format } = require('date-fns') format(new Date(2014, 1, 11), 'MM/dd/yyyy')
  • eventemitter timing - /eenewbsauce/eventemitter-timing
    Last edited 6 years ago
    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() }); }); emitter.on('end', (timing) => { iterations++; timing.end = now(); timings.push(timing); });