el-beeswarm
Version:
<div style="display: flex; padding: 1rem; flex-direction: column; align-items: center; justify-content: center; height: 100vh; text-align: center; display: flex;
41 lines (33 loc) • 799 B
JavaScript
var fromCharCode = require('../constant/from-char-code.js')
function serializeChunks(chunks) {
var index = -1
var result = []
var chunk
var value
var atTab
while (++index < chunks.length) {
chunk = chunks[index]
if (typeof chunk === 'string') {
value = chunk
} else if (chunk === -5) {
value = '\r'
} else if (chunk === -4) {
value = '\n'
} else if (chunk === -3) {
value = '\r' + '\n'
} else if (chunk === -2) {
value = '\t'
} else if (chunk === -1) {
if (atTab) continue
value = ' '
} else {
// Currently only replacement character.
value = fromCharCode(chunk)
}
atTab = chunk === -2
result.push(value)
}
return result.join('')
}
module.exports = serializeChunks