UNPKG

@mathlib/functions

Version:
15 lines (14 loc) 425 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function mod(a, n) { if (isNaN(a)) { throw new Error("a should be a number."); } if (isNaN(n)) { throw new Error("n should be a number."); } const _a = typeof a === "string" ? parseFloat(a) : a; const _n = typeof n === "string" ? parseFloat(n) : n; return ((_a % _n) + _n) % _n; } exports.default = mod;