MCPcopy Create free account
hub / github.com/cssstats/cssstats / parse

Function parse

packages/cssstats/index.js:28–75  ·  view source on GitHub ↗
(root, result)

Source from the content-addressed store, hash-verified

26 })
27
28 function parse(root, result) {
29 var stats = {}
30
31 const plugins = []
32 if (!opts.preserveCustomProperties) {
33 plugins.push(customProperties({ preserve: false }))
34 }
35
36 const parser = postcss()
37 plugins.forEach(plugin => parser.use(plugin))
38
39 var string = parser.process(root).css
40 stats.size = size(string)
41 stats.gzipSize = gzipSize.sync(string)
42 stats.humanizedSize = bytes(stats.size, { decimalPlaces: 0 })
43 stats.humanizedGzipSize = bytes(stats.gzipSize, { decimalPlaces: 0 })
44
45 stats.rules = rules(root, opts)
46 stats.selectors = selectors(root, opts)
47 stats.declarations = declarations(root, opts)
48 stats.mediaQueries = mediaQueries(root, opts)
49
50 // Push message to PostCSS when used as a plugin
51 if (result && result.messages) {
52 result.messages.push({
53 type: 'cssstats',
54 plugin: 'postcss-cssstats',
55 stats: stats,
56 })
57 }
58
59 stats.toJSON = function () {
60 // Remove methods when using JSON.stringify
61 delete stats.selectors.getSpecificityGraph
62 delete stats.selectors.getRepeatedValues
63 delete stats.selectors.getSortedSpecificity
64 delete stats.declarations.getPropertyResets
65 delete stats.declarations.getUniquePropertyCount
66 delete stats.declarations.getPropertyValueCount
67 delete stats.declarations.getVendorPrefixed
68 delete stats.declarations.getAllFontSizes
69 delete stats.declarations.getAllFontFamilies
70 return stats
71 }
72
73 // Return stats for default usage
74 return stats
75 }
76
77 if (typeof src === 'string') {
78 // Default behavior

Callers 2

index.jsFile · 0.85
index.jsFile · 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…