Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Jabher/parcel-plugin-pbf
Protocol Buffer plugin for Parcel bundler (via pbf)
https://github.com/Jabher/parcel-plugin-pbf
Last synced: 3 months ago
JSON representation
Protocol Buffer plugin for Parcel bundler (via pbf)
- Host: GitHub
- URL: https://github.com/Jabher/parcel-plugin-pbf
- Owner: Jabher
- Created: 2018-12-03T11:52:29.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-21T18:04:10.000Z (about 6 years ago)
- Last Synced: 2024-11-15T00:42:02.395Z (3 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-parcel - Protobuf - Plugin to compile [Protocol Buffer](https://developers.google.com/protocol-buffers/) binary protocol schemas with [pbf](https://github.com/mapbox/pbf). (Plugins / Templates)
README
Parcel-plugin-pbf
---
[Protocol Buffers](https://developers.google.com/protocol-buffers/) support in [Parcel](https://parceljs.org/) via [pbf](https://npmjs.com/package/pbf) library#### How to install
use
```npm install parcel-plugin-pbf```
or
```yarn add parcel-plugin-pbf```and then `require()` or `import` `.proto` files.
Parcel will do everything else for you: it will detect `parcel-plugin-` module in `node_modules` folder and will turn on compilation of `.proto` files.
#### API
```
import Pbf from 'pbf'interface PbfMessage {
read (value: Pbf): mixed,write (value: mixed, pbf: Pbf): void
}module ProtobufferModule {
declare module.exports: {
[string]: PbfMessage
}
}
```#### Examples
Use [pbf](https://npmjs.com/package/pbf) as reference - this plugin utilizes its compiler.
```proto
// Envelope.proto
syntax = "proto3";message Envelope {
map kv = 1;
map kn = 2;
}
```
```typescript
import Pbf from 'pbf'
import {Envelope} from './envelope.proto'export function decode(buffer: Buffer): Object {
return Envelope.read(new Pbf(buffer))
}export function encode(object: Object): Buffer {
const pbf = new Pbf()
Envelope.write(object, pbf)
const buffer = pbf.finish()
return buffer
}```
#### Things to do
- [ ] source maps support
- [ ] tests