hardlounge/client/js/libs/handlebars/ircmessageparser/fill.js
Bonuspunkt 0b85ded53f Add bonuspunkt's parser
Fixes #15.
Fixes #199.
Fixes #583.
Fixes #654.
Fixes #928.
Fixes #1001.
2017-04-21 20:29:04 +03:00

30 lines
476 B
JavaScript

"use strict";
function fill(existingEntries, text) {
let position = 0;
const result = [];
for (let i = 0; i < existingEntries.length; i++) {
const textSegment = existingEntries[i];
if (textSegment.start > position) {
result.push({
start: position,
end: textSegment.start
});
}
position = textSegment.end;
}
if (position < text.length) {
result.push({
start: position,
end: text.length
});
}
return result;
}
module.exports = fill;