export default sliceChunks import assert from 'assert' function sliceChunks(chunks, token) { var startIndex = token.start._index var startBufferIndex = token.start._bufferIndex var endIndex = token.end._index var endBufferIndex = token.end._bufferIndex var view if (startIndex === endIndex) { assert(endBufferIndex > -1, 'expected non-negative end buffer index') assert(startBufferIndex > -1, 'expected non-negative start buffer index') view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)] } else { view = chunks.slice(startIndex, endIndex) if (startBufferIndex > -1) { view[0] = view[0].slice(startBufferIndex) } if (endBufferIndex > 0) { view.push(chunks[endIndex].slice(0, endBufferIndex)) } } return view }