UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

36 lines (35 loc) 1.82 kB
import { Value } from './value'; /** * A readonly wrapper that enforces compile-time checking on an element's name. * * For example, requiring a signature to use NamedElement<'foo'> will force the caller to assert that an element's name * is foo. As long as types aren't being dynamically casted, this is also backed by the compiler. * * It also provides convenience methods on top of the Element API. */ export declare class NamedElement<T extends string> { private readonly element; readonly name: T; private constructor(); /** Creates a NamedNode from a document node. */ static of<T extends string = string>(element: Element): NamedElement<T>; /** Determines if the node has the given name. */ isNamed<S extends string>(name: S): this is NamedElement<S>; /** Casts the underlying node to an Element. */ native(): Element; children<S extends string>(...tagNames: S[]): Array<NamedElement<S>>; /** Returns the first _descendant_ node matching the tag name. Defaults to null. */ first<S extends string>(tagName: S): NamedElement<S> | null; /** Returns all _descendant_ node matching the tag name. */ all<S extends string>(tagName: S): Array<NamedElement<S>>; /** Returns the next _sibling_ node matching the tag name. */ next<S extends string>(tagName: S): NamedElement<S> | null; /** Returns the previous _sibling_ node matching the tag name. */ previous<S extends string>(tagName: S): NamedElement<S> | null; /** Returns the _ancestor_ matching the tag name. Defaults to null. */ ancestor<S extends string>(tagName: S): NamedElement<S> | null; /** Returns an attr wrapper for the attribute of the given name. */ attr(name: string): Value<null>; /** Returns the text content of the node. */ content(): Value<null>; }