Skip to content

Commit

Permalink
rm Median metric (#410)
Browse files Browse the repository at this point in the history
closes #390
  • Loading branch information
bartveneman authored Jul 12, 2024
1 parent d8d6b1b commit ae8ec84
Show file tree
Hide file tree
Showing 22 changed files with 24 additions and 278 deletions.
94 changes: 24 additions & 70 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ A <b>CSS analyzer</b> that goes through your CSS to find all kinds of relevant s

## Features

* Extremely **detailed** (150+ metrics)
* Super **[fast](/benchmark)**
* Supports both NodeJS and browsers
- Extremely **detailed** (150+ metrics)
- Super **[fast](/benchmark)**
- Supports both NodeJS and browsers

## Install

Expand All @@ -37,7 +37,7 @@ npm install @projectwallace/css-analyzer
### Analyzing CSS

```js
import { analyze } from '@projectwallace/css-analyzer'
import { analyze } from "@projectwallace/css-analyzer";

const result = analyze(`
p {
Expand All @@ -48,8 +48,9 @@ const result = analyze(`
.component[data-state="loading"] {
background-color: whitesmoke;
}
`)
`);
```

<details>
<summary>More examples output can be found in <a href="src/__fixtures__">the fixtures folder</a> and looks roughly like this:</summary>

Expand Down Expand Up @@ -126,82 +127,40 @@ const result = analyze(`
"max": 1,
"mean": 1,
"mode": 1,
"median": 1,
"range": 0,
"sum": 2,
"items": [
1,
1
]
"items": [1, 1]
},
"declarations": {
"min": 1,
"max": 2,
"mean": 1.5,
"mode": 1.5,
"median": 1.5,
"range": 1,
"sum": 3,
"items": [
2,
1
]
"items": [2, 1]
}
},
"selectors": {
"total": 2,
"totalUnique": 2,
"uniquenessRatio": 1,
"specificity": {
"sum": [
0,
2,
1
],
"min": [
0,
0,
1
],
"max": [
0,
2,
0
],
"mean": [
0,
1,
0.5
],
"mode": [
0,
1,
0.5
],
"median": [
0,
1,
0.5
],
"sum": [0, 2, 1],
"min": [0, 0, 1],
"max": [0, 2, 0],
"mean": [0, 1, 0.5],
"mode": [0, 1, 0.5],
"items": [
[
0,
0,
1
],
[
0,
2,
0
]
[0, 0, 1],
[0, 2, 0]
]
},
"complexity": {
"min": 1,
"max": 3,
"mean": 2,
"mode": 2,
"median": 2,
"range": 2,
"sum": 4,
"total": 2,
Expand All @@ -211,10 +170,7 @@ const result = analyze(`
"3": 1
},
"uniquenessRatio": 1,
"items": [
1,
3
]
"items": [1, 3]
},
"id": {
"total": 0,
Expand Down Expand Up @@ -379,18 +335,19 @@ const result = analyze(`
}
}
```

</details>

### Comparing specificity

```js
import { compareSpecificity } from '@projectwallace/css-analyzer'
import { compareSpecificity } from "@projectwallace/css-analyzer";

const result = [
[0,1,1],
[2,0,0],
[0,0,1],
].sort((a, b) => compareSpecificity(a, b))
[0, 1, 1],
[2, 0, 0],
[0, 0, 1],
].sort((a, b) => compareSpecificity(a, b));

// => result:
// [
Expand All @@ -399,16 +356,13 @@ const result = [
// [0,0,1],
// ]

const isSpecificityEqual = compareSpecificity(
[0,1,0],
[0,1,0]
) === 0
const isSpecificityEqual = compareSpecificity([0, 1, 0], [0, 1, 0]) === 0;
// => isSpecificityEqual: true
```

## Related projects

- [CSS Code Quality Analyzer](https://github.com/projectwallace/css-code-quality) -
- [CSS Code Quality Analyzer](https://github.com/projectwallace/css-code-quality) -
A Code Quality analyzer that tells you how maintainable, complex and performant your CSS is
- [Wallace CLI](https://github.com/projectwallace/wallace-cli) - CLI tool for
@projectwallace/css-analyzer
Expand Down
13 changes: 0 additions & 13 deletions src/__fixtures__/bol-com-20231008.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@
"max": 1,
"mean": 1,
"mode": 1,
"median": 1,
"range": 0,
"sum": 1061
}
Expand All @@ -286,7 +285,6 @@
"max": 73,
"mean": 3.4047571457125723,
"mode": 2,
"median": 2,
"range": 71,
"sum": 17034,
"items": [
Expand Down Expand Up @@ -5332,7 +5330,6 @@
"max": 70,
"mean": 1.3260043973615832,
"mode": 1,
"median": 1,
"range": 69,
"sum": 6634,
"items": [
Expand Down Expand Up @@ -10368,7 +10365,6 @@
"max": 26,
"mean": 2.0787527483509893,
"mode": 1,
"median": 1,
"range": 25,
"sum": 10400,
"items": [
Expand Down Expand Up @@ -15433,11 +15429,6 @@
1,
0
],
"median": [
0,
1,
0
],
"items": [
[
0,
Expand Down Expand Up @@ -48365,7 +48356,6 @@
"max": 13,
"mean": 2.2189115232593495,
"mode": 1,
"median": 1,
"range": 12,
"sum": 14596,
"total": 6578,
Expand Down Expand Up @@ -55093,7 +55083,6 @@
"max": 1,
"mean": 1,
"mode": 1,
"median": 1,
"range": 0,
"sum": 10441
}
Expand Down Expand Up @@ -55333,7 +55322,6 @@
"max": 2,
"mean": 1.0103438367972417,
"mode": 1,
"median": 1,
"range": 1,
"sum": 10549
}
Expand Down Expand Up @@ -56689,7 +56677,6 @@
"max": 2,
"mean": 1.0010535389330524,
"mode": 1,
"median": 1,
"range": 1,
"sum": 10452
},
Expand Down
13 changes: 0 additions & 13 deletions src/__fixtures__/bootstrap-5.3.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
"max": 1,
"mean": 1,
"mode": 1,
"median": 1,
"range": 0,
"sum": 115
}
Expand All @@ -173,7 +172,6 @@
"max": 119,
"mean": 3.328777821163608,
"mode": 2,
"median": 2,
"range": 117,
"sum": 8525,
"items": [
Expand Down Expand Up @@ -2781,7 +2779,6 @@
"max": 12,
"mean": 1.162827020695041,
"mode": 1,
"median": 1,
"range": 11,
"sum": 2978,
"items": [
Expand Down Expand Up @@ -5366,7 +5363,6 @@
"max": 117,
"mean": 2.165950800468567,
"mode": 1,
"median": 1,
"range": 116,
"sum": 5547,
"items": [
Expand Down Expand Up @@ -8000,11 +7996,6 @@
1,
0
],
"median": [
0,
1,
0
],
"items": [
[
0,
Expand Down Expand Up @@ -22895,7 +22886,6 @@
"max": 18,
"mean": 1.788021534320323,
"mode": 1,
"median": 1,
"range": 17,
"sum": 5314,
"total": 2972,
Expand Down Expand Up @@ -26003,7 +25993,6 @@
"max": 1,
"mean": 1,
"mode": 1,
"median": 1,
"range": 0,
"sum": 5547
}
Expand Down Expand Up @@ -27118,7 +27107,6 @@
"max": 2,
"mean": 1.2383270236163693,
"mode": 1,
"median": 1,
"range": 1,
"sum": 6869
}
Expand Down Expand Up @@ -30826,7 +30814,6 @@
"max": 2,
"mean": 1.0030216850337719,
"mode": 1,
"median": 1,
"range": 1,
"sum": 5643
},
Expand Down
Loading

0 comments on commit ae8ec84

Please sign in to comment.