method ReplSession.whenPaused
ReplSession.whenPaused(listener: (where: string) => void): void

Called when the page stops with nothing waiting on it — a breakpoint reached by a timer, or by anything else the prompt did not start.

Without it such a pause is silent: the prompt keeps taking input, and every line of it evaluates in a frame nobody was told about. That is the whole reason it exists — a pause the prompt CAUSED comes back on ReplResult.pausedAt and needs no listener, so this covers only the ones that arrive on their own.

import type { ReplSession } from './session.ts';

// Defined, not invoked: a real session owns a browser and a bound port.
function announce(session: ReplSession, log: (line: string) => void) {
  // `setTimeout(() => { debugger; }, 1000)` stops the page a second after the line answered.
  session.whenPaused((where) => log(`paused at ${where} — \`.continue\` to carry on`));
}

Parameters

listener: (where: string) => void

Return Type

void

Usage

import { type ReplSession } from "lib/repl/session.ts";