lib/irc: rename IRC prefix utilities

This commit is contained in:
Simon Ser 2021-06-03 13:18:28 +02:00
parent 04c9f0211a
commit 283f8af4b1
2 changed files with 10 additions and 9 deletions

View file

@ -42,6 +42,7 @@ export const ERR_SASLTOOLONG = "905";
export const ERR_SASLABORTED = "906";
export const ERR_SASLALREADY = "907";
export const STD_MEMBERSHIPS = "~&@%+";
export const STD_CHANNEL_TYPES = "#&+!";
export const STD_CHANMODES = "beI,k,l,imnst";
@ -208,10 +209,9 @@ export function formatMessage(msg) {
return s;
}
export function parseMembership(s) {
/** Split a prefix and a name out of a target. */
export function parseTargetPrefix(s) {
// TODO: use the PREFIX token from RPL_ISUPPORT
const STD_MEMBERSHIPS = "~&@%+";
var i;
for (i = 0; i < s.length; i++) {
if (STD_MEMBERSHIPS.indexOf(s[i]) < 0) {
@ -221,7 +221,7 @@ export function parseMembership(s) {
return {
prefix: s.slice(0, i),
nick: s.slice(i),
name: s.slice(i),
};
}
@ -514,7 +514,8 @@ export class CaseMapMap {
}
}
export function parseMemberships(str) {
/** Parse the ISUPPORT PREFIX token */
export function parseMembershipModes(str) {
if (str[0] !== "(") {
throw new Error("malformed ISUPPORT PREFIX value: expected opening parenthesis");
}