flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
41
VISUALIZACION/node_modules/polished/lib/internalHelpers/_pxto.js.flow
generated
vendored
Executable file
41
VISUALIZACION/node_modules/polished/lib/internalHelpers/_pxto.js.flow
generated
vendored
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
// @flow
|
||||
import endsWith from './_endsWith'
|
||||
import stripUnit from '../helpers/stripUnit'
|
||||
import PolishedError from './_errors'
|
||||
|
||||
/**
|
||||
* Factory function that creates pixel-to-x converters
|
||||
* @private
|
||||
*/
|
||||
const pxtoFactory = (to: string) => (
|
||||
pxval: string | number,
|
||||
base?: string | number = '16px',
|
||||
): string => {
|
||||
let newPxval = pxval
|
||||
let newBase = base
|
||||
if (typeof pxval === 'string') {
|
||||
if (!endsWith(pxval, 'px')) {
|
||||
throw new PolishedError(69, to, pxval)
|
||||
}
|
||||
newPxval = stripUnit(pxval)
|
||||
}
|
||||
|
||||
if (typeof base === 'string') {
|
||||
if (!endsWith(base, 'px')) {
|
||||
throw new PolishedError(70, to, base)
|
||||
}
|
||||
newBase = stripUnit(base)
|
||||
}
|
||||
|
||||
if (typeof newPxval === 'string') {
|
||||
throw new PolishedError(71, pxval, to)
|
||||
}
|
||||
|
||||
if (typeof newBase === 'string') {
|
||||
throw new PolishedError(72, base, to)
|
||||
}
|
||||
|
||||
return `${newPxval / newBase}${to}`
|
||||
}
|
||||
|
||||
export default pxtoFactory
|
||||
Loading…
Add table
Add a link
Reference in a new issue