1module.exports = shift 2 3function shift (stream) { 4 var rs = stream._readableState 5 if (!rs) return null 6 return rs.objectMode ? stream.read() : stream.read(getStateLength(rs)) 7} 8 9function getStateLength (state) { 10 if (state.buffer.length) { 11 // Since node 6.3.0 state.buffer is a BufferList not an array 12 if (state.buffer.head) { 13 return state.buffer.head.data.length 14 } 15 16 return state.buffer[0].length 17 } 18 19 return state.length 20} 21