mirror of
https://github.com/thelounge/thelounge
synced 2024-12-25 20:03:08 +00:00
29 lines
476 B
JavaScript
29 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;
|