UNPKG

438 BJavaScriptView Raw
1
2function expandMap(attrsMap) {
3 return Object.entries(attrsMap).
4 reduce((result, [key, value]) => (value ? [...result, key] : result), []);
5}
6
7export default function joinDataTestAttributes(...attrs) {
8 return attrs.
9 filter(attr => !!attr).
10 reduce((result, attr) => {
11 if (typeof attr === 'object') {
12 return [...result, ...expandMap(attr)];
13 }
14 return [...result, attr];
15 }, []).
16 join(' ');
17}