You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 27, 2019. It is now read-only.
__`gzipSize`:__ The size of the stylesheet gzipped in bytes
171
+
#### `rules` object
53
172
54
-
__`selectors`:__ An array of selectors sorted by source order with the selector string, specificity score, and parts array
173
+
-`total` number - total number of rules
174
+
-`size` object
175
+
-`size.graph` array - ruleset sizes (number of declarations per rule) in source order
176
+
-`size.max` number - maximum ruleset size
177
+
-`size.average` number - average ruleset size
55
178
56
-
__`declarations`:__ An object of declarations.
57
-
-`declarations.all`: An array of declaration objects from PostCSS.
58
-
-`declarations.byProperty`: An object with keys for each property found in the stylesheet.
59
-
-`declarations.unique`: An object with keys for each unique property/value found in the stylesheet.
60
-
-`declarations.byMedia`: An object with keys for each media query found in the stylesheet.
61
-
-`declarations.propertyResetDeclarations`: An object with keys for each property with a value of `0` found in the stylesheet. (Actually only margins and paddings are counted)
62
-
-`declarations.importantCount`: The number of declarations with values that contain `!important`
63
-
-`declarations.vendorPrefixCount`: The number of declaration properties that have vendor prefixes.
64
-
-`declarations.displayNoneCount`: The number of `display: none;` declarations.
65
-
-`declarations.uniqueDeclarationsCount`: The number of unique declarations.
179
+
#### `selectors` object
66
180
67
-
__`rules`:__ Flattened array of rules from PostCSS.
181
+
-`total` number - total number of selectors
182
+
-`type` number - total number of type selectors
183
+
-`class` number - total number of class selectors
184
+
-`id` number - total number of id selectors
185
+
-`pseudoClass` number - total number of pseudo class selectors
186
+
-`pseudoElement` number - total number of pseudo element selectors
187
+
-`values` array - array of strings for all selectors
188
+
-`specificity` object
189
+
-`specificity.max` number - maximum specificity as a base 10 number
190
+
-`specificity.average` number - average specificity as a base 10 number
191
+
-`getSpecificityGraph()` function - returns an array of numbers for each selector’s specificity as a base 10 number
192
+
-`getRepeatedValues()` function - returns an array of strings of repeated selectors
193
+
-`getSortedSpecificity()` function - returns an array of selectors with base 10 specificity score, sorted from highest to lowest
68
194
69
-
__`aggregates`:__ Aggregate data for the entire stylesheet.
70
-
-`selectors` - total number of selectors
71
-
-`declarations` - total number of declarations
72
-
-`properties` - an array of properties used in the stylesheet
73
-
-`mediaQueries` - an array of media query strings used in the stylesheet
74
-
-`idSelectors` - total number of selectors containing an id
75
-
-`classSelectors` - total number of selectors containing a class
76
-
-`pseudoElementSelectors` - total number of selectors containing an pseudo element
77
-
-`pseudoClassSelectors` - total number of selectors containing a pseudo class
78
-
-`repeatedSelectors` - array of selectors that were declared more than once
195
+
#### `declarations` object
79
196
80
-
For every unique property found in the stylesheet, `aggregates` also includes these values:
81
-
-`[property].total` - total number of [property] declarations
82
-
-`[property].unique` - number of unique [property] declarations
197
+
-`total` number - total number of declarations
198
+
-`properties` object - object with each unique property and an array of that property’s values
199
+
-`getPropertyResets()` function - returns an object with the number of times margin or padding is reset for each property
200
+
-`getUniquePropertyCount(property)` function - returns the number of unique values for the given property
201
+
-`getPropertyValueCount(property, value)` function - returns the number of times a declaration occurs for the given property and value
202
+
-`getVendorPrefixed()` function - returns an array of declarations with vendor prefixed properties
203
+
-`getAllFontSizes()` function - returns an array of font sizes from both `font-size` and `font` shorthand declarations
204
+
-`getAllFontFamilies()` function - returns an array of font families from both `font-family` and `font` shorthand declarations
205
+
-`important` array (optional) - `!important` declaration objects with `property` and `value`
206
+
207
+
#### `mediaQueries` object
208
+
209
+
-`total` number - total number of media queries
210
+
-`unique` number - total unique media queries
211
+
-`values` array - array of values for each media query
212
+
-`contents` array - array of media query blocks with full stats object for each
83
213
84
214
85
215
See the `/test/results` folder for example JSON results.
216
+
217
+
### Usage examples
218
+
219
+
```js
220
+
var cssstats =require('cssstats')
221
+
var stats =cssstats(css)
222
+
```
223
+
224
+
#### Generate a [specificity graph](http://csswizardry.com/2014/10/the-specificity-graph/)
225
+
226
+
```js
227
+
var specificityGraph =stats.selectors.getSpecificityGraph()
228
+
```
229
+
230
+
#### Sort selectors by highest specificity
231
+
232
+
```js
233
+
var sortedSelectors =stats.selectors.getSortedSpecificity()
234
+
```
235
+
236
+
#### Get total number of unique colors
237
+
238
+
```js
239
+
var uniqueColorsCount =stats.declarations.getUniquePropertyCount('color')
240
+
```
241
+
242
+
#### `display: none` count
243
+
244
+
```js
245
+
var displayNoneCount =stats.declarations.getPropertyValueCount('display', 'none')
0 commit comments