# int32-encoding

> Int32 encoding, a simple way to convert 32-bit signed integers to Uint8Arrays, and vice versa.

Latest version **1.0.1** (published 2025-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install int32-encoding
pnpm add int32-encoding
yarn add int32-encoding
bun add int32-encoding
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2025-01-15 |
| First published | 2023-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | fabiospampinato |
| Keywords | int32, uint8array, encoding |

## Links

- npm: https://www.npmjs.com/package/int32-encoding
- Repository: https://github.com/fabiospampinato/int32-encoding
- Homepage: https://github.com/fabiospampinato/int32-encoding#readme
- Issues: https://github.com/fabiospampinato/int32-encoding/issues
- npm.io page: https://npm.io/package/int32-encoding

## 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.1 (latest) — 2025-01-15
- 1.0.0 — 2023-08-07

## README

# Int32 Encoding

Int32 encoding, a simple way to convert 32-bit signed integers to Uint8Arrays, and vice versa.

The produced Uint8Array will always be 4-bytes long.

## Install

```sh
npm install int32-encoding
```

## Usage

```ts
import Int32 from 'int32-encoding';

{ // It works with positive 32-bit numbers
  const encoded = Int32.encode ( 1234567890 ); // => Uint8Array(4) [73, 150, 2, 210]
  const decoded = Int32.decode ( new Uint8Array ([ 73, 150, 2, 210 ]) ); // => 1234567890
}

{ // It works with negative 32-bit numbers
  const encoded = Int32.encode ( -1234567890 ); // => Uint8Array(4) [182, 105, 253, 46]
  const decoded = Int32.decode ( new Uint8Array ([ 182, 105, 253, 46 ]) ); // => -1234567890
}
```

## License

MIT © Fabio Spampinato

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