# mpbf

> a fork of pbf, the low-level, lightweight protocol buffer implementation in JavaScript, but built for ESM-based projects

Latest version **0.1.2** (published 2023-07-26) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install mpbf
pnpm add mpbf
yarn add mpbf
bun add mpbf
```

Provides the command `mpbf`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2023-07-26 |
| First published | 2023-07-26 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 41.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | measuredweighed |
| Maintainers | measured-weighed |
| Keywords | protocol, buffer, pbf, mpbf, protobuf, binary, format, serialization, encoder, decoder |

## Links

- npm: https://www.npmjs.com/package/mpbf
- Repository: https://github.com/measuredweighed/mpbf
- Issues: https://github.com/measuredweighed/mpbf/issues
- npm.io page: https://npm.io/package/mpbf

## Dependencies (1)

- [resolve-protobuf-schema](https://npm.io/package/resolve-protobuf-schema.md) ^2.1.0

## 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

- 0.1.2 (latest) — 2023-07-26
- 0.1.1 — 2023-07-26
- 0.1.0 — 2023-07-26

## README

# Mpbf

M(odular)pbf is a fork of [pbf](https://github.com/mapbox/pbf), the low-level, fast, ultra-lightweight (3KB gzipped) JavaScript library for decoding and encoding [protocol buffers](https://developers.google.com/protocol-buffers). Mpbf generates code for use in ESM-based projects. 

## Examples

#### Using Compiled Code

Install `mpbf` and compile a JavaScript module from a `.proto` file:

```bash
$ npm install -g mpbf
$ mpbf example.proto > example.js
```

Then read and write objects using the module like this:

```js
import { Pbf } from 'mbpf';
import { Example } from './example.js';

// read
const pbf = new Pbf(buffer);
const obj = Example.read(pbf);

// write
const pbf = new Pbf();
Example.write(obj, pbf);
const buffer = pbf.finish();
```

## Install

```bash
npm install mpbf
```

## Proto Schema to JavaScript

If installed globally, `mpbf` provides a binary that compiles `proto` files into JavaScript modules. Usage:

```bash
$ mpbf <proto_path> [--no-write] [--no-read]
```

The `--no-write` and `--no-read` switches remove corresponding code in the output.

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