К
Size: a a a
К
AK
from([
'ABCD\nEFGH',
'wtf',
'IJKL\nMNOP',
'QRST\nUVWX',
])
.scan(
(acc, data: string) => {
const rows = data.split('\n')
const queue = rows.slice(0, -1)
const lastRow = last(rows) || ''
if (queue.length) {
queue[0] = acc.buff + queue[0]
acc.queue = queue
acc.buff = ''
} else {
acc.queue = []
}
if (data.endsWith('\n')) {
acc.queue.push(
`${acc.buff}${lastRow}`,
)
} else {
acc.buff += lastRow
}
return acc
},
{ buff: '', queue: [] },
)
.chain(acc => from(acc.queue))
.subscribe({
next: console.log,
})
К
К
AK
AK
AK
К
К
at
К
at
К
m
К
m
К
с