index.js
function createBufferStream (stream, interval) {
  var buf = []
  var timer = null

  // flush function
  function flush () {
    timer = null
    stream.write(buf.join(''))
    buf.length = 0
  }

  // write function
  function write (str) {
    if (timer === null) {
      timer = setTimeout(flush, interval)
    }

    buf.push(str)
  }

  // return a minimal "stream"
  return { write: write }
}
function createBufferStream (stream, interval) {
  var buf = []
  var timer = null

  // flush function
  function flush () {
    timer = null
    stream.write(buf.join(''))
    buf.length = 0
  }

  // write function
  function write (str) {
    if (timer === null) {
      timer = setTimeout(flush, interval)
    }

    buf.push(str)
  }

  // return a minimal "stream"
  return { write: write }
}
function createBufferStream ( stream , interval ) { var buf = [ ] var timer = null // flush function function flush ( ) { timer = null stream . write ( buf . join ( '' ) ) buf . length = 0 } // write function function write ( str ) { if ( timer === null ) { timer = setTimeout ( flush , interval ) } buf . push ( str ) } // return a minimal "stream" return { write : write } }
Create a basic buffering stream.

@param {object} stream
@param {number} interval
@public
Create a basic buffering stream .