Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81158 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule ExecutionEnvironment
10
*/
11
12
/*jslint evil: true */
13
14
"use strict";
15
16
var canUseDOM = !!(
17
typeof window !== 'undefined' &&
18
window.document &&
19
window.document.createElement
20
);
21
22
/**
23
* Simple, lightweight module assisting with the detection and context of
24
* Worker. Helps avoid circular dependencies and allows code to reason about
25
* whether or not they are in a Worker, even if they never include the main
26
* `ReactWorker` dependency.
27
*/
28
var ExecutionEnvironment = {
29
30
canUseDOM: canUseDOM,
31
32
canUseWorkers: typeof Worker !== 'undefined',
33
34
canUseEventListeners:
35
canUseDOM && !!(window.addEventListener || window.attachEvent),
36
37
canUseViewport: canUseDOM && !!window.screen,
38
39
isInWorker: !canUseDOM // For now, this is true - might change in the future.
40
41
};
42
43
module.exports = ExecutionEnvironment;
44
45