/** * Looping function for any framesize. * Like fmod. * * @module mumath/loop * */ 'use strict'; module.exports = function (value, left, right) { //detect single-arg case, like mod-loop or fmod if (right === undefined) { right = left; left = 0; } //swap frame order if (left > right) { var tmp = right; right = left; left = tmp; } var frame = right - left; value = ((value + left) % frame) - left; if (value < left) value += frame; if (value > right) value -= frame; return value; };