@webref/css 7.0.0-alpha → 7.0.2-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -3
- package/README.md +41 -16
- package/css.json +3253 -3230
- package/index.js +24 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -6,4 +6,27 @@ async function listAll({folder = __dirname} = {}) {
|
|
|
6
6
|
return JSON.parse(json);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
async function index({folder = __dirname} = {}) {
|
|
10
|
+
const nonIndexed = await listAll(folder);
|
|
11
|
+
const indexed = {};
|
|
12
|
+
for (const [category, features] of Object.entries(nonIndexed)) {
|
|
13
|
+
indexed[category] = {};
|
|
14
|
+
for (const feature of features) {
|
|
15
|
+
// A handful of features have different definitions for different scopes.
|
|
16
|
+
// When that happens, the feature identifier needs to be disambiguated.
|
|
17
|
+
let id = feature.name;
|
|
18
|
+
let dupl = null;
|
|
19
|
+
if (feature.for) {
|
|
20
|
+
dupl = features.find(f => f !== feature && f.name === feature.name);
|
|
21
|
+
}
|
|
22
|
+
if (dupl) {
|
|
23
|
+
// Note: scopes of different definitions are necessarily disjoint
|
|
24
|
+
id += ' for ' + feature.for[0];
|
|
25
|
+
}
|
|
26
|
+
indexed[category][id] = feature;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return indexed;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = {listAll, index};
|