UNPKG

@devgrid/netron

Version:

A powerful TypeScript library for building distributed systems with event bus, streaming capabilities, and remote object invocation. Features WebSocket-based bidirectional communication between Node.js and browser environments, service discovery, and type

26 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StreamReference = void 0; const readable_stream_1 = require("./readable-stream"); const writable_stream_1 = require("./writable-stream"); class StreamReference { constructor(streamId, type, isLive, peerId) { this.streamId = streamId; this.type = type; this.isLive = isLive; this.peerId = peerId; } static from(stream) { return new StreamReference(stream.id, stream instanceof writable_stream_1.NetronWritableStream ? 'writable' : 'readable', stream.isLive, stream.peer.id); } static to(ref, peer) { if (ref.type === 'writable') { return readable_stream_1.NetronReadableStream.create(peer, ref.streamId, ref.isLive); } else { return writable_stream_1.NetronWritableStream.create(peer, undefined, ref.isLive, ref.streamId); } } } exports.StreamReference = StreamReference; //# sourceMappingURL=stream-reference.js.map