From 745643557b71ba6721d901604f269d7519cb5d7f Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 3 Feb 2018 20:11:29 +0000 Subject: [PATCH] Node: buffer.from() instead of new Buffer(array) --- backend/node.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/node.js b/backend/node.js index cdf5cd1..d552191 100644 --- a/backend/node.js +++ b/backend/node.js @@ -543,9 +543,9 @@ os.EOL; // A constant defining the appropriate End-of-line mark // Buffer is used to dealing with binary data // Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap -new Buffer(size); // Allocates a new buffer of size octets. -new Buffer(array); // Allocates a new buffer using an array of octets. -new Buffer(str, [encoding]); // Allocates a new buffer containing the given str. encoding defaults to 'utf8'. +Buffer.from(size); // Allocates a new buffer of size octets. +Buffer.from(array); // Allocates a new buffer using an array of octets. +Buffer.from(str, [encoding]); // Allocates a new buffer containing the given str. encoding defaults to 'utf8'. Buffer.isEncoding(encoding); // Returns true if the encoding is a valid encoding argument, or false otherwise. Buffer.isBuffer(obj); // Tests if obj is a Buffer