@openxmldev/linq-to-xml
Version:
LINQ to XML for TypeScript
39 lines • 1.12 kB
JavaScript
/**
* @author Thomas Barnekow
* @license MIT
*/
import { LinqIterableBase } from './LinqIterable.js';
/**
* Provides additional methods specific to a `LinqIterable<XAttribute>`.
*/
export class LinqAttributes extends LinqIterableBase {
/**
* Initializes a new instance with the given source sequence.
*
* @param source The source sequence.
*/
constructor(source) {
super(source, linqAttributes);
}
/**
* Removes each `XAttribute` represented in this sequence from its parent
* `XElement`.
*/
remove() {
const attributes = [...this.source];
for (const attribute of attributes) {
if (attribute)
attribute.remove();
}
}
}
/**
* Converts an `Iterable<XAttribute>` into a LINQ-style iterable.
*
* @param source The source `Iterable<XAttribute>`.
* @returns A `LinqAttributes` instance.
*/
export function linqAttributes(source) {
return source instanceof LinqAttributes ? source : new LinqAttributes(source);
}
//# sourceMappingURL=LinqAttributes.js.map