From f9fd8eaf357cfe178cc6e3f919e44578e9ec5af8 Mon Sep 17 00:00:00 2001 From: NinjaManatee Date: Mon, 22 Jul 2024 12:14:21 -0400 Subject: [PATCH] Replaced Buffer constructor with Buffer.from and Buffer.alloc --- lib/matcher-stream.js | 4 ++-- lib/unzip-stream.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/matcher-stream.js b/lib/matcher-stream.js index 6818160..c3090c5 100644 --- a/lib/matcher-stream.js +++ b/lib/matcher-stream.js @@ -14,7 +14,7 @@ function MatcherStream(patternDesc, matchFn) { this.requiredLength = this.pattern.length; if (patternDesc.requiredExtraSize) this.requiredLength += patternDesc.requiredExtraSize; - this.data = new Buffer(''); + this.data = Buffer.from(''); this.bytesSoFar = 0; this.matchFn = matchFn; @@ -57,7 +57,7 @@ MatcherStream.prototype.checkDataChunk = function (ignoreMatchZero) { var finished = this.matchFn ? this.matchFn(this.data, this.bytesSoFar) : true; if (finished) { - this.data = new Buffer(''); + this.data = Buffer.from(''); return; } diff --git a/lib/unzip-stream.js b/lib/unzip-stream.js index 1a503b5..21a8c38 100644 --- a/lib/unzip-stream.js +++ b/lib/unzip-stream.js @@ -44,7 +44,7 @@ function UnzipStream(options) { stream.Transform.call(this); this.options = options || {}; - this.data = new Buffer(''); + this.data = Buffer.from(''); this.state = states.STREAM_START; this.skippedBytes = 0; this.parsedEntity = null; @@ -306,7 +306,7 @@ UnzipStream.prototype._prepareOutStream = function (vars, entry) { }; if (!fileSizeKnown) { - var pattern = new Buffer(4); + var pattern = Buffer.alloc(4); pattern.writeUInt32LE(SIG_DATA_DESCRIPTOR, 0); var zip64Mode = vars.extra.zip64Mode; var extraSize = zip64Mode ? 20 : 12; @@ -662,7 +662,7 @@ UnzipStream.prototype._parseOrOutput = function (encoding, cb) { this.data = this.data.slice(remaining); } else { packet = this.data; - this.data = new Buffer(''); + this.data = Buffer.from(''); } this.outStreamInfo.written += packet.length; @@ -675,7 +675,7 @@ UnzipStream.prototype._parseOrOutput = function (encoding, cb) { } } else { var packet = this.data; - this.data = new Buffer(''); + this.data = Buffer.from(''); this.outStreamInfo.written += packet.length; var outputStream = this.outStreamInfo.stream;