function complete
complete(
server: REPLServer,
line: string,
cwd?: string
): void

What TAB offers: dot commands on a line that starts with one, page identifiers everywhere else.

Nothing is offered where split finds no base it is willing to evaluate — foo().b needs foo() called to know what is on it, and TAB is not consent to run somebody's function.

import { complete } from './completion.ts';

import type { REPLServer } from 'node:repl';

// Defined, not invoked: the names come from a live page.
function example(server: REPLServer) {
  const names = {
    lookup: () => ['title'],
    ask: () => Promise.resolve(['title']),
    stale: () => {},
    subscribe: () => {},
  };
  complete(server, names, 'document.ti', (_error, [hits]) => hits); // ['title']
}

Parameters

server: REPLServer
line: string
optional
cwd: string

Return Type

void

Usage

import { complete } from "lib/commands/repl/completion.ts";