2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2017-03-01 15:18:10 -08:00
|
|
|
// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492
|
|
|
|
declare var WorkerGlobalScope: any /** TODO #9100 */;
|
|
|
|
// CommonJS / Node have global context exposed as "global" variable.
|
|
|
|
// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
|
|
|
|
// the global "global" var for now.
|
|
|
|
declare var global: any /** TODO #9100 */;
|
|
|
|
const __window = typeof window !== 'undefined' && window;
|
|
|
|
const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
|
|
|
self instanceof WorkerGlobalScope && self;
|
|
|
|
const __global = typeof global !== 'undefined' && global;
|
|
|
|
const _global: {[name: string]: any} = __window || __global || __self;
|
|
|
|
export {_global as global};
|
|
|
|
|
|
|
|
// When Symbol.iterator doesn't exist, retrieves the key used in es6-shim
|
|
|
|
declare const Symbol: any;
|
|
|
|
let _symbolIterator: any = null;
|
|
|
|
export function getSymbolIterator(): string|symbol {
|
|
|
|
if (!_symbolIterator) {
|
|
|
|
var Symbol = _global['Symbol'];
|
|
|
|
if (Symbol && Symbol.iterator) {
|
|
|
|
_symbolIterator = Symbol.iterator;
|
|
|
|
} else {
|
|
|
|
// es6-shim specific logic
|
|
|
|
const keys = Object.getOwnPropertyNames(Map.prototype);
|
|
|
|
for (let i = 0; i < keys.length; ++i) {
|
|
|
|
const key = keys[i];
|
|
|
|
if (key !== 'entries' && key !== 'size' &&
|
|
|
|
(Map as any).prototype[key] === Map.prototype['entries']) {
|
|
|
|
_symbolIterator = key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _symbolIterator;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function scheduleMicroTask(fn: Function) {
|
|
|
|
Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
|
|
|
}
|