From de717a8379d3c969fb3a373934376911badaf10e Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Thu, 1 Oct 2015 14:13:24 -0700 Subject: [PATCH] Polyfill Number.EPSILON and Number.MIN/MAX_SAFE_INTEGER MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../InitializeJavaScriptAppEngine.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index fde1f06c1..fcd695abd 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -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. @@ -59,7 +59,7 @@ function setUpRedBoxConsoleErrorHandler() { } } -function setupFlowChecker() { +function setUpFlowChecker() { if (__DEV__) { var checkFlowAtRuntime = require('checkFlowAtRuntime'); checkFlowAtRuntime(); @@ -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__) { @@ -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(); @@ -154,6 +160,7 @@ setUpXHR(); setUpRedBoxConsoleErrorHandler(); setUpGeolocation(); setUpWebSockets(); -setupProfile(); +setUpProfile(); setUpProcessEnv(); -setupFlowChecker(); +setUpFlowChecker(); +setUpNumber();