Urara-Blog/node_modules/.pnpm-store/v3/files/48/2321823bb37163e7bdff99dc516fee97a1022b51b612b58a5a06a7b8340dd522f5d20d1b06e1a10656e08cde0b9e55aa2f009ed1d60a626a17284158d3c6cf
2022-08-14 01:14:53 +08:00

37 lines
844 B
Text

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function rotateFromString(value, defaultValue = 0) {
const units = value.replace(/^-?[0-9.]*/, "");
function cleanup(value2) {
while (value2 < 0) {
value2 += 4;
}
return value2 % 4;
}
if (units === "") {
const num = parseInt(value);
return isNaN(num) ? 0 : cleanup(num);
} else if (units !== value) {
let split = 0;
switch (units) {
case "%":
split = 25;
break;
case "deg":
split = 90;
}
if (split) {
let num = parseFloat(value.slice(0, value.length - units.length));
if (isNaN(num)) {
return 0;
}
num = num / split;
return num % 1 === 0 ? cleanup(num) : 0;
}
}
return defaultValue;
}
exports.rotateFromString = rotateFromString;