Source: polyfill/Number.js

// Licensed Materials - Property of IBM
//
// IBM Watson Analytics
//
// (C) Copyright IBM Corp. 2015
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

( function( Number, ObjectPolyfill )
{
"use strict";

/**
 * Polyfills for {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number Number}.
 * @class module:barejs/polyfill.Number
 */

/** @lends module:barejs/polyfill.Number */
var stat = {};

/*istanbul ignore else: We test with __ES__ set to 3*/
if ( __ES__ < 6 )
{
    stat.parseInt   = parseInt;    // ES6 defines this global should be on Number
    stat.parseFloat = parseFloat;  // ES6 defines this global should be on Number

    /**
     * The Number.MAX_SAFE_INTEGER constant represents the maximum safe integer in JavaScript (2<sup>53</sup> - 1).
     * @member {number}
     * @readonly
     */
    stat.MAX_SAFE_INTEGER = 9007199254740991 /*0x1fffffffffffff*/;
    /**
     * The Number.MIN_SAFE_INTEGER constant represents the minimum safe integer in JavaScript (-(2<sup>53</sup> - 1)).
     * @member {number}
     * @readonly
     */
    stat.MIN_SAFE_INTEGER = -stat.MAX_SAFE_INTEGER;
    /**
     * The Number.EPSILON property represents the difference between `1` and the smallest floating point number greater than `1`.
     * @member {number}
     * @readonly
     */
    stat.EPSILON = Math.pow( 2, -52 );

    // Closure to protect the isFinite name
    ( function( _isFinite )
    {
        /**
         * Check if a number is finite. Differs from global isFinite by not coercing types.
         * @param _value the value to check.
         * @returns {boolean} True if _value is a finite number
         */
        stat.isFinite = function isFinite( _value )
        {
            return typeof _value === "number" && _isFinite( _value );
        };
    }( isFinite /* Grab the global isFinite */ ) );

    /**
     * The Number.isInteger() method determines whether the passed value is an integer.
     * @param _value the value to check.
     * @returns {boolean} True if _value is an integer.
     */
    stat.isInteger = function isInteger( _value )
    {
        return Number.isFinite( _value ) && Math.floor( _value ) === _value;
    };

    /**
     * The Number.isSafeInteger() method determines whether the provided value is a number that is a safe integer.
     * A safe integer is an integer that
     *  - can be exactly represented as an IEEE-754 double precision number, and
     *  - whose IEEE-754 representation cannot be the result of rounding any other integer to fit the IEEE-754 representation.
     * For example, 2<sup>53</sup> - 1 is a safe integer: it can be exactly represented, and no other integer rounds to it under any IEEE-754 rounding mode.
     * In contrast, 2<sup>53</sup> is not a safe integer: it can be exactly represented in IEEE-754, but the integer 2<sup>53</sup> + 1 can't be directly represented in IEEE-754
     * but instead rounds to 2<sup>53</sup> under round-to-nearest and round-to-zero rounding.
     * The safe integers consist of all integers from -(2<sup>53</sup> - 1) inclusive to 2<sup>53</sup> - 1 inclusive.
     * @param {number} _value The value to test
     * @returns {boolean} True if _value is a Number and a safe integer value.
     */
    stat.isSafeInteger = function isSafeInteger( _value )
    {
        return Number.isInteger( _value ) && ( _value >= Number.MIN_SAFE_INTEGER ) && ( _value <= Number.MAX_SAFE_INTEGER );
    };

    // Closure to protect the isNaN name
    ( function( _isNaN )
    {
        /**
         * Check if _value is the special NaN value. Differs from global isNaN by not coercing types.
         * @param _value the value to check.
         * @returns {boolean} True if _value is the NaN value number
         */
        stat.isNaN = function isNaN( _value )
        {
            return typeof _value === "number" && _isNaN( _value );
        };
    }( isNaN /* Grab the global isNaN */ ) );
// End of ES6 polyfill scope
}

ObjectPolyfill.polyfill( Number, stat, null, exports, "Number" );

// End of module
}( Number, require( "./Object" ) ) );