How to use browser-process-hrtime - 2 common examples

To help you get started, we’ve selected a few browser-process-hrtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Paratii-Video / paratii-player / imports / ui / pages / player / ipfs.js View on Github external
stream.content.on('data', (chunk) => {
              // console.log('chunk ', chunk)

              // if (chunk && chunk.length > 0) {
              if (chunk) {
                metrics.queue.push(chunk)

                metrics.received += chunk.length
                const lastHr = (metrics.chunks.length > 0)
                  ? metrics.chunks[metrics.chunks.length - 1].hrtime
                  : metrics.started

                metrics.chunks.push({
                  time: Date.now(),
                  hrtime: hrtime(),
                  bytes: chunk.length,
                  elaspedSinceLast: utils.duration(lastHr),
                  rate: utils.speed(metrics.received, utils.duration(metrics.started))
                })

                metrics.rates = utils.calcRates(metrics.chunks.map(chunk => chunk.rate))
                metrics.overallRate = utils.speed(metrics.received, utils.duration(metrics.started))

                if (!metrics.started) {
                  metrics.started = hrtime()
                }
                if (!streamStarted) {
                  templateDict.set('status', 'awaiting first fragment (' + (chunksPerAppend - metrics.queue.length + 1) + ' chunks )')
                  // stream hasn't started yet. this is first fragment.
                  if (metrics.queue.length - lastChunkIndex === chunksPerAppend) {
                    // there are enough for first append.
github Paratii-Video / paratii-player / imports / ui / pages / player / ipfs.js View on Github external
? metrics.chunks[metrics.chunks.length - 1].hrtime
                  : metrics.started

                metrics.chunks.push({
                  time: Date.now(),
                  hrtime: hrtime(),
                  bytes: chunk.length,
                  elaspedSinceLast: utils.duration(lastHr),
                  rate: utils.speed(metrics.received, utils.duration(metrics.started))
                })

                metrics.rates = utils.calcRates(metrics.chunks.map(chunk => chunk.rate))
                metrics.overallRate = utils.speed(metrics.received, utils.duration(metrics.started))

                if (!metrics.started) {
                  metrics.started = hrtime()
                }
                if (!streamStarted) {
                  templateDict.set('status', 'awaiting first fragment (' + (chunksPerAppend - metrics.queue.length + 1) + ' chunks )')
                  // stream hasn't started yet. this is first fragment.
                  if (metrics.queue.length - lastChunkIndex === chunksPerAppend) {
                    // there are enough for first append.
                    console.log('first chunk(s) appending')
                    appendBuffer()
                    streamStarted = true
                    templateDict.set('status', 'Buffering Chunks...')
                  }
                }

                if (waiting) {
                  // we were waiting for enough chunks.
                  // append what we got.

browser-process-hrtime

Shim for process.hrtime in the browser

BSD-2-Clause
Latest version published 6 years ago

Package Health Score

65 / 100
Full package analysis

Popular browser-process-hrtime functions

Similar packages