UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

12 lines (11 loc) 382 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mod = void 0; // mod that really constrains n within the modulus of [0, n[ function mod(modulus, n) { if (arguments.length === 1) return (_n) => mod(modulus, _n); const jsMod = n % modulus; return jsMod < 0 ? jsMod + modulus : Math.abs(jsMod); // catch -0 } exports.mod = mod;