base64-format
Version:
Re-format base64 data
56 lines (42 loc) • 1.49 kB
Markdown
# base64-format [](https://travis-ci.org/neftaly/npm-base64-format)
Re-format base64 data from one [implementation](https://en.wikipedia.org/wiki/Base64#Implementations_and_history) to another.
Variants
--------
For the latest list, please refer to [base64-variants](https://github.com/neftaly/npm-base64-variants).
* `base64`: Vanilla base64 **- default**
* `base64_64`/: Vanilla base64, with 64-char lines
* `base64_76`: Vanilla base64, with 76-char lines
* `rfc4648`: RFC 4648 (base64url)
* `rfc4648_alt`: RFC 4648 with "="
* `rfc4648_ni`: RFC 6920 (unpadded RFC 4648)
* `y64`: YUI "Y64"
* `xml`: XML-compatible
Install
-------
```shell
npm install base64-format
```
Usage
-----
```javascript
var base64Format = require("base64-format");
var options = {
from: "base64",
to: "rfc4648"
}
base64Format(options, "heLLO+/="); //=> "heLLO-_.""
```
**Note:** this module supports [currying](http://fr.umio.us/favoring-curry/).
```javascript
var rfc4648 = base64Format({ from: "base64", to: "RFC 4648" });
rfc4648("heLLO+/="); //=> "heLLO-_."
```
Options
-------
Key: type **name** *= default*
* string **from** *= "base64"*
Desired "from" base64 variant (see "Variants").
* string **to** *= "base64"*
Desired "to" base64 variant (see "Variants").
* boolean **clean** *= true*
Remove non-encoding characters (courtesy of [base64-clean](https://github.com/neftaly/npm-base64-clean))?