# @atcute/varint

> protobuf-style LEB128 varint codec library

Latest version **2.0.2** (published 2026-07-16) · 0BSD license · 0 weekly downloads

## Install

```sh
npm install @atcute/varint
pnpm add @atcute/varint
yarn add @atcute/varint
bun add @atcute/varint
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2026-07-16 |
| First published | 2024-08-18 |
| Weekly downloads | 0 |
| License | 0BSD |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 519 |
| Maintainers | externdefs |

## Links

- npm: https://www.npmjs.com/package/@atcute/varint
- Repository: https://github.com/mary-ext/atcute
- npm.io page: https://npm.io/package/@atcute/varint

## Recent versions

- 2.0.2 (latest) — 2026-07-16
- 2.0.1 — 2026-06-29
- 2.0.0 — 2026-02-12
- 1.0.4 — 2026-02-10
- 1.0.3 — 2025-10-09
- 1.0.2 — 2024-12-29
- 1.0.1 — 2024-11-06
- 1.0.0 — 2024-08-18

## README

# @atcute/varint

protobuf-style LEB128 varint codec.

```sh
npm install @atcute/varint
```

```ts
import { encode, decode, encodingLength } from '@atcute/varint';

// encoding
const encoded: number[] = [];
const bytesWritten = encode(420, encoded);
// -> encoded: [164, 3]
// -> bytesWritten: 2

// decoding
const { value, nextOffset } = decode(encoded);
// -> value: 420
// -> nextOffset: 2

// check encoding length beforehand
encodingLength(420); // -> 2
encodingLength(16383); // -> 2
encodingLength(16384); // -> 3
```

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