nerdbank-streams
Version:
Multiplexing of streams
39 lines • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.QualifiedChannelId = exports.ChannelSource = void 0;
/**
* An enumeration of the possible sources of a channel.
* @description The ordinal values are chosen so as to make flipping the perspective as easy as negating the value,
* while leaving the Seeded value unchanged.
*/
var ChannelSource;
(function (ChannelSource) {
/** The channel was offered by this MultiplexingStream instance to the other party. */
// eslint-disable-next-line @typescript-eslint/naming-convention
ChannelSource[ChannelSource["Local"] = 1] = "Local";
/** The channel was offered to this MultiplexingStream instance by the other party. */
// eslint-disable-next-line @typescript-eslint/naming-convention
ChannelSource[ChannelSource["Remote"] = -1] = "Remote";
/**
* The channel was seeded during construction via the Options.SeededChannels collection.
* This channel is to be accepted by both parties.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
ChannelSource[ChannelSource["Seeded"] = 0] = "Seeded";
})(ChannelSource || (exports.ChannelSource = ChannelSource = {}));
// tslint:disable-next-line: no-namespace
var QualifiedChannelId;
(function (QualifiedChannelId) {
function toString(id) {
const sourceName = id.source === ChannelSource.Local
? 'local'
: id.source === ChannelSource.Remote
? 'remote'
: id.source === ChannelSource.Seeded
? 'seeded'
: 'unknown';
return `${id.id} (${sourceName})`;
}
QualifiedChannelId.toString = toString;
})(QualifiedChannelId || (exports.QualifiedChannelId = QualifiedChannelId = {}));
//# sourceMappingURL=QualifiedChannelId.js.map