UNPKG

data-fns

Version:

This library provides utility functions for working with array data that are useful in many contexts, including creative coding. It offers generic functions that perform common operations such as offsetting an array, generating an array based on a callbac

26 lines (22 loc) 729 B
import { modulo } from './modulo' describe('modulo', () => { it('should return the remainder of dividing the dividend by the divisor', () => { expect(modulo(5, 3)).toBe(2) expect(modulo(-5, -3)).toBe(2) expect(modulo(-5, 3)).toBe(-2) expect(modulo(5, -3)).toBe(-2) expect(modulo(10, 4)).toBe(2) expect(modulo(-10, 4)).toBe(-2) expect(modulo(10, -4)).toBe(-2) expect(modulo(-10, -4)).toBe(2) }) it('should return NaN if the divisor is 0', () => { expect(modulo(5, 0)).toBeNaN() expect(modulo(0, 0)).toBeNaN() expect(modulo(-5, 0)).toBeNaN() }) it('should return zero if the divisor is 1', () => { expect(modulo(5, 1)).toBe(0) expect(modulo(-5, 1)).toBe(-0) }) })