# bigint-conversion

> Convert to/from BigInt from/to Buffer, ArrayBuffer, hex string, utf8-encoded text string.

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

## Install

```sh
npm install bigint-conversion
pnpm add bigint-conversion
yarn add bigint-conversion
bun add bigint-conversion
```

## 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 | 2.4.3 |
| Published | 2023-11-10 |
| First published | 2020-02-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 97.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Juan Hernández Serrano |
| Maintainers | juanelasisme |
| Keywords | BigInt, bignum, big integer, text, utf8, hex, Buffer, ArrayBuffer, TypedArray |

## Links

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

## Dependencies (1)

- [@juanelas/base64](https://npm.io/package/@juanelas/base64.md) ^1.1.2

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 2.4.3 (latest) — 2023-11-10
- 2.4.2 — 2023-09-05
- 2.4.1 — 2023-04-14
- 2.4.0 — 2023-04-09
- 2.3.0 — 2022-11-08
- 2.2.2 — 2022-08-02
- 2.2.1 — 2021-10-18
- 2.1.12 — 2020-10-27
- 2.1.11 — 2020-05-18
- 2.1.10 — 2020-04-30
- 2.1.9 — 2020-04-18
- 2.1.8 — 2020-04-15
- 2.1.6 — 2020-04-14
- 2.1.4 — 2020-04-12
- 2.1.2 — 2020-03-24
- … 10 more at https://npm.io/package/bigint-conversion/versions

## README

[![Licence: 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/bigint-conversion/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/juanelas/bigint-conversion/actions/workflows/build-and-test.yml)
[![Coverage Status](https://coveralls.io/repos/github/juanelas/bigint-conversion/badge.svg?branch=main)](https://coveralls.io/github/juanelas/bigint-conversion?branch=main)

# bigint-conversion

Convert to/from non-negative integers represented with [ES-2020 native JS implementation of BigInt](https://tc39.es/ecma262/#sec-bigint-objects) from/to:

- `Buffer` (node.js) or `ArrayBuffer|TypedArray` (native js),
- hex `string`,
- utf8-encoded text `string`,
- standard and url-safe base64 with and without padding.

It provides a common interface for the conversions that works for both **node.js** and **native javascript**.

> Note that there is not a directly visible `TypedArray()` constructor, but a set of typed array ones: `Int8Array()`, `Uint8Array()`, `Uint8ClampedArray()`, `Int16Array()`, `Uint16Array()`, `Int32Array()`, `Uint32Array()`, `Float32Array()`, `Float64Array()`, `BigInt64Array()`, `BigUint64Array()`.

## Usage

`bigint-conversion` can be imported to your project with `npm`:

```console
npm install bigint-conversion
```

Then either require (Node.js CJS):

```javascript
const bigintConversion = require('bigint-conversion')
```

or import (JavaScript ES module):

```javascript
import * as bigintConversion from 'bigint-conversion'
```

The appropriate version for browser or node is automatically exported.

> BigInt is [ES-2020](https://tc39.es/ecma262/#sec-bigint-objects). In order to use it with TypeScript you should set `target` (and probably also `lib`) to at least `es2020` in `tsconfig.json`.

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

## API reference documentation

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

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