You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
629 B
27 lines
629 B
'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
|
|
|