Package Exports
- @thi.ng/base-n
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thi.ng/base-n) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
This project is part of the @thi.ng/umbrella monorepo.
About
Arbitrary base-n conversions w/ presets for base16/32/36/58/62/64/85, support for arrays & bigints.
Status
STABLE - used in production
Search or submit any issues for this package
Installation
yarn add @thi.ng/base-n
// ES module
<script type="module" src="https://unpkg.com/@thi.ng/base-n?module" crossorigin></script>
// UMD
<script src="https://unpkg.com/@thi.ng/base-n/lib/index.umd.js" crossorigin></script>
Package sizes (gzipped, pre-treeshake): ESM: 811 bytes / CJS: 919 bytes / UMD: 995 bytes
Dependencies
API
import { BASE85, defBase } from "@thi.ng/base-n";
BASE85.encodeBigInt(2n ** 128n - 1);
// '=r54lj&NUUO~Hi%c2ym0'
BASE85.decodeBigInt("=r54lj&NUUO~Hi%c2ym0").toString(16);
// 'ffffffffffffffffffffffffffffffff'
// define a custom base impl
const ternary = defBase("012");
ternary.encode(12345678)
// '212020020002100'
ternary.decode("212020020002100");
// 12345678
Authors
Karsten Schmidt
If this project contributes to an academic publication, please cite it as:
@misc{thing-base-n,
title = "@thi.ng/base-n",
author = "Karsten Schmidt",
note = "https://thi.ng/base-n",
year = 2017
}
License
© 2017 - 2021 Karsten Schmidt // Apache Software License 2.0