UNPKG

@azizbecha/strkit

Version:

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

20 lines 727 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = toRadians; /** * Converts degrees to radians. * Accepts both numbers and numeric strings. * @param degrees - The angle in degrees (number or numeric string). * @returns The angle in radians. * @throws Error if the input is not a valid number. * @example * toRadians(180); // Output: 3.14159... */ function toRadians(degrees) { const parsedDegrees = typeof degrees === 'string' ? parseFloat(degrees) : degrees; if (isNaN(parsedDegrees)) { throw new Error('Invalid input: degrees must be a number or a numeric string.'); } return parsedDegrees * (Math.PI / 180); } //# sourceMappingURL=toRadians.js.map