@hexagon/base64
Advanced tools
Comparing version 1.0.12 to 1.0.13
{ | ||
"name": "@hexagon/base64", | ||
"version": "1.0.12", | ||
"description": "Base64 and base64url to string or arraybuffer, and back.", | ||
"version": "1.0.13", | ||
"description": "Base64 and base64url to string or arraybuffer, and back. Node, Deno or browser.", | ||
"author": "Hexagon <github.com/hexagon>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://hexagon.github.io/base64", |
@@ -0,11 +1,16 @@ | ||
<p align="center"> | ||
<img src="/base64.png" alt="Croner" width="200" height="200"><br> | ||
<br>Probably the only JavaScript base64 library you'll ever need.<br> | ||
</p> | ||
# @hexagon/base64 | ||
Base64 and base64url to string or arraybuffer, and back. | ||
Base64 and base64url to string or arraybuffer, and back. Works in Node, Deno or browser. | ||
[![Node.js CI](https://github.com/Hexagon/base64/actions/workflows/node.js.yml/badge.svg)](https://github.com/Hexagon/base64/actions/workflows/node.js.yml) | ||
[![npm version](https://badge.fury.io/js/@hexagon%2Fbase64.svg)](https://badge.fury.io/js/@hexagon%2Fbase64) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/4978bdbf495941c087ecb32b120f28ff)](https://www.codacy.com/gh/Hexagon/base64/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Hexagon/base64&utm_campaign=Badge_Grade) | ||
[![npm version](https://badge.fury.io/js/@hexagon%2Fbase64.svg)](https://badge.fury.io/js/@hexagon%2Fbase64) [![NPM Downloads](https://img.shields.io/npm/dm/@hexagon/base64.svg)](https://www.npmjs.org/package/@hexagon/base64) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/4978bdbf495941c087ecb32b120f28ff)](https://www.codacy.com/gh/Hexagon/base64/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Hexagon/base64&utm_campaign=Badge_Grade) | ||
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Hexagon/base64/blob/master/LICENSE) [![jsdelivr](https://data.jsdelivr.com/v1/package/gh/hexagon/base64/badge?style=rounded)](https://www.jsdelivr.com/package/gh/hexagon/base64) | ||
* Support regular base64, and base64url | ||
* Convert to/from string or ArrayBuffers | ||
* Supports regular base64, as well as base64url | ||
* Convert to/from string or arraybuffer | ||
* Works in Node.js >=4.0 (both require and import). | ||
@@ -89,4 +94,30 @@ * Works in Deno >=1.16. | ||
## API | ||
### Examples | ||
Assuming you have imported base64 as described under 'Installation'. | ||
```javascript | ||
// Encode string as regular base64 | ||
const example1enc = base64.fromString("Hellö Wörld, how are you doing today?!"); | ||
console.log(example1enc); | ||
// > SGVsbMO2IFfDtnJsZCwgaG93IGFyZSB5b3UgZG9pbmcgdG9kYXk/IQ== | ||
// Decode string as regular base64 | ||
const example1dec = base64.toString("SGVsbMO2IFfDtnJsZCwgaG93IGFyZSB5b3UgZG9pbmcgdG9kYXk/IQ=="); | ||
console.log(example1dec); | ||
// > Hellö Wörld, how are you doing today?! | ||
// Encode string as base64url (setting the second parameter to true gives base64url) | ||
const example2enc = base64.fromString("Hellö Wörld, how are you doing today?!", true); | ||
console.log(example2enc); | ||
// > SGVsbMO2IFfDtnJsZCwgaG93IGFyZSB5b3UgZG9pbmcgdG9kYXk_IQ | ||
// Decode string as base64url (setting the second parameter to true takes base64url) | ||
const example2dec = base64.toString("SGVsbMO2IFfDtnJsZCwgaG93IGFyZSB5b3UgZG9pbmcgdG9kYXk_IQ", true); | ||
console.log(example2dec); | ||
// > Hellö Wörld, how are you doing today?! | ||
``` | ||
### Full API | ||
The library encodes and decodes base64/base64url to and from ArrayBuffers | ||
@@ -93,0 +124,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39660
14
143