|
123456789101112131415161718192021222324252627 |
- 'use strict'
-
- 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) {
- 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
- }
-
- module.exports = sliceChunks
|