Skip to content
This repository was archived by the owner on Mar 28, 2018. It is now read-only.

Commit b0bcd2e

Browse files
committed
Export util functions as well
1 parent 0c32632 commit b0bcd2e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Originally written by @jxnblk
44
// https://github.com/cssstats/cssstats/blob/16fe37c96623fd3cdb24bd302ef6f6e93826af0f/controllers/stats.js#L98
5-
module.exports = units => units.sort(sortFn)
5+
const cssUnitSort = units => units.sort(sortFn)
66

77
const sortFn = (a, b) => {
88
const aa = convert(a)
@@ -13,13 +13,11 @@ const sortFn = (a, b) => {
1313
}
1414

1515
const convert = value => {
16-
let raw
17-
1816
if (typeof value !== 'string') {
1917
value = value.toString()
2018
}
2119

22-
raw = parseFloat(value, 10)
20+
const raw = parseFloat(value, 10)
2321

2422
if (value.match(/px$/)) return raw
2523
if (value.match(/pt$/)) return raw
@@ -51,3 +49,7 @@ const convert = value => {
5149
return 1024
5250
}
5351
}
52+
53+
module.exports = cssUnitSort
54+
module.exports.sortFn = sortFn
55+
module.exports.convert = convert

0 commit comments

Comments
 (0)