INNER CODE UNIT · JavaScript
CommandError
sebastiancarlos/beachpatrol · beachmsg.js:34
class CommandError extends Error {
constructor(kind, message) {
super(message);
this.kind = kind;
}
}
// Connect to an instance endpoint, send a command, and stream the output
// lines as an async generator. Each yield is one output line as it arrives.
// A failure throws a CommandError.
const sendCommand = async function* (endpoint, command, { timeout } = {}) {
const client = connect(endpoint, () => {
client.write(JSON.stringify(command));
});
const rl = createInterface({ input: client });
// Stop iteration after timeout, if any.
let timedOut = false;