# mugipack

> A small library to encode unicode strings or objects to base64

Latest version **1.0.2** (published 2018-08-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install mugipack
pnpm add mugipack
yarn add mugipack
bun add mugipack
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-08-11 |
| First published | 2017-10-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Doronin Stanislav |
| Maintainers | mugiseyebrows |
| Keywords | base64, serialize, compress, unicode |

## Links

- npm: https://www.npmjs.com/package/mugipack
- Repository: https://github.com/mugiseyebrows/mugipack
- Homepage: https://github.com/mugiseyebrows/mugipack#readme
- Issues: https://github.com/mugiseyebrows/mugipack/issues
- npm.io page: https://npm.io/package/mugipack

## 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.0.2 (latest) — 2018-08-11
- 1.0.1 — 2017-10-15

## README

# Mugipack
A small library to encode unicode strings or objects to base64
# How to use

## In browser

Add library
```html
<script type="text/javascript" src="mugipack.min.js"></script>
```
Instantiate and use
```javascript
var mugipack = new MugiPack();
var encoded = mugipack.encode({foo:'👍',bar:'❤'});
var decoded = mugipack.decode(encoded);
```
## In node

run `npm install mugipack --save`

```javascript
var mugipack = require('mugipack')
var encoded = mugipack.encode({foo:'👍',bar:'❤'})
var decoded = mugipack.decode(encoded)
```

# Rationale
`btoa()` is limited to ascii strings only, of course there are [ways to overcome this](https://developer.mozilla.org/ru/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem), which depend on escaping or other libraries. I wish there was an easy way...

# Algorithm
Object json-stringified, string converted to charcodes, every pair of charcodes encoded with one or two base64 symbols, resulted string prepended with dictionary (rules to convert it back) and some metadata. Numbers in dictionary and metadata converted to base62 to save more space (one symbol reserved as chunk separator '/' and one as array element separator '+', so it's 62 not 64)

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