@sz-md/postman
v0.4.0
Published
A very simple asynchronous protocol using a 2 byte packet size header allowing for data transfers of up to 64kBytes.
Downloads
18
Readme
@sz-md/postman
A very simple asynchronous protocol using a 2 byte packet size header allowing for data transfers of up to 64kBytes.
This protcol is intended for local inter process communication (IPC), but can be used outside of that scope.
API:
const postman = require("@sz-md/postman")
const instance = await postman.create(options)
// You need to provide read/write functions like this:
instance.sendBytes = function(bytes) {
// Send "bytes" array, bytes is an Uint8Array
}
// Call receiveBytes to process incoming data (Uint8Array)
instance.receiveBytes(buffer)
// Sending messages...
instance.send("A string")
instance.send({
value: 100
})
// Receiving them:
await instance.receive()
Where options
is an object:
{
_maxQueueLength: 10 /* see @sz-md/mutex */
}