UNPKG

@nickbusey/thelounge

Version:

The self-hosted Web IRC client

23 lines (22 loc) 627 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const nickRegExp = /([\w[\]\\`^{|}-]+)/g; function findNames(text, nicks) { const result = []; // Return early if we don't have any nicknames to find if (nicks.length === 0) { return result; } let match; while ((match = nickRegExp.exec(text))) { if (nicks.indexOf(match[1]) > -1) { result.push({ start: match.index, end: match.index + match[1].length, nick: match[1], }); } } return result; } exports.default = findNames;