diff options
author | 2022-07-16 17:23:18 -0500 | |
---|---|---|
committer | 2022-07-16 15:23:18 -0700 | |
commit | e9f376825c8eac7ed8dcf7e896c77bbe63389821 (patch) | |
tree | 8445e956b50cf4c579ee4409c3c184bee7709be3 | |
parent | 3c0f18f704fac1e27a0bc5fe82c8e084e411acb3 (diff) | |
download | bun-e9f376825c8eac7ed8dcf7e896c77bbe63389821.tar.gz bun-e9f376825c8eac7ed8dcf7e896c77bbe63389821.tar.zst bun-e9f376825c8eac7ed8dcf7e896c77bbe63389821.zip |
docs: fix documentation of `atob` and `btoa` (#748)
These function are confusingly named. `btoa` converts "Binary" to Ascii
by encoding the input using base64. `atob` reverses that process by
base64 decoding the Ascii input into a "Binary" output.
The names come from the Unix utilities with the same names, which
"converts a binary file to ascii for transmission over a telephone line"
(https://www.unix.com/man-page/minix/1/btoa/)
See:
- https://developer.mozilla.org/en-US/docs/Web/API/atob
- https://developer.mozilla.org/en-US/docs/Web/API/btoa
- https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa-dev
Note: the actual implementation of `btoa` and `atob` are correct, but
the docs were backwards.
-rw-r--r-- | types/bun/globals.d.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/types/bun/globals.d.ts b/types/bun/globals.d.ts index 5ed32b939..81e4b25cb 100644 --- a/types/bun/globals.d.ts +++ b/types/bun/globals.d.ts @@ -726,18 +726,18 @@ interface Crypto { declare var crypto: Crypto; /** - * [`atob`](https://developer.mozilla.org/en-US/docs/Web/API/atob) converts ascii text into base64. + * [`atob`](https://developer.mozilla.org/en-US/docs/Web/API/atob) decodes base64 into ascii text. * - * @param asciiText The ascii text to convert. + * @param asciiText The base64 string to decode. */ -declare function atob(asciiText: string): string; +declare function atob(encodedData: string): string; /** - * [`btoa`](https://developer.mozilla.org/en-US/docs/Web/API/btoa) decodes base64 into ascii text. + * [`btoa`](https://developer.mozilla.org/en-US/docs/Web/API/btoa) encodes ascii text into base64. * - * @param base64Text The base64 text to convert. + * @param stringToEncode The ascii text to encode. */ -declare function btoa(base64Text: string): string; +declare function btoa(stringToEncode: string): string; /** * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All |