# @juanelas/base64

> Base64 for both node.js and browser javascript. It supports URL-safe encoding and enabling/disabling padding. Buffers can be implementedd using ArrayBuffer, any TypedArray, or Buffer

Latest version **1.1.5** (published 2023-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @juanelas/base64
pnpm add @juanelas/base64
yarn add @juanelas/base64
bun add @juanelas/base64
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2023-11-10 |
| First published | 2021-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 42 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Juan Hernández Serrano |
| Maintainers | juanelasisme |
| Keywords | base64, base64url, Buffer, ArrayBuffer, TypedArray, Uint8Array |

## Links

- npm: https://www.npmjs.com/package/@juanelas/base64
- Repository: https://github.com/juanelas/base64
- Homepage: https://github.com/juanelas/base64#readme
- Issues: https://github.com/juanelas/base64/issues
- npm.io page: https://npm.io/package/@juanelas/base64

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2023-11-10
- 1.1.4 — 2023-10-06
- 1.1.3 — 2023-10-06
- 1.1.2 — 2023-04-14
- 1.1.0 — 2023-04-09
- 1.0.5 — 2022-08-01
- 1.0.4 — 2021-12-04
- 1.0.3 — 2021-11-19
- 1.0.1 — 2021-10-15
- 1.0.0 — 2021-10-15

## README

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Node.js CI](https://github.com/juanelas/base64/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/juanelas/base64/actions/workflows/build-and-test.yml)
[![Coverage Status](https://coveralls.io/repos/github/juanelas/base64/badge.svg?branch=main)](https://coveralls.io/github/juanelas/base64?branch=main)

# @juanelas/base64

Base64 for both node.js and browser javascript. It supports URL-safe encoding and enabling/disabling padding. Buffers can be implementedd using ArrayBuffer, any TypedArray, or Buffer.

## Usage

`@juanelas/base64` can be imported to your project with `npm`:

```console
npm install @juanelas/base64
```

Then either require (Node.js CJS):

```javascript
const base64 = require('@juanelas/base64')
```

or import (JavaScript ES module):

```javascript
import * as base64 from '@juanelas/base64'
```

The appropriate version for browser or node is automatically exported. Types for TypeScript users are also provided.

You can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/base64/main/dist/bundle.iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/base64/main/dist/esm/bundle.min.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/base64/main/dist/bundle.umd.js) and manually add it to your project, or, if you have already installed `@juanelas/base64` in your project, just get the bundles from `node_modules/@juanelas/base64/dist/bundles/`.

An example of usage could be:

```typescript
import * as base64 from '@juanelas/base64'

const buf = new Uint8Array([254, 1, 128, 255])
const base64str = base64.encode(buf, true, false) // URL-safe base64 with no padding

console.log(base64str) // Outputs: '_gGA_w'

const buf2 = base64.decode(base64str) // URL-safe encoding and padding are automatically detected

console.log(buf2.toString()) // Outputs: '254,1,128,255'

const text = 'fooba'
const base64str2 = base64.encode(text) // Standard base64 with padding

console.log(base64str2) // Outputs: 'Zm9vYmE='

const text2 = base64.decode(base64str2, true) // Output to unicode string instead of Uint8Array

console.log(text2) // Outputs: 'fooba'

```

## API reference documentation

[Check the API](./docs/API.md)

---
_Source: https://npm.io/package/@juanelas/base64 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
