UNPKG

ramda-adjunct

Version:

Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.

41 lines (35 loc) 1.22 kB
import { bind, curryN } from 'ramda'; import isFunction from './isFunction'; import polyfill from './internal/polyfills/Number.isSafeInteger'; export const isSafeIntegerPolyfill = curryN(1, polyfill); /** * Checks whether the passed value is a safe `integer`. * * @func isSafeInteger * @memberOf RA * @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0} * @category Type * @sig * -> Boolean * @param {*} val The value to test * @return {boolean} * @example * * RA.isSafeInteger(3); //=> true * RA.isSafeInteger(Math.pow(2, 53)) //=> false * RA.isSafeInteger(Math.pow(2, 53) - 1); //=> true * RA.isSafeInteger(NaN); //=> false * RA.isSafeInteger(Infinity); //=> false * RA.isSafeInteger('3') //=> false * RA.isSafeInteger(3.1); //=> false * RA.isSafeInteger(3.0); //=> true * RA.isSafeInteger('string'); //=> false * RA.isSafeInteger(null); //=> false * RA.isSafeInteger(undefined); //=> false * RA.isSafeInteger({}); //=> false * RA.isSafeInteger(() => { }); //=> false * RA.isSafeInteger(true); //=> false */ const isSafeInteger = isFunction(Number.isSafeInteger) ? curryN(1, bind(Number.isSafeInteger, Number)) : isSafeIntegerPolyfill; export default isSafeInteger;