mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 15:17:36 +00:00
Replace deprecated substr with substring (#355)
* Make the QueryRunner more readable * Remove use of deprecated substr and replace with substring, and some formatting
This commit is contained in:
parent
65dd876252
commit
5b01e1be17
9 changed files with 66 additions and 61 deletions
|
|
@ -14,8 +14,8 @@ class Teamspeak2 extends Core {
|
|||
const data = await this.sendCommand(socket, 'si');
|
||||
for (const line of data.split('\r\n')) {
|
||||
const equals = line.indexOf('=');
|
||||
const key = equals === -1 ? line : line.substr(0,equals);
|
||||
const value = equals === -1 ? '' : line.substr(equals+1);
|
||||
const key = equals === -1 ? line : line.substring(0,equals);
|
||||
const value = equals === -1 ? '' : line.substring(equals+1);
|
||||
state.raw[key] = value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ class Teamspeak3 extends Core {
|
|||
const unit = {};
|
||||
for (const field of split) {
|
||||
const equals = field.indexOf('=');
|
||||
const key = equals === -1 ? field : field.substr(0,equals);
|
||||
const value = equals === -1 ? '' : field.substr(equals+1)
|
||||
const key = equals === -1 ? field : field.substring(0, equals);
|
||||
const value = equals === -1 ? '' : field.substring(equals + 1)
|
||||
.replace(/\\s/g,' ').replace(/\\\//g,'/');
|
||||
unit[key] = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class Tribes1 extends Core {
|
|||
if (!str) return [];
|
||||
return ('?'+str)
|
||||
.split('\t')
|
||||
.map((a) => a.substr(1).trim().toLowerCase())
|
||||
.map((a) => a.substring(1).trim().toLowerCase())
|
||||
.map((a) => a === 'team name' ? 'name' : a)
|
||||
.map((a) => a === 'player name' ? 'name' : a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ function splitFields(str,subMode) {
|
|||
}
|
||||
for (const one of split) {
|
||||
const equal = one.indexOf(splitter);
|
||||
const key = equal === -1 ? one : one.substr(0,equal);
|
||||
const key = equal === -1 ? one : one.substring(0,equal);
|
||||
if(!key || key === '\0') continue;
|
||||
const value = equal === -1 ? '' : one.substr(equal+splitter.length);
|
||||
const value = equal === -1 ? '' : one.substring(equal+splitter.length);
|
||||
if(!subMode && key === 'CHANNEL') out.CHANNELS.push(splitFields(value,true));
|
||||
else if(!subMode && key === 'CLIENT') out.CLIENTS.push(splitFields(value,true));
|
||||
else out[key] = value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue