WebRun Ports

Send/recieve calls or streams over MessageChannel Ports

The @statewalker/webrun-ports JavaScript library offers a set of utilities designed for handling asynchronous calls and managing the exchange of data streams through MessageChannel Ports.

This library enables the initiation of calls and receipt of responses across bidirectional channels, utilizing MessagePort instances provided by MessageChannel. The methods in this library guarantee that each call is either processed or rejected, ensuring no indefinite hangs. In cases where the peer fails to handle the request appropriately or if the request exceeds a specified time limit, a timeout exception is raised on the caller’s side.

In addition to these fundamental calling functionalities, the library includes an implementation of asynchronous iterators. Clients can send, and servers can handle, asynchronous iterators, serving as a foundation for bidirectional communication using AsyncIterators.

High-level methods to perform individual calls over MessagePort instances: