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;