forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
root.ts
29 lines (27 loc) · 803 Bytes
/
root.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
declare let global: NodeJS.Global;
declare module NodeJS {
interface Global {
window: any;
global: any;
}
}
/**
* window: browser in DOM main thread
* self: browser in WebWorker
* global: Node.js/other
*/
export let root: any;
if (typeof window == 'object' && window.window === window) {
root = window;
} else if (typeof self == 'object' && self.self === self) {
root = self;
} else if (typeof global == 'object' && global.global === global) {
root = global;
} else {
// Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
// This is needed when used with angular/tsickle which inserts a goog.module statement.
// Wrap in IIFE
(function () {
throw new Error('RxJS could not find any global context (window, self, global)');
})();
}