Socket
Socket
Sign inDemoInstall

@thi.ng/base-n

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/base-n

Arbitrary base-n conversions w/ presets for base8/16/32/36/58/62/64/85, support for bigints and encoding/decoding of byte arrays


Version published
Weekly downloads
758
increased by5.87%
Maintainers
1
Weekly downloads
 
Created
Source

@thi.ng/base-n

npm version npm downloads Mastodon Follow

This is a standalone project, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

About

Arbitrary base-n conversions w/ presets for base8/16/32/36/58/62/64/85, support for bigints and encoding/decoding of byte arrays.

In addition to the actual converters/encoders, the package also provides the plain character strings for each base and variations.

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/base-n

ES module import:

<script type="module" src="https://cdn.skypack.dev/@thi.ng/base-n"></script>

Skypack documentation

For Node.js REPL:

const baseN = await import("@thi.ng/base-n");

Package sizes (brotli'd, pre-treeshake): ESM: 1.01 KB

Dependencies

None

API

Generated API docs

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

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 - 2024 Karsten Schmidt // Apache License 2.0

Keywords

FAQs

Package last updated on 23 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc