From 200fbb2360be206ef9f397612bd0969104f114fc Mon Sep 17 00:00:00 2001 From: Michael Rowley Date: Thu, 30 Dec 2021 01:40:09 +0000 Subject: [PATCH] Minor fixes --- src/core/lib/IP.mjs | 3 +-- src/core/operations/Sort.mjs | 13 +++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/lib/IP.mjs b/src/core/lib/IP.mjs index c43a0797..350bca7a 100644 --- a/src/core/lib/IP.mjs +++ b/src/core/lib/IP.mjs @@ -345,7 +345,7 @@ export function ipv4ToStr(ipInt) { * @example * // returns [65280, 0, 0, 0, 0, 0, 4369, 8738] * strToIpv6("ff00::1111:2222"); - * + * * // returns 126946n * strToIpv6("1:f000", false); */ @@ -356,7 +356,6 @@ export function strToIpv6(ipStr, retArr=true) { ipStr = "0" + ipStr; } return BigInt("0x" + ipStr.replace(":", "")); - return } let j = 0; const blocks = ipStr.split(":"), diff --git a/src/core/operations/Sort.mjs b/src/core/operations/Sort.mjs index cd3b8e76..354a01ed 100644 --- a/src/core/operations/Sort.mjs +++ b/src/core/operations/Sort.mjs @@ -60,7 +60,7 @@ class Sort extends Operation { sorted = sorted.sort(Sort._caseInsensitiveSort); } else if (order === "IPv4 address") { sorted = sorted.sort(Sort._ipv4Sort); - } else if (order == "IPv6 address") { + } else if (order === "IPv6 address") { sorted = sorted.sort(Sort._ipv6Sort); } else if (order === "Numeric") { sorted = sorted.sort(Sort._numericSort); @@ -109,14 +109,15 @@ class Sort extends Operation { /** * Comparison operator for sorting of IPv6 addresses. - * - * @param {string} a - * @param {string} b + * + * @param {string} a + * @param {string} b * @returns {number} */ static _ipv6Sort(a, b) { - const numericalA = strToIpv6(a, false), - numericalB = strToIpv6(b, false); + const ipLib = require("../lib/IP.mjs"); + const numericalA = ipLib.strToIpv6(a, false), + numericalB = ipLib.strToIpv6(b, false); return numericalA < numericalB ? -1 : 1; }