From c7cf5f7d63cbd59e683571a2a4c133edbfeda31d Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 26 Mar 2018 17:24:27 +0200 Subject: [PATCH] Use `Buffer.from()` instead of `new Buffer` (#4) The `Buffer` constructor is deprecated, we should use `Buffer.from()` instead. Refs: https://github.com/nodejs/node/issues/19079 --- blake2b.js | 2 +- example.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/blake2b.js b/blake2b.js index 4059b7c..a27b86b 100644 --- a/blake2b.js +++ b/blake2b.js @@ -53,7 +53,7 @@ function loadWebAssembly (opts) { function toUint8Array (s) { if (typeof atob === 'function') return new Uint8Array(atob(s).split('').map(charCodeAt)) - return new (require('buf' + 'fer').Buffer)(s, 'base64') + return (require('buf' + 'fer').Buffer).from(s, 'base64') } function charCodeAt (c) { diff --git a/example.js b/example.js index 390c418..1efed75 100644 --- a/example.js +++ b/example.js @@ -1,10 +1,11 @@ +'use strict' var blake2b = require('./') blake2b.ready(function () { var hash = blake2b() - .update(new Buffer('hello')) - .update(new Buffer(' ')) - .update(new Buffer('world')) + .update(Buffer.from('hello')) + .update(Buffer.from(' ')) + .update(Buffer.from('world')) .digest('hex') console.log('Blake2b hash of "hello world" is %s', hash)