# btoa-lite

> Smallest/simplest possible means of using btoa with both Node and browserify

Latest version **1.0.0** (published 2015-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install btoa-lite
pnpm add btoa-lite
yarn add btoa-lite
bun add btoa-lite
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-06-25 |
| First published | 2015-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/btoa-lite) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | btoa, base64, isomorphic, browser, node, shared |

## Links

- npm: https://www.npmjs.com/package/btoa-lite
- Repository: https://github.com/hughsk/btoa-lite
- Issues: https://github.com/hughsk/btoa-lite/issues
- npm.io page: https://npm.io/package/btoa-lite

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-06-25

## README

# btoa-lite
![](http://img.shields.io/badge/stability-stable-orange.svg?style=flat)
![](http://img.shields.io/npm/v/btoa-lite.svg?style=flat)
![](http://img.shields.io/npm/dm/btoa-lite.svg?style=flat)
![](http://img.shields.io/npm/l/btoa-lite.svg?style=flat)

Smallest/simplest possible means of using btoa with both Node and browserify.

In the browser, encoding base64 strings is done using:

``` javascript
var encoded = btoa(decoded)
```

However in Node, it's done like so:

``` javascript
var encoded = new Buffer(decoded).toString('base64')
```

You can easily check if `Buffer` exists and switch between the approaches
accordingly, but using `Buffer` anywhere in your browser source will pull
in browserify's `Buffer` shim which is pretty hefty. This package uses
the `main` and `browser` fields in its `package.json` to perform this
check at build time and avoid pulling `Buffer` in unnecessarily.

## Usage

[![NPM](https://nodei.co/npm/btoa-lite.png)](https://nodei.co/npm/btoa-lite/)

### `encoded = btoa(decoded)`

Returns the base64-encoded value of a string.

## License

MIT. See [LICENSE.md](http://github.com/hughsk/btoa-lite/blob/master/LICENSE.md) for details.

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