From eef3a5eb8a421cd479bdb999f9742161da62083b Mon Sep 17 00:00:00 2001 From: David Michaud Date: Tue, 14 May 2019 13:19:34 -0400 Subject: [PATCH] replace all new Buffer with Buffer.from and Buffer.alloc --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 66c4054..fbde244 100644 --- a/src/index.js +++ b/src/index.js @@ -140,7 +140,7 @@ class PNG { } })(); - this.imgData = new Buffer(this.imgData); + this.imgData = Buffer.from(this.imgData); return; break; @@ -185,7 +185,7 @@ class PNG { const pixelBytes = this.pixelBitlength / 8; const scanlineLength = pixelBytes * this.width; - const pixels = new Buffer(scanlineLength * this.height); + const pixels = Buffer.alloc(scanlineLength * this.height); const {length} = data; let row = 0; let pos = 0; @@ -288,7 +288,7 @@ class PNG { decodePalette() { const {palette} = this; const transparency = this.transparency.indexed || []; - const ret = new Buffer(transparency.length + palette.length); + const ret = Buffer.alloc(transparency.length + palette.length); let pos = 0; const {length} = palette; let c = 0; @@ -361,7 +361,7 @@ class PNG { } decode(fn) { - const ret = new Buffer(this.width * this.height * 4); + const ret = Buffer.alloc(this.width * this.height * 4); return this.decodePixels(pixels => { this.copyToImageData(ret, pixels); return fn(ret);