diff options
author | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
commit | 2c4ae43e688a9873e86211ea0e7aeb9ba770dd77 (patch) | |
tree | 17848d95522dab25d3cdeb9c4a6450e2a234861f /alarm/node_modules/abab/README.md | |
parent | 108525534c28013cfe1897c30e4565f9893f3766 (diff) | |
download | pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.gz pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.bz2 pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.zip |
Update
Diffstat (limited to 'alarm/node_modules/abab/README.md')
-rw-r--r-- | alarm/node_modules/abab/README.md | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/alarm/node_modules/abab/README.md b/alarm/node_modules/abab/README.md new file mode 100644 index 0000000..6f32eb0 --- /dev/null +++ b/alarm/node_modules/abab/README.md @@ -0,0 +1,51 @@ +# abab [![npm version](https://badge.fury.io/js/abab.svg)](https://www.npmjs.com/package/abab) [![Build Status](https://travis-ci.org/jsdom/abab.svg?branch=master)](https://travis-ci.org/jsdom/abab) + +A JavaScript module that implements `window.atob` and `window.btoa` according the forgiving-base64 algorithm in the [Infra Standard](https://infra.spec.whatwg.org/#forgiving-base64). The original code was forked from [w3c/web-platform-tests](https://github.com/w3c/web-platform-tests/blob/master/html/webappapis/atob/base64.html). + +Compatibility: Node.js version 3+ and all major browsers. + +Install with `npm`: + +```sh +npm install abab +``` + +## API + +### `btoa` (base64 encode) + +```js +const { btoa } = require('abab'); +btoa('Hello, world!'); // 'SGVsbG8sIHdvcmxkIQ==' +``` + +### `atob` (base64 decode) + +```js +const { atob } = require('abab'); +atob('SGVsbG8sIHdvcmxkIQ=='); // 'Hello, world!' +``` + +#### Valid characters + +[Per the spec](https://html.spec.whatwg.org/multipage/webappapis.html#atob:dom-windowbase64-btoa-3), `btoa` will accept strings "containing only characters in the range `U+0000` to `U+00FF`." If passed a string with characters above `U+00FF`, `btoa` will return `null`. If `atob` is passed a string that is not base64-valid, it will also return `null`. In both cases when `null` is returned, the spec calls for throwing a `DOMException` of type `InvalidCharacterError`. + +## Browsers + +If you want to include just one of the methods to save bytes in your client-side code, you can `require` the desired module directly. + +```js +const atob = require('abab/lib/atob'); +const btoa = require('abab/lib/btoa'); +``` + +## Development + +If you're **submitting a PR** or **deploying to npm**, please use the [checklists in CONTRIBUTING.md](CONTRIBUTING.md#checklists). + +## Remembering what `atob` and `btoa` stand for + +Base64 comes from IETF [RFC 4648](https://tools.ietf.org/html/rfc4648#section-4) (2006). + +- **`btoa`**, the encoder function, stands for **binary** to **ASCII**, meaning it converts any binary input into a subset of **ASCII** (Base64). +- **`atob`**, the decoder function, converts **ASCII** (or Base64) to its original **binary** format. |