UNPKG

@gannochenko/ui.styled-components

Version:

<!-- PROJECT SHIELDS --> <!-- *** Reference links are enclosed in brackets [ ] instead of parentheses ( ). *** See the bottom of this document for the declaration of the reference variables *** for contributors-url, forks-url, etc. This is an optional, co

35 lines 953 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.op = exports.pInt = void 0; const pInt = (val) => { let iVal = 0; if (typeof val === 'string') { iVal = parseInt(val, 10); if (Number.isNaN(iVal)) { iVal = 0; } } else if (typeof val !== 'undefined' && val !== null) { iVal = val; } return iVal; }; exports.pInt = pInt; const op = (val, fn) => { if (typeof val === 'undefined' || val === null) { return val; } const results = val .toString() .trim() .match(/^(\d+)?(.(\d+))?(px|rem|em)?$/i); if (results && results.length) { const full = (0, exports.pInt)(results[1]); const frac = (0, exports.pInt)(results[3]); const unit = results[4] || ''; return `${fn(full + +`0.${frac}`)}${unit}`; } return val.toString(); }; exports.op = op; //# sourceMappingURL=op.js.map