JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q30718F
  • License MIT

Protocol Buffers RPC utility module for pull-streams

Package Exports

  • pull-pb-rpc

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 (pull-pb-rpc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pull-pb-rpc

Protocol Buffers RPC utility module for pull-streams

Usage

const conn = getConnectionSomehow()
const PBRPC = require('pull-pb-rpc')
const pbRPC = PBRPC()
const rpc = pbRPC.rpc

pull(
  conn,
  pbRPC,
  conn
)

rpc.read(Request).then(request => {
  // ...
})

API

Constructor:

  • opts.timeout: Number Default timeout for reading
  • opts.lpFixed: Boolean Whether to use fixed length-prefixes instead of varInt ones
  • opts.lpMaxLength: Number Default maximum message length in bytes for length-prefixed reads

.read(Proto[, max, timeout, fixed]) Read a Protocol Buffers message

  • Proto: Protocol Buffers Protocol as returned by protons
  • max: Number Maximum message length in bytes
  • timeout: Number Timeout for reading
  • fixed: Boolean Flag whether to use fixed length-prefixes instead of varInt ones

.write(Proto, data[, fixed]) Write a Protocol Buffers message

  • Proto: Protocol Buffers Protocol as returned by protons
  • data: Object Message payload
  • fixed: Boolean Flag whether to use fixed length-prefixes instead of varInt ones

.readLP([max, timeout, fixed]) Read a length-prefixed message

  • max: Number Maximum message length in bytes
  • timeout: Number Timeout for reading
  • fixed: Boolean Flag whether to use fixed length-prefixes instead of varInt ones

.writeLP(data[, fixed]) Write a length-prefixed message

  • data: Buffer Message payload
  • fixed: Boolean Flag whether to use fixed length-prefixes instead of varInt ones

.readRaw(bytes[, timeout]) Read bytes

  • bytes: Number Amount of bytes to read
  • timeout: Number Timeout for reading

.writeRaw(data) Write bytes

  • data: Buffer Message payload