From 2f13bde7ca479fd82d1e3c7051ed81a2fdc5ef42 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 26 Feb 2021 10:00:49 -0800 Subject: [PATCH] buffer: implement atob and btoa Signed-off-by: James M Snell Fixes: https://github.com/nodejs/node/issues/3462 --- doc/api/buffer.md | 22 +++ lib/buffer.js | 38 +++- test/fixtures/wpt/README.md | 15 +- .../wpt/html/webappapis/atob/base64.any.js | 163 ++++++++++++++++++ test/fixtures/wpt/versions.json | 48 +++--- test/wpt/status/html/webappapis/atob.json | 1 + test/wpt/test-atob.js | 19 ++ 7 files changed, 276 insertions(+), 30 deletions(-) create mode 100644 test/fixtures/wpt/html/webappapis/atob/base64.any.js create mode 100644 test/wpt/status/html/webappapis/atob.json create mode 100644 test/wpt/test-atob.js diff --git a/doc/api/buffer.md b/doc/api/buffer.md index ab357fe12486f1d..3826ee89bdcf3cb 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -3279,6 +3279,28 @@ While, the `Buffer` object is available as a global, there are additional `Buffer`-related APIs that are available only via the `buffer` module accessed using `require('buffer')`. +### `buffer.atob(data)` + + +* `data` {any} The Base64-encoded input string. + +Decodes a string of Base64-encoded data into ASCII (Latin1). + +The `data` may be any JavaScript-value that can be coerced into a string. + +### `buffer.btoa(data)` + + +* `data` {any} An ASCII (Latin1) string. + +Encodes a string of ASCII characters into a Base64-encoded string. + +The `data` may be any JavaScript-value that can be coerced into a string. + ### `buffer.INSPECT_MAX_BYTES`