more optimizations
This commit is contained in:
@@ -86,18 +86,18 @@ class WTVClientCapabilities {
|
||||
|
||||
this.capabilities_table = capabilities_table;
|
||||
|
||||
var capabilities = new Array();
|
||||
const capabilities = [];
|
||||
|
||||
// might want to pass without a flag to get the table
|
||||
if (wtv_capability_flags != null) {
|
||||
|
||||
// define function to convert hex string to binary string (0s & 1s)
|
||||
var hex2bin = function (hex) {
|
||||
var binary = "";
|
||||
var remainingSize = hex.length;
|
||||
for (var p = 0; p < hex.length / 8; p++) {
|
||||
const hex2bin = function (hex) {
|
||||
let binary = "";
|
||||
let remainingSize = hex.length;
|
||||
for (let p = 0; p < hex.length / 8; p++) {
|
||||
//In case remaining hex length (or initial) is not multiple of 8
|
||||
var blockSize = remainingSize < 8 ? remainingSize : 8;
|
||||
let blockSize = remainingSize < 8 ? remainingSize : 8;
|
||||
|
||||
binary += parseInt(hex.slice(p * 8, blockSize), 16).toString(2);
|
||||
|
||||
@@ -107,18 +107,18 @@ class WTVClientCapabilities {
|
||||
}
|
||||
|
||||
// convert wtv_capability_flags to binary string, reverse the string, and split into array containing each character;
|
||||
var bitfield = hex2bin(wtv_capability_flags).split("").reverse();
|
||||
const bitfield = hex2bin(wtv_capability_flags).split("").reverse();
|
||||
this.debug("bitfield:", bitfield)
|
||||
|
||||
var add = function (flag_name, flag) {
|
||||
const add = function (flag_name, flag) {
|
||||
capabilities[flag_name] = flag;
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
let i = 0;
|
||||
// process bitfield and set capabilities
|
||||
Object.keys(bitfield).forEach(function (k) {
|
||||
// Convert binary to boolean, 0 to false, 1 to true
|
||||
var bitfield_result = (bitfield[k] == "1")
|
||||
const bitfield_result = (bitfield[k] == "1")
|
||||
|
||||
// set flags based on position of bit
|
||||
try {
|
||||
@@ -131,7 +131,6 @@ class WTVClientCapabilities {
|
||||
});
|
||||
|
||||
this.capabilities = capabilities;
|
||||
return capabilities;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -827,7 +827,7 @@ class WTVClientSessionData {
|
||||
|
||||
hasCap(cap) {
|
||||
if (this.capabilities) {
|
||||
return this.capabilities[cap] || false;
|
||||
return this.capabilities.get(cap) || false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ class WTVIRC {
|
||||
data = data.toString('ascii');
|
||||
}
|
||||
if (data.length > this.max_message_len) {
|
||||
data = data.alice(0, this.max_message_len - 2) + '\r\n';
|
||||
data = data.slice(0, this.max_message_len - 2) + '\r\n';
|
||||
this.debugLog('warn', `Data length exceeds max_message_len (${this.max_message_len}), truncating: ${data.length} > ${this.max_message_len}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user