From 499020ed510b72509396bae85a4be39b879bcc68 Mon Sep 17 00:00:00 2001 From: nijynot Date: Thu, 13 Feb 2020 13:46:13 +0100 Subject: [PATCH] fix: Inspect deprecation warning --- src/index.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index d72db826..dd82807f 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ const varint = require('varint') const bs58 = require('bs58') const CID = require('cids') const withIs = require('class-is') +const inspect = Symbol.for('nodejs.util.inspect.custom') /** * Creates a [multiaddr](https://github.com/multiformats/multiaddr) from @@ -86,7 +87,25 @@ Multiaddr.prototype.toOptions = function toOptions () { } /** - * Returns Multiaddr as a human-readable string + * Returns Multiaddr as a human-readable string. + * For post Node.js v10.0.0. + * https://nodejs.org/api/deprecations.html#deprecations_dep0079_custom_inspection_function_on_objects_via_inspect + * + * @returns {String} + * @example + * console.log(Multiaddr('/ip4/127.0.0.1/tcp/4001')) + * // '' + */ +Multiaddr.prototype[inspect] = function inspectCustom () { + return '' +} + +/** + * Returns Multiaddr as a human-readable string. + * Fallback for pre Node.js v10.0.0. + * https://nodejs.org/api/deprecations.html#deprecations_dep0079_custom_inspection_function_on_objects_via_inspect * * @returns {String} * @example