Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /** * Returns an array of unique values for the given attribute from a series array. * If the attribute is not present on the series, attempts to get it from the first instance. * @param {Array} series - The series array to extract attributes from. * @param {string} attribute - The attribute name to extract. * @returns {Array} Array of unique attribute values. */ export function getUniqueAttributeFromList(series, attribute) { return series.reduce((prev, curr) => { let value = curr[attribute]; Iif (!value && curr.instances && curr.instances[0]) { value = curr.instances[0][attribute]; } Iif (value && prev.indexOf(value) === -1) { prev.push(value); } return prev; }, []); } |