Skip to content

@jsvision/core / createTerminalQuery

Function: createTerminalQuery() ​

createTerminalQuery(options?): ManagedTerminalQuery

Defined in: host/terminal-query.ts:70

Create a real, tty-backed TerminalQuery over a pair of Node streams.

write(data) sends the request string to output. read() returns an AsyncIterable that yields each input chunk as a Uint8Array; bytes arriving between iterations are buffered so none are dropped, and the input listener is detached when you stop iterating or call ManagedTerminalQuery.close. The caller must ensure the input stream is already in raw mode and flowing.

Always call close() when done so the input listener is released.

Parameters ​

options? ​

TerminalQueryOptions = {}

Injectable input/output streams (default: process standard streams).

Returns ​

ManagedTerminalQuery

A managed query object; feed it to resolveCapabilitiesAsync.

Example ​

ts
import { createTerminalQuery, resolveCapabilitiesAsync } from '@jsvision/core';

// With stdin in raw mode and flowing, detect capabilities by asking the terminal.
const query = createTerminalQuery(); // defaults to process.stdin/stdout
try {
  const { profile } = await resolveCapabilitiesAsync({ query });
  console.error('color depth:', profile.colorDepth);
} finally {
  query.close();
}