Skip to content

Commit

Permalink
Polyfill Number.EPSILON and Number.MIN/MAX_SAFE_INTEGER
Browse files Browse the repository at this point in the history
Summary: Those three properties have been ratified as ES6 but are not yet implementd in JSCore. This polyfills them.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON

@​public

Reviewed By: @sahrens

Differential Revision: D2497528
  • Loading branch information
vjeux authored and facebook-github-bot-3 committed Oct 1, 2015
1 parent d967484 commit de717a8
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @providesModule InitializeJavaScriptAppEngine
*/

/* eslint global-strict: 0 */
/* eslint strict: 0 */
/* globals GLOBAL: true, window: true */

// Just to make sure the JS gets packaged up.
Expand Down Expand Up @@ -59,7 +59,7 @@ function setUpRedBoxConsoleErrorHandler() {
}
}

function setupFlowChecker() {
function setUpFlowChecker() {
if (__DEV__) {
var checkFlowAtRuntime = require('checkFlowAtRuntime');
checkFlowAtRuntime();
Expand Down Expand Up @@ -130,7 +130,7 @@ function setUpWebSockets() {
GLOBAL.WebSocket = require('WebSocket');
}

function setupProfile() {
function setUpProfile() {
console.profile = console.profile || GLOBAL.nativeTraceBeginSection || function () {};
console.profileEnd = console.profileEnd || GLOBAL.nativeTraceEndSection || function () {};
if (__DEV__) {
Expand All @@ -146,6 +146,12 @@ function setUpProcessEnv() {
}
}

function setUpNumber() {
Number.EPSILON = Number.EPSILON || Math.pow(2, -52);
Number.MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
Number.MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
}

setUpRedBoxErrorHandler();
setUpTimers();
setUpAlert();
Expand All @@ -154,6 +160,7 @@ setUpXHR();
setUpRedBoxConsoleErrorHandler();
setUpGeolocation();
setUpWebSockets();
setupProfile();
setUpProfile();
setUpProcessEnv();
setupFlowChecker();
setUpFlowChecker();
setUpNumber();

0 comments on commit de717a8

Please sign in to comment.