consortium
Version:
Remote control and session sharing CLI for AI coding agents
47 lines (42 loc) • 1.1 kB
JavaScript
;
var consumable = require('./consumable-jpudCE9S.cjs');
class InspectStream extends consumable.TransformStream {
constructor(callback) {
super({
transform(chunk, controller) {
callback(chunk);
controller.enqueue(chunk);
}
});
}
}
class SplitStringStream extends consumable.TransformStream {
constructor(separator) {
let remaining = void 0;
super({
transform(chunk, controller) {
if (remaining) {
chunk = remaining + chunk;
remaining = void 0;
}
let start = 0;
while (start < chunk.length) {
const index = chunk.indexOf(separator, start);
if (index === -1) {
remaining = chunk.substring(start);
break;
}
controller.enqueue(chunk.substring(start, index));
start = index + 1;
}
},
flush(controller) {
if (remaining) {
controller.enqueue(remaining);
}
}
});
}
}
exports.InspectStream = InspectStream;
exports.SplitStringStream = SplitStringStream;