Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 22x 22x 22x 3x 22x 25x 22x 22x 22x 3x 3x | /**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/
const CSS_UNIT_RE = /^[+-]?\d*(?:\.\d+)?(?:[Ee][+-]?\d+)?(%|\w*)/;
const getUnit = (str) => str.match(CSS_UNIT_RE)[1];
const isNumeric = (n) => {
return !isNaN(parseFloat(n)) && isFinite(n);
};
const multiplyStyleLengthValue = (value: string | number, multiple) => {
if (typeof value === 'string') {
const number = parseFloat(value) * multiple;
const unit = getUnit(value);
return `${number}${unit}`;
} else Eif (isNumeric(value)) {
return value * multiple;
}
};
export default multiplyStyleLengthValue;
|