thelounge/client/js/libs/handlebars/ircmessageparser/findNames.js

20 lines
289 B
JavaScript
Raw Normal View History

2017-11-14 22:36:45 +00:00
"use strict";
function findNames(text, users) {
const result = [];
let index = -1;
2017-11-14 22:36:45 +00:00
users.forEach((nick) => {
index = text.indexOf(nick, ++index);
2017-11-14 22:36:45 +00:00
result.push({
start: index,
end: index + nick.length,
nick: nick,
});
});
2017-11-14 22:36:45 +00:00
return result;
}
module.exports = findNames;