docs: function readonly (stream) {
    var rs = stream._readableState || {}
    var opts = {}
  
    if (typeof stream.read !== 'function') {
      throw new Error('not a readable stream')
    }
  
    ['highWaterMark', 'encoding', 'objectMode'].forEach(function (p) {
      opts[p] = rs[p]
    })
  
    var readOnly = new Readable(opts)
    var waiting = false
  
    stream.on('readable', function () {
      if (waiting) {
        waiting = false
        readOnly._read()
      }
    })
  
    readOnly._read = function (size) {
      var buf
  
      while ((buf = stream.read(size)) !== null) {
        if (!readOnly.push(buf)) {
          return
        }
      }
      waiting = true
    }
  
    stream.once('end', function () {
      readOnly.push(null)
    })
    stream.on('close', function () {
      readOnly.emit('close')
    })
    stream.on('error', function (err) {
      readOnly.emit('error', err)
    })
    return readOnly
  }