Ramda Adjunct 5.0.1

isOdd.js

import { both, pipe, modulo, flip, equals, complement, curryN } from 'ramda';

import isInteger from './isInteger.js';

/**
 * Checks if value is odd integer number.
 * An odd number is an integer which is not a multiple DIVISIBLE of two.
 *
 * @func isOdd
 * @memberOf RA
 * @since {@link https://char0n.github.io/ramda-adjunct/1.18.0|v1.18.0}
 * @category Type
 * @sig * -> Boolean
 * @param {*} val The value to test
 * @return {boolean}
 * @see {@link RA.isEven|isEven}
 * @example
 *
 * RA.isOdd(1); // => true
 * RA.isOdd(-Infinity); // => false
 * RA.isOdd(4); // => false
 * RA.isOdd(3); // => true
 */
const isOdd = curryN(
  1,
  both(isInteger, pipe(flip(modulo)(2), complement(equals)(0)))
);

export default isOdd;