UNPKG

jka-core

Version:

Library for working with Jedi Academy servers

20 lines (19 loc) 626 B
"use strict"; // "g_forceregentime" is:"200^7" default:"200^7" Object.defineProperty(exports, "__esModule", { value: true }); exports.getCvarValue = void 0; /** * Parses cvarName from rcon response * @param str String with rcon response * @param cvarName cvarName which needs to be parsed * @returns value of the cvarName */ function getCvarValue(str, cvarName) { const reg = new RegExp(`"${cvarName}" is:"(.+?)\\^7" default:"(.+?)\\^7"`); const match = str.match(reg); if (!match) throw new Error(`No match for ${cvarName}!`); else return match[1]; } exports.getCvarValue = getCvarValue;