sikits
Version:
A powerful and comprehensive utility library for JavaScript and TypeScript with 100+ functions for strings, numbers, arrays, and objects
14 lines (13 loc) • 623 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromPercentage = exports.toPercentage = exports.toDegrees = exports.toRadians = void 0;
const toRadians = (degrees) => (degrees * Math.PI) / 180;
exports.toRadians = toRadians;
const toDegrees = (radians) => (radians * 180) / Math.PI;
exports.toDegrees = toDegrees;
const toPercentage = (value, total, decimals = 2) => {
return ((value / total) * 100).toFixed(decimals) + '%';
};
exports.toPercentage = toPercentage;
const fromPercentage = (value) => parseFloat(value.replace('%', '')) / 100;
exports.fromPercentage = fromPercentage;