From c798852df754aba54e81e0147a82b0bbad97b58e Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 3 Oct 2018 23:08:31 +0200 Subject: [PATCH] Replace deprecated calls in atob and btoa --- snippets/atob.md | 2 +- snippets/btoa.md | 2 +- test/atob/atob.js | 2 +- test/btoa/btoa.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/atob.md b/snippets/atob.md index e7fa6d167..ce01ec1e2 100644 --- a/snippets/atob.md +++ b/snippets/atob.md @@ -5,7 +5,7 @@ Decodes a string of data which has been encoded using base-64 encoding. Create a `Buffer` for the given string with base-64 encoding and use `Buffer.toString('binary')` to return the decoded string. ```js -const atob = str => new Buffer(str, 'base64').toString('binary'); +const atob = str => Buffer.from(str, 'base64').toString('binary'); ``` ```js diff --git a/snippets/btoa.md b/snippets/btoa.md index 970cee770..d24508e50 100644 --- a/snippets/btoa.md +++ b/snippets/btoa.md @@ -5,7 +5,7 @@ Creates a base-64 encoded ASCII string from a String object in which each charac Create a `Buffer` for the given string with binary encoding and use `Buffer.toString('base64')` to return the encoded string. ```js -const btoa = str => new Buffer(str, 'binary').toString('base64'); +const btoa = str => new Buffer.from(str, 'binary').toString('base64'); ``` ```js diff --git a/test/atob/atob.js b/test/atob/atob.js index 151c9ef18..6dc03b03b 100644 --- a/test/atob/atob.js +++ b/test/atob/atob.js @@ -1,2 +1,2 @@ -const atob = str => new Buffer(str, 'base64').toString('binary'); +const atob = str => Buffer.from(str, 'base64').toString('binary'); module.exports = atob; diff --git a/test/btoa/btoa.js b/test/btoa/btoa.js index 9ff0e6caf..bdff3b689 100644 --- a/test/btoa/btoa.js +++ b/test/btoa/btoa.js @@ -1,2 +1,2 @@ -const btoa = str => new Buffer(str, 'binary').toString('base64'); +const btoa = str => new Buffer.from(str, 'binary').toString('base64'); module.exports = btoa;