size-chunks.mjs 345 B

1234567891011121314
  1. export default sizeChunks
  2. // Measure the number of character codes in chunks.
  3. // Counts tabs based on their expanded size, and CR+LF as one character.
  4. function sizeChunks(chunks) {
  5. var index = -1
  6. var size = 0
  7. while (++index < chunks.length) {
  8. size += typeof chunks[index] === 'string' ? chunks[index].length : 1
  9. }
  10. return size
  11. }