From 6144c56cc576db8597bb73e5de5093ea26155998 Mon Sep 17 00:00:00 2001 From: luin Date: Sun, 22 Jul 2018 22:50:29 +0800 Subject: [PATCH] fix: resolve warning for Buffer() in Node.js 10 --- lib/redis.js | 2 +- lib/redis/parser.js | 2 +- lib/utils/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/redis.js b/lib/redis.js index 5dc1081c..1eff2837 100644 --- a/lib/redis.js +++ b/lib/redis.js @@ -597,7 +597,7 @@ Redis.prototype.sendCommand = function (command, stream) { if (!writable && command.name === 'quit' && this.offlineQueue.length === 0) { this.disconnect(); - command.resolve(new Buffer('OK')); + command.resolve(Buffer.from('OK')); return command.promise; } diff --git a/lib/redis/parser.js b/lib/redis/parser.js index 713cb425..f3bedd74 100644 --- a/lib/redis/parser.js +++ b/lib/redis/parser.js @@ -71,7 +71,7 @@ exports.returnError = function (err) { var sharedBuffers = {}; _.forEach(['message', 'pmessage', 'subscribe', 'psubscribe', 'unsubscribe', 'punsubscribe'], function (str) { - sharedBuffers[str] = new Buffer(str); + sharedBuffers[str] = Buffer.from(str); }); exports.returnReply = function (reply) { if (this.status === 'monitoring') { diff --git a/lib/utils/index.js b/lib/utils/index.js index e5213065..5e9c9d21 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -35,7 +35,7 @@ exports.bufferEqual = function (a, b) { * @return {*} The result * @example * ```js - * var input = [new Buffer('foo'), [new Buffer('bar')]]; + * var input = [Buffer.from('foo'), [Buffer.from('bar')]]; * var res = convertBufferToString(input, 'utf8'); * expect(res).to.eql(['foo', ['bar']]); * ```