This module makes it easy to send and receive length-prefixed Protobuf encoded messages over streams.
import { pbStream } from 'it-protobuf-stream'import { MessageType } from './src/my-message-type.js'// RequestType and ResponseType have been generate from `.proto` files and have// `.encode` and `.decode` methods for serialization/deserializationconst stream = pbStream(duplex)// write a message to the streamstream.write({ foo: 'bar'}, MessageType)// read a message from the streamconst res = await stream.read(MessageType) Copy
import { pbStream } from 'it-protobuf-stream'import { MessageType } from './src/my-message-type.js'// RequestType and ResponseType have been generate from `.proto` files and have// `.encode` and `.decode` methods for serialization/deserializationconst stream = pbStream(duplex)// write a message to the streamstream.write({ foo: 'bar'}, MessageType)// read a message from the streamconst res = await stream.read(MessageType)
This module makes it easy to send and receive length-prefixed Protobuf encoded messages over streams.
Example