diff --git a/lib/DOMMatrix.js b/lib/DOMMatrix.js index 3c5262449..5c43c62a7 100644 --- a/lib/DOMMatrix.js +++ b/lib/DOMMatrix.js @@ -1,5 +1,7 @@ 'use strict' +const util = require('util') + // DOMMatrix per https://drafts.fxtf.org/geometry/#DOMMatrix function DOMPoint(x, y, z, w) { @@ -127,7 +129,8 @@ DOMMatrix.fromFloat64Array = function (init) { return new DOMMatrix(init) } -DOMMatrix.prototype.inspect = function (depth, options) { +// TODO || is for Node.js pre-v6.6.0 +DOMMatrix.prototype[util.inspect.custom || 'inspect'] = function (depth, options) { if (depth < 0) return '[DOMMatrix]' return `DOMMatrix [ diff --git a/lib/canvas.js b/lib/canvas.js index cd43ff868..2ba013f65 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -17,17 +17,12 @@ const PNGStream = require('./pngstream') const PDFStream = require('./pdfstream') const JPEGStream = require('./jpegstream') const FORMATS = ['image/png', 'image/jpeg'] +const util = require('util') -/** - * Inspect canvas. - * - * @return {String} - * @api public - */ - -Canvas.prototype.inspect = function(){ - return '[Canvas ' + this.width + 'x' + this.height + ']'; -}; +// TODO || is for Node.js pre-v6.6.0 +Canvas.prototype[util.inspect.custom || 'inspect'] = function () { + return `[Canvas ${this.width}x${this.height}]` +} /** * Get a context object. diff --git a/lib/image.js b/lib/image.js index 9313b997d..74003ffd1 100644 --- a/lib/image.js +++ b/lib/image.js @@ -14,6 +14,7 @@ const bindings = require('./bindings') const Image = module.exports = bindings.Image const http = require("http") const https = require("https") +const util = require('util') const {GetSource, SetSource} = bindings; @@ -72,16 +73,8 @@ Object.defineProperty(Image.prototype, 'src', { configurable: true }); -/** - * Inspect image. - * - * TODO: indicate that the .src was a buffer, data uri etc - * - * @return {String} - * @api public - */ - -Image.prototype.inspect = function(){ +// TODO || is for Node.js pre-v6.6.0 +Image.prototype[util.inspect.custom || 'inspect'] = function(){ return '[Image' + (this.complete ? ':' + this.width + 'x' + this.height : '') + (this.src ? ' ' + this.src : '')