Skip to content

Commit 356e85c

Browse files
yungsterszpao
authored andcommitted
Separate performanceNow into own project
1 parent 5c9d616 commit 356e85c

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright 2013-2014 Facebook, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* @providesModule performance
17+
* @typechecks
18+
*/
19+
20+
"use strict";
21+
22+
var ExecutionEnvironment = require('ExecutionEnvironment');
23+
24+
var performance;
25+
26+
if (ExecutionEnvironment.canUseDOM) {
27+
performance =
28+
window.performance ||
29+
window.msPerformance ||
30+
window.webkitPerformance;
31+
}
32+
33+
module.exports = performance || {};
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,16 @@
1414
* limitations under the License.
1515
*
1616
* @providesModule performanceNow
17-
* @typechecks static-only
17+
* @typechecks
1818
*/
1919

20-
"use strict";
21-
22-
var ExecutionEnvironment = require('ExecutionEnvironment');
20+
var performance = require('performance');
2321

2422
/**
25-
* Detect if we can use window.performance.now() and gracefully
26-
* fallback to Date.now() if it doesn't exist.
27-
* We need to support Firefox < 15 for now due to Facebook's webdriver
28-
* infrastructure.
23+
* Detect if we can use `window.performance.now()` and gracefully fallback to
24+
* `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
25+
* because of Facebook's testing infrastructure.
2926
*/
30-
var performance = null;
31-
32-
if (ExecutionEnvironment.canUseDOM) {
33-
performance = window.performance || window.webkitPerformance;
34-
}
35-
3627
if (!performance || !performance.now) {
3728
performance = Date;
3829
}

0 commit comments

Comments
 (0)