From 2df937df1372359babd123d1361e702a1a4b8168 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Tue, 5 Jul 2022 23:34:03 +0200 Subject: Create the sensor, move values to config --- src/lib/math.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/lib/math.js (limited to 'src/lib/math.js') diff --git a/src/lib/math.js b/src/lib/math.js new file mode 100644 index 0000000..c745cdc --- /dev/null +++ b/src/lib/math.js @@ -0,0 +1,8 @@ +/** + * Modulo that acts well with negative numbers. + * @param {number} dividend the number to divide + * @param {number} divisor the divisor to calculate the remainder + */ +export const modulo = function modulo (dividend, divisor) { + return ((dividend % divisor) + divisor) % divisor +}; -- cgit