MCPcopy Index your code
hub / github.com/darkreader/darkreader / sortDeclarations

Function sortDeclarations

src/utils/css-text/format-css.ts:44–58  ·  view source on GitHub ↗
(declarations: ParsedDeclaration[])

Source from the content-addressed store, hash-verified

42}
43
44function sortDeclarations(declarations: ParsedDeclaration[]) {
45 const prefixRegex = /^-[a-z]-/;
46 return [...declarations].sort((a, b) => {
47 const aProp = a.property;
48 const bProp = b.property;
49 const aPrefix = aProp.match(prefixRegex)?.[0] ?? '';
50 const bPrefix = bProp.match(prefixRegex)?.[0] ?? '';
51 const aNorm = aPrefix ? aProp.replace(prefixRegex, '') : aProp;
52 const bNorm = bPrefix ? bProp.replace(prefixRegex, '') : bProp;
53 if (aNorm === bNorm) {
54 return aPrefix.localeCompare(bPrefix);
55 }
56 return aNorm.localeCompare(bNorm);
57 });
58}
59
60function clearEmptyRules(rules: Array<ParsedAtRule | ParsedStyleRule>) {
61 for (let i = rules.length - 1; i >= 0; i--) {

Callers 1

formatStyleRuleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…