Skip to content

Commit

Permalink
Fix "inspect" function deprecation notice
Browse files Browse the repository at this point in the history
Fixes #1326
  • Loading branch information
zbjornson committed Jan 21, 2019
1 parent b968c8a commit 2cf57e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
### Added
### Fixed
* PDF metadata (added in 2.3.0) wasn't being set with `canvas.createPDFStream()`
* Fix custom "inspect" function deprecation warnings (#1326)

2.3.1
==================
Expand Down
5 changes: 4 additions & 1 deletion 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) {
Expand Down Expand Up @@ -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 [
Expand Down
15 changes: 5 additions & 10 deletions lib/canvas.js
Expand Up @@ -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.
Expand Down
13 changes: 3 additions & 10 deletions lib/image.js
Expand Up @@ -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;

Expand Down Expand Up @@ -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 : '')
Expand Down

0 comments on commit 2cf57e0

Please sign in to comment.