diff --git a/lib/ip.js b/lib/ip.js index 4b2adb5..36dddcb 100644 --- a/lib/ip.js +++ b/lib/ip.js @@ -58,7 +58,7 @@ ip.toBuffer = function (ip, buff, offset) { return result; }; -ip.toString = function (buff, offset, length) { +function ipToString(buff, offset, length) { offset = ~~offset; length = length || (buff.length - offset); @@ -81,6 +81,7 @@ ip.toString = function (buff, offset, length) { return result; }; +Object.defineProperty(ip, 'toString', { value: ipToString, writable: true, enumerable: true, configurable: true }); const ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/; const ipv6Regex = /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;