How to use flush-write-stream - 5 common examples

To help you get started, we’ve selected a few flush-write-stream 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 mcollina / climem / climem.js View on Github external
xLabelPadding: 3,
      xPadding: 5,
      label: 'Memory (MB)',
      showLegend: true,
      legend: { width: 12 }
    })
    screen.append(line)

    screen.key(['escape', 'q', 'C-c'], () => {
      return process.exit(0)
    })
  }

  pump(net.connect(argv._[0], argv._[1]),
       split(JSON.parse),
       writer.obj(argv.data ? write : plot), (err) => {
    if (err) {
      console.error(err.message)
    } else {
      console.error('stream closed')
    }

    try {
      fs.unlinkSync(argv._[0])
    } catch (err) {
      // nothing to do it might not be a file
    }
  })

  function write (chunk, enc, cb) {
    console.dir(chunk)
    cb()
github kemitchell / lamos.js / concat.js View on Github external
module.exports = function (callback) {
  var state = core.parserState()
  return pumpify(
    parser(),
    flushWriteStream.obj(
      function (token, _, done) {
        /* istanbul ignore next */
        try {
          core.parseToken(state, token)
        } catch (error) {
          return done(error)
        }
        done()
      },
      function (done) {
        callback(core.parserResult(state))
      }
    )
  )
}
github pinojs / pino / test / helper.js View on Github external
function sink (func) {
  const result = split((data) => {
    try {
      return JSON.parse(data)
    } catch (err) {
      console.log(err)
      console.log(data)
    }
  })
  if (func) result.pipe(writer.obj(func))
  return result
}
github bcomnes / getusermedia-to-text / index.js View on Github external
GetUserMediaToText.prototype.start = function () {
  var self = this
  if (this.listening) return this.emit('status', 'Already Listening')

  if (!this.mediaStream) {
    if (this.waiting) return this.emit('status', 'Waiting for userMedia')
    this.waiting = true
    return this.once('mediaStream', function () {
      self.waiting = false
      self.start()
    })
  }

  if (!this.sinkStream) {
    var recognizeStream = this.speech.createRecognizeStream(this._opts.request)
    var emitter = writer.obj(function (data, enc, cb) {
      self.emit('data', data)
      cb()
    })
    this.sinkStream = pumpify(pcm(), recognizeStream, emitter)
  }

  if (!this.audioStream) {
    this.audioStream = audio(this.mediaStream, {
      channels: 1,
      volume: 0.8
    })
  }
  this.listening = true
  this.emit('listening', true)
  this.emit('status', 'Started listening')
  this.pipeline = pump(this.audioStream, this.sinkStream, function (err) {
github hypermodules / hyperamp / main / track-dict.js View on Github external
function concatTrackDict (obj) {
  function writeTrackDict (data, enc, cb) {
    log.info(`Scanning ${data.filepath}`)
    parseMetadata(data, handleMeta)

    function handleMeta (err, meta) {
      if (err) throw err
      obj[meta.filepath] = meta
      cb(null)
    }
  }
  return writer.obj(writeTrackDict)
}

flush-write-stream

A write stream constructor that supports a flush function that is called before finish is emitted

MIT
Latest version published 5 years ago

Package Health Score

65 / 100
Full package analysis

Popular flush-write-stream functions

Similar packages