UNPKG

@openxmldev/linq-to-xml

Version:
31 lines 1.04 kB
/** * @author Thomas Barnekow * @license MIT */ import { getAttributes, XAttribute } from '../internal.js'; /** * Returns a function that, for the elements of the source sequence passed to * that function, returns the concatenated sequences of attributes of such * elements. * * If a name is provided, the resulting sequence contains only those attributes * having a matching name. * * @param name The optional name used to filter the sequence of attributes. * @returns A function that will return a flat sequence of attributes. */ export function attributes(name) { return function (source) { return name !== null ? getManyAttributes(source, name !== null && name !== void 0 ? name : null) : XAttribute.emptySequence; }; } function* getManyAttributes(source, name) { for (const element of source) { for (const attribute of getAttributes(element, name)) { yield attribute; } } } //# sourceMappingURL=attributes.js.map