From e25e54de50419f75f0f3d226f79ec25c72fe04d6 Mon Sep 17 00:00:00 2001 From: Nodari Chkuaselidze Date: Tue, 19 Sep 2023 16:48:09 +0400 Subject: [PATCH] pkg: fix optional parameters. --- lib/ip.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/ip.js b/lib/ip.js index 0afc82e..ef3411a 100644 --- a/lib/ip.js +++ b/lib/ip.js @@ -415,8 +415,8 @@ binet.toHost = function toHost(host, port, key) { /** * Parse a hostname. * @param {String} addr - * @param {Number?} fport - Fallback port. - * @param {Buffer?} fkey - Fallback key. + * @param {Number} [fport=0] - Fallback port. + * @param {Buffer} [fkey=null] - Fallback key. * @returns {Object} Contains `host`, `port`, and `type`. */ @@ -828,7 +828,7 @@ binet.isEqual = function isEqual(a, b) { * Apply a network mask to IP. * @param {Buffer} raw * @param {Buffer} mask - * @param {Buffer?} dst + * @param {Buffer} [dst] * @returns {Buffer} */ @@ -859,7 +859,7 @@ binet.mask = function(raw, mask, dst) { * to IP from CIDR bits. * @param {Buffer} raw * @param {Number} bits - * @param {Buffer?} dst + * @param {Buffer} [dst] * @returns {Buffer} */ @@ -1477,7 +1477,7 @@ binet._interfaces = function _interfaces(filter, af) { /** * Get local IP from network interfaces. - * @param {String?} family - IP family name. + * @param {String} [family='all'] - IP family name. * @returns {String[]} */ @@ -1487,7 +1487,7 @@ binet.getInterfaces = function getInterfaces(family) { /** * Get local IP from network interfaces. - * @param {String?} family - IP family name. + * @param {String} [family='all'] - IP family name. * @returns {String[]} */ @@ -1497,7 +1497,7 @@ binet.getLocal = function getLocal(family) { /** * Get non-local IP from network interfaces. - * @param {String?} family - IP family name. + * @param {String} [family='all'] - IP family name. * @returns {String[]} */ @@ -1507,7 +1507,7 @@ binet.getNonlocal = function getNonlocal(family) { /** * Get private IP from network interfaces. - * @param {String?} family - IP family name. + * @param {String} [family='all'] - IP family name. * @returns {String[]} */ @@ -1517,7 +1517,7 @@ binet.getPrivate = function getPrivate(family) { /** * Get public IP from network interfaces. - * @param {String?} family - IP family name. + * @param {String} [family='all'] - IP family name. * @returns {String[]} */ @@ -1557,6 +1557,11 @@ function af2str(af) { throw new Error(`Invalid address family: ${af}.`); } +/** + * @param {*} family + * @returns {types} + */ + function str2af(family) { if (family == null) return types.NONE;