-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetKeysInGroup.js
More file actions
31 lines (20 loc) · 867 Bytes
/
getKeysInGroup.js
File metadata and controls
31 lines (20 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import bcdf from './data/bcdf.json' with { type: 'json' };
import { features } from "web-features";
const groupKey = 'web-components';
const getFeaturesAsArray = features => {
return Object.keys(features).map(featureKey => {
const feature = features[featureKey];
feature.key = featureKey;
return feature;
});
};
const getKeysInGroup = groupKey => {
const featuresArray = getFeaturesAsArray(features);
const getFeaturesInGroup = group => featuresArray.filter(f => f.group && f.group.includes(groupKey));
const featuresInGroup = getFeaturesInGroup(groupKey);
const featureKeys = featuresInGroup.map(f => f.key).sort();
const tags = featureKeys.map(key => `web-features:${key}`);
const keysInGroup = bcdf.filter(key => key.tags && key.tags.some(tag => tags.includes(tag)));
return keysInGroup;;
};
export default getKeysInGroup;