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

Function convert

packages/css-unit-sort/index.js:13–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13const convert = value => {
14 if (typeof value !== 'string') {
15 value = value.toString()
16 }
17
18 const raw = parseFloat(value, 10)
19
20 if (value === 0) return 0
21 if (value.match(/px$/)) return raw
22 if (value.match(/pt$/)) return raw
23 if (value.match(/em$/)) return raw * 16
24 if (value.match(/%$/)) return raw * 0.16
25
26 switch (value) {
27 case 'inherit':
28 return 16
29 case 'xx-small':
30 return 9
31 case 'x-small':
32 return 10
33 case 'small':
34 return 13
35 case 'medium':
36 return 16
37 case 'large':
38 return 18
39 case 'x-large':
40 return 24
41 case 'xx-large':
42 return 32
43 case 'larger':
44 return 19
45 default:
46 return 1024
47 }
48}
49
50module.exports = cssUnitSort
51module.exports.sortFn = sortFn

Callers 1

sortFnFunction · 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…