UNPKG

@openxmldev/linq-to-xml

Version:
39 lines 1.1 kB
/** * @author Thomas Barnekow * @license MIT */ import { ancestors, remove } from './transformations/index.js'; import { LinqIterableBase, LinqElements } from './internal.js'; /** * Provides additional methods specific to a `LinqIterable<XNode>`. */ export class LinqNodes extends LinqIterableBase { /** * Initializes a new instance with the given source sequence. * * @param source The source sequence. */ constructor(source) { super(source, linqNodes); } ancestors(name) { return new LinqElements(ancestors(name)(this.source)); } /** * Removes each `XNode` represented in this sequence from its parent * `XContainer`. */ remove() { remove(this.source); } } /** * Converts an `Iterable<XNode>` into a LINQ-style iterable. * * @param source The source `Iterable<XNode>`. * @returns A `LinqNodes` instance. */ export function linqNodes(source) { return source instanceof LinqNodes ? source : new LinqNodes(source); } //# sourceMappingURL=LinqNodes.js.map