MCPcopy Index your code
hub / github.com/css/csso / buildIndex

Function buildIndex

lib/usage.js:43–71  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

41}
42
43export function buildIndex(data) {
44 let scopes = false;
45
46 if (data.scopes && Array.isArray(data.scopes)) {
47 scopes = Object.create(null);
48
49 for (let i = 0; i < data.scopes.length; i++) {
50 const list = data.scopes[i];
51
52 if (!list || !Array.isArray(list)) {
53 throw new Error('Wrong usage format');
54 }
55
56 for (const name of list) {
57 if (hasOwnProperty.call(scopes, name)) {
58 throw new Error(`Class can't be used for several scopes: ${name}`);
59 }
60
61 scopes[name] = i + 1;
62 }
63 }
64 }
65
66 return {
67 whitelist: buildList(data),
68 blacklist: buildList(data.blacklist),
69 scopes
70 };
71}

Callers 1

compressFunction · 0.90

Calls 1

buildListFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…