project files added
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
import { root } from '../util/root';
|
||||
|
||||
export function symbolIteratorPonyfill(root: any) {
|
||||
const Symbol: any = root.Symbol;
|
||||
|
||||
if (typeof Symbol === 'function') {
|
||||
if (!Symbol.iterator) {
|
||||
Symbol.iterator = Symbol('iterator polyfill');
|
||||
}
|
||||
return Symbol.iterator;
|
||||
} else {
|
||||
// [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC)
|
||||
const { Set } = root;
|
||||
if (Set && typeof new Set()['@@iterator'] === 'function') {
|
||||
return '@@iterator';
|
||||
}
|
||||
const { Map } = root;
|
||||
// required for compatability with es6-shim
|
||||
if (Map) {
|
||||
let keys = Object.getOwnPropertyNames(Map.prototype);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
let key = keys[i];
|
||||
// according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal.
|
||||
if (key !== 'entries' && key !== 'size' && Map.prototype[key] === Map.prototype['entries']) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '@@iterator';
|
||||
}
|
||||
}
|
||||
|
||||
export const iterator = symbolIteratorPonyfill(root);
|
||||
|
||||
/**
|
||||
* @deprecated use iterator instead
|
||||
*/
|
||||
export const $$iterator = iterator;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { root } from '../util/root';
|
||||
|
||||
export function getSymbolObservable(context: any) {
|
||||
let $$observable: any;
|
||||
let Symbol = context.Symbol;
|
||||
|
||||
if (typeof Symbol === 'function') {
|
||||
if (Symbol.observable) {
|
||||
$$observable = Symbol.observable;
|
||||
} else {
|
||||
$$observable = Symbol('observable');
|
||||
Symbol.observable = $$observable;
|
||||
}
|
||||
} else {
|
||||
$$observable = '@@observable';
|
||||
}
|
||||
|
||||
return $$observable;
|
||||
}
|
||||
|
||||
export const observable = getSymbolObservable(root);
|
||||
|
||||
/**
|
||||
* @deprecated use observable instead
|
||||
*/
|
||||
export const $$observable = observable;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { root } from '../util/root';
|
||||
|
||||
const Symbol: any = root.Symbol;
|
||||
|
||||
export const rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
|
||||
Symbol.for('rxSubscriber') : '@@rxSubscriber';
|
||||
|
||||
/**
|
||||
* @deprecated use rxSubscriber instead
|
||||
*/
|
||||
export const $$rxSubscriber = rxSubscriber;
|
||||
Reference in New Issue
Block a user