All files / src calcs.js

100% Statements 6/6
100% Branches 3/3
100% Functions 3/3
100% Lines 3/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                  8x                       12x                     7x  
/**
 * @module multiply
 * @description multiply a given value
 * @author Zander
 * @param {number} initial
 * @param {number} multiplier
 * @return {number}
 * @example: multiply(30, 2)
 */
export const multiply = (initial, multiplier) => initial * multiplier
 
/**
 * @module pxTo
 * @description converts `px` to `rem` or `em`
 * @author Zander
 * @param {number} value
 * @param {number} base
 * @param {string} unit
 * @return {string}
 * @example: pxTo(30, 16, 'em')
 */
export const pxTo = (value, base = 20, unit = 'rem') => `${value / base}${unit}`
 
/**
 * @module toPx
 * @description converts a `rem` or `em` value to `px`
 * @author Zander
 * @param {string} value
 * @param {number} base
 * @return {string}
 * @example: toPx(30, 16)
 */
export const toPx = (value, base = 20) => `${parseFloat(value) * base}px`