
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
protobuf-codec
Advanced tools
protobuf-codec
Minimal Protocol Buffers wire encoding/decoding
import Writer from 'protobuf-codec/encoding/writer'
import { uint64, string } from 'protobuf-codec/encoding/types'
const w = new Writer()
w.varint(1, 1024n, uint64) // myInt
w.varint(2, 'Hello world', string) // myString
const buf = w.concat()
import Reader from 'protobuf-codec/decoding/reader'
import { uint64, string } from 'protobuf-codec/decoding/types'
const buf = new Uint8Array([ /* ... */ ])
const myInt = 0n
const myString = ''
for (const [fieldNumber, { data }] of reader(buf)) {
switch (fieldNumber) {
case 1:
myInt = uint64(data); break
case 2:
myString = string(data); break
}
}
const writer = new Writer(prealloc = 256)
writer.varint(fieldNumber, value, [codec])
writer.bytes(fieldNumber, value, [codec])
writer.fixed64(fieldNumber, value, [codec])
writer.fixed32(fieldNumber, value, [codec])
const buf = writer.concat([buf], [byteOffset])
const iter = reader(buf, [byteOffset], [byteLength])
const msg = new Uint8Array([ /* ... */ ])
for (const [fieldNumber, field] of reader(msg)) {
const {
tagByteOffset,
tagByteLength,
// The tag is essentially `fieldNumber << 3 | wireType`
fieldNumber,
wireType,
// Total length of the data, eg. including a length prefix or extra bytes for varints
dataByteLength,
// The actually value of the field decoded based on the wireType:
//
// - varint: bigint
// - fixed32: Uint8Array subarray
// - fixed64: Uint8Array subarray
// - bytes: Uint8Array subarray
//
// The fixed size integers are represented as Uint8Arrays since there's no easy way
// to cast a integer to a double/float without using DataView's, which in turn expect
// a TypedArray
data
} = field
// ...
}
npm install protobuf-codec
FAQs
Minimal Protocol Buffers wire encoding/decoding
The npm package protobuf-codec receives a total of 8 weekly downloads. As such, protobuf-codec popularity was classified as not popular.
We found that protobuf-codec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.