CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
index.js22 linesDownload Raw Back to stream-shift
1module.exports = shift2 3function shift (stream) {4  var rs = stream._readableState5  if (!rs) return null6  return (rs.objectMode || typeof stream._duplexState === 'number') ? stream.read() : stream.read(getStateLength(rs))7}8 9function getStateLength (state) {10  if (state.buffer.length) {11    var idx = state.bufferIndex || 012    // Since node 6.3.0 state.buffer is a BufferList not an array13    if (state.buffer.head) {14      return state.buffer.head.data.length15    } else if (state.buffer.length - idx > 0 && state.buffer[idx]) {16      return state.buffer[idx].length17    }18  }19 20  return state.length21}22