Skip to content

Commit

Permalink
♻️ Improve splitUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
exah committed Jan 20, 2019
1 parent a8aebf0 commit e01ddbf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export const wrapIfMedia = (query, style) => wrap(
style
)

const parseUnit = (str) => str.replace(/([\d.]+)(\D+)?$/, '$2').trim()
const parseUnit = (str) => str.replace(/([\d.]+)(\D+)?$/, '$2').trim() || undefined

export const splitUnit = (input) => isStr(input)
? [ parseFloat(input, 10), parseUnit(input) || undefined ]
: [ input, undefined ]
? [ parseFloat(input, 10), parseUnit(input) ]
: (isNum(input) ? [ input, undefined ] : [])

export const floor = (number, precision = 0) => {
const factor = Math.pow(10, precision)
Expand Down

0 comments on commit e01ddbf

Please sign in to comment.