import { AnyConstructor } from '../meta'; import { TreeNode, TreeNodeRoot } from '../tree'; import { SelectionGedcom } from './internal'; /** * A selection of Gedcom nodes, represented in an array-like datastructure. */ export declare class SelectionAny implements ArrayLike { #private; /** * The number of nodes in the selection. * @category Base */ length: number; /** * The nodes in the selection. * @category Base */ [n: number]: TreeNode; /** * The common root node of the elements in this selection. * @category Base */ rootNode: TreeNodeRoot; /** * @param rootNode * @param nodes * @category Base */ constructor(rootNode: TreeNodeRoot, nodes: TreeNode[]); /** * Returns an array of {@link TreeNode.tag}. * @category Base */ tag(): (string | null)[]; /** * Returns an array of {@link TreeNode.pointer}. * @category Base */ pointer(): (string | null)[]; /** * Returns an array of {@link TreeNode.value}. * @category Base */ value(): (string | null)[]; /** * Calls {@link value} and filters out null values. * @category Base */ valueNonNull(): string[]; /** * Wraps the value of {@link rootNode} in {@link SelectionGedcom}. * The selection will contain exactly one node. * @category Base */ root(): SelectionGedcom; /** * Query the direct children of this node. * It is possible to efficiently filter the results by tag and pointer. * Leaving either or both of these parameter empty will result in a wildcard behavior (not filtering). * In most cases this method is not useful as the functionality is already implemented in the subclasses through various more precise methods. * Returns an array of children. * @param tag Optionally filter the results by their Gedcom tag * @param pointer Optionally filter the result by their pointer value * @category Base */ get(tag?: string | string[] | null, pointer?: string | string[] | null): SelectionAny; /** * Query the direct children of this node. * It is possible to efficiently filter the results by tag and pointer. * Leaving either or both of these parameter empty will result in a wildcard behavior (not filtering). * In most cases this method is not useful as the functionality is already implemented in the subclasses through various more precise methods. * Returns an array of children. * Additionally, allows the specification of an adapter class. * @param tag Optionally filter the results by their Gedcom tag * @param pointer Optionally filter the result by their pointer value * @param adapter The adapter class, see {@link as} * @category Base */ get(tag: string | string[] | null, pointer: string | string[] | null, adapter: AnyConstructor): N; /** * Filter nodes from the selection based on a predicate. * @param f The filtering predicate * @category Base */ filter(f: (node: TreeNode) => boolean): this; /** * Filter lifted nodes from the selection based on a predicate. * The argument is a selection of one node. * @param f The filtering predicate * @category Base */ filterSelect(f: (node: this) => boolean): this; /** * View this selection as a different type. This method can be used to extend functionality for non-standard Gedcom files. * @param Adapter The class adapter * @category Base */ as(Adapter: AnyConstructor): N; /** * Export the selection as an array of nodes. * The inverse operation is {@link of}. * @category Base */ array(): TreeNode[]; /** * Exports the selection as an array of selections of one element. * @category Base */ arraySelect(): this[]; /** * Returns a concatenation of two selections. * The right hand side selection should be a subtype of the left hand side's. * The resulting selection will be the same type as the left hand side's. * @param other The right hand side selection * @category Base */ concatenate(other: N): this; /** * Returns a concatenation of two selections. * The right hand side selection should be a subtype of the left hand side's. * The resulting selection will be the same type as the left hand side's, with the elements of the right hand side's first. * @param other The right hand side selection * @category Base */ concatenateLeft(other: N): this; /** * Returns a sorted selection, with respect to the comparator. * The default comparator relies on the {@link TreeNode.indexSource} attribute. * @param comparator The comparator * @category Base */ sorted(comparator?: (a: TreeNode, b: TreeNode) => number): this; /** * Checks whether two selections are equal. * Note that the strategy used here is reference equality, hence for this method to return true, the nodes must be the same references (and in the same order). * @param other The selection to compare it against * @category Base */ equals(other: SelectionAny): boolean; /** * Returns a string representation for this selection. * @category Base */ toString(): string; /** * Create a selection from an array of nodes. * It is highly recommended (but not required) for the nodes to be at the same logical level in the hierarchy. * The inverse operation is {@link array}. * @param previous The previous selection, required to inherit the reference to the root * @param nodes The nodes to be included in the selection * @category Base */ static of(previous: SelectionAny, nodes: TreeNode[] | TreeNode): SelectionAny; /** * Create a selection from an array of nodes. * It is highly recommended (but not required) for the nodes to be at the same logical level in the hierarchy. * The inverse operation is {@link array}. * @param previous The previous selection, required to inherit the reference to the root * @param nodes The nodes to be included in the selection * @param Adapter The adapter class, see {@link as} * @category Base */ static of(previous: SelectionAny, nodes: TreeNode[] | TreeNode, Adapter: AnyConstructor): N; }