code format stdlize

This commit is contained in:
lion 2025-10-20 19:09:37 +08:00
parent 567224ca60
commit b3383680f9
1 changed files with 4 additions and 4 deletions

View File

@ -156,19 +156,19 @@ function _ipv4_to_string(v4Bytes) {
// ipv6 bytes to string // ipv6 bytes to string
function _ipv6_to_string(v6Bytes, compress) { function _ipv6_to_string(v6Bytes, compress) {
let ps = [], needCompress = false; let ps = [], needCompress = false;
let last_hex = -1, hex = 0; let lastHex = -1, hex = 0;
for (var i = 0; i < v6Bytes.length; i += 2) { for (var i = 0; i < v6Bytes.length; i += 2) {
hex = v6Bytes.readUint16BE(i).toString(16); hex = v6Bytes.readUint16BE(i).toString(16);
ps.push(hex); ps.push(hex);
// check the necessity for compress // check the necessity for compress
if (last_hex > -1 if (lastHex > -1
&& hex == 0 && last_hex == 0) { && hex == 0 && lastHex == 0) {
needCompress = true; needCompress = true;
} }
// reset the last hex // reset the last hex
last_hex = hex; lastHex = hex;
} }
if (needCompress == false || compress === false) { if (needCompress == false || compress === false) {