JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q44947F
  • License BSD-3-Clause

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

Package Exports

  • mpbf
  • mpbf/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mpbf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Mpbf

M(odular)pbf is a fork of pbf, the low-level, fast, ultra-lightweight (3KB gzipped) JavaScript library for decoding and encoding 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:

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

Then read and write objects using the module like this:

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

npm install mpbf

Proto Schema to JavaScript

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

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

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