From 3b63328c2f8bc066d8b12022818d7110b9aaad0b Mon Sep 17 00:00:00 2001 From: Robert Rosebury Date: Thu, 21 May 2020 10:30:07 +0100 Subject: [PATCH] #78 Change from Buffer constructors to Buffer.from() --- .gitignore | 2 ++ src/data-type-formats.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 17dfa0b4..6f4c7fef 100644 --- a/.gitignore +++ b/.gitignore @@ -155,3 +155,5 @@ crashlytics.properties crashlytics-build.properties fabric.properties +# VS Code +.history \ No newline at end of file diff --git a/src/data-type-formats.js b/src/data-type-formats.js index 873c51fd..0a49bea5 100644 --- a/src/data-type-formats.js +++ b/src/data-type-formats.js @@ -32,7 +32,7 @@ exports.binary = { const length = value.length; const array = []; for (let i = 0; i < length; i += 8) array.push(parseInt(value.substr(i, 8), 2)) - return Buffer.from ? Buffer.from(array, 'binary') : new Buffer(array, 'binary'); + return Buffer.from(array, 'binary'); } }, @@ -81,7 +81,7 @@ exports.byte = { if (!rx.byte.test(value) || value.length % 4 !== 0) { exception.message('Expected a base64 string'); } else { - return Buffer.from ? Buffer.from(value, 'base64') : new Buffer(value, 'base64'); + return Buffer.from(value, 'base64'); } } else { exception.message('Expected a base64 string');