function depth
depth(source: string): number

How many brackets are open at the end of the source — what a continuation prompt counts.

Counted from tokens rather than characters, so a brace inside a string or a comment is text and not a level: '{' leaves you exactly where you were.

import { depth } from './highlight.ts';

depth('const a = {'); // 1
depth('const a = { b: [');  // 2
depth("const a = { b: '}' "); // 1 — the brace in the string is not a brace

Parameters

source: string

Return Type

number

Usage

import { depth } from "lib/repl/highlight.ts";