function signature
signature(
source: string,
line: number
): string

The declaration a line starts, up to where its body begins.

What a signature is FOR is telling you how to call something, so it stops at the { — and only at one that opens a body, not one inside a parameter's type or default. Multi-line signatures come back whole, since a parameter list broken over four lines is still one thing to read.

import { signature } from './docs.ts';

signature('export function helper(value: number): number {\n  return 1;\n}', 1);
// 'export function helper(value: number): number'
signature('const a = 1;', 1); // 'const a = 1;' — nothing opens, so it is all of it

Parameters

source: string
line: number

Return Type

string

Usage

import { signature } from "lib/repl/docs.ts";