Projects
Mega:24.03:SP1:Everything
nodejs-grunt-legacy-util
_service:tar_scm:0001-Fix-Buffer-warnings-by-sw...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0001-Fix-Buffer-warnings-by-switching-to-Buffer.from.patch of Package nodejs-grunt-legacy-util
From 6be9fdb20b77842151aa52d49e9dab183345b4b1 Mon Sep 17 00:00:00 2001 From: lei_ju <lj3074194431@163.com> Date: Thu, 3 Dec 2020 15:34:48 +0800 Subject: [PATCH] Fix Buffer warnings by switching to Buffer.from diff --git a/index.js b/index.js index a61d9cc..7f389e6 100644 --- a/index.js +++ b/index.js @@ -182,16 +182,16 @@ util.spawn = function(opts, done) { } var child = spawn(cmd, args, opts.opts); - var stdout = new Buffer(''); - var stderr = new Buffer(''); + var stdout = Buffer.from(''); + var stderr = Buffer.from(''); if (child.stdout) { child.stdout.on('data', function(buf) { - stdout = Buffer.concat([stdout, new Buffer(buf)]); + stdout = Buffer.concat([stdout, Buffer.from(buf)]); }); } if (child.stderr) { child.stderr.on('data', function(buf) { - stderr = Buffer.concat([stderr, new Buffer(buf)]); + stderr = Buffer.concat([stderr, Buffer.from(buf)]); }); } child.on('close', function(code) { diff --git a/test/fixtures/spawn-multibyte.js b/test/fixtures/spawn-multibyte.js index 8277711..b592341 100644 --- a/test/fixtures/spawn-multibyte.js +++ b/test/fixtures/spawn-multibyte.js @@ -4,7 +4,7 @@ // A multibyte buffer containing all our output. We will slice it later. // In this case we are using a Japanese word for hello / good day, where each // character takes three bytes. -var fullOutput = new Buffer('こんにちは'); +var fullOutput = Buffer.from('こんにちは'); // Output one full character and one third of a character process.stdout.write(fullOutput.slice(0, 4)); diff --git a/test/index.js b/test/index.js index 4a657be..55cf79f 100644 --- a/test/index.js +++ b/test/index.js @@ -477,10 +477,10 @@ exports['util.recurse'] = { 'buffer': function(test) { test.expect(1); var actual = util.recurse({ - buf: new Buffer('buf'), + buf: Buffer.from('buf'), }, this.typeValue); var expected = { - buf: {type: 'buffer', value: new Buffer('buf')}, + buf: {type: 'buffer', value: Buffer.from('buf')}, }; test.deepEqual(actual, expected, 'Should not mangle Buffer instances.'); test.done(); -- 2.23.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2