UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

19 lines (18 loc) 1.01 kB
import { type TreeElement } from "../util/element.js"; /** * Base class for an extractor that converts input into a tree element. * - Extractors are composable: outer extractors delegate to inner extractors. * - The output type is always a `TreeElement` (or a more specific subtype). */ export declare abstract class Extractor<I, O extends TreeElement = TreeElement> { /** Extract a tree element from the given input. */ abstract extract(input: I): O | Promise<O>; } /** * Merge two tree elements — `primary` keeps its identity (`type`, `key`, `source`); `secondary` contributes any * metadata `primary` does not already have. * - `title` and `description` are taken from `primary` when set, otherwise from `secondary` — primary stays canonical * but a missing field falls back rather than disappearing. * - `content` and `children` from both are concatenated (primary first). */ export declare function mergeTreeElements<T extends TreeElement>(primary: T, secondary: TreeElement): T;