From: bluelovers Date: Thu, 7 Mar 2019 14:48:38 +0000 (+0800) Subject: [bugfix] Make nodejs util inspect happy X-Git-Tag: 2.25.0~67^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39dcea824ad0f10b2d0d773657cf5ba878092c4e;p=thirdparty%2Fmoment.git [bugfix] Make nodejs util inspect happy Newer versions of nodejs use a special symbol for inspecting a value instead of the old-school obj.inspect function. --- diff --git a/src/lib/moment/prototype.js b/src/lib/moment/prototype.js index bd8fff79c..1d0d08d14 100644 --- a/src/lib/moment/prototype.js +++ b/src/lib/moment/prototype.js @@ -51,6 +51,11 @@ proto.toObject = toObject; proto.toDate = toDate; proto.toISOString = toISOString; proto.inspect = inspect; +if (typeof Symbol !== undefined && Symbol.for != null) { + proto[Symbol.for('nodejs.util.inspect.custom')] = function () { + return 'Moment<' + this.format() + '>'; + }; +} proto.toJSON = toJSON; proto.toString = toString; proto.unix = unix;