@sz-md/postman

0.4.0 • Public • Published

@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 */
}

Readme

Keywords

none

Package Sidebar

Install

npm i @sz-md/postman

Weekly Downloads

0

Version

0.4.0

License

MIT

Unpacked Size

15.2 kB

Total Files

15

Last publish

Collaborators

  • sz-coder