diff --git a/src/internal/symbol/iterator.ts b/src/internal/symbol/iterator.ts index 2475131f06..2ca0f21ae4 100644 --- a/src/internal/symbol/iterator.ts +++ b/src/internal/symbol/iterator.ts @@ -1,14 +1,17 @@ +export function getSymbolIterator(): symbol { + /* NOTE: Warning users that they don't have a Symbol.iterator + polyfill. We don't want to throw on this, because it's not required + by the library. However it will provide clues to users on older + browsers why things like `from(iterable)` doesn't work. */ + if (typeof Symbol !== 'function' || !Symbol.iterator) { + console.warn('RxJS: Symbol.iterator does not exist, so things like from(iterable) won\'t work'); + return '@@iterator' as any; + } -/* NOTE: Warning users that they don't have a Symbol.iterator - polyfill. We don't want to throw on this, because it's not required - by the library. However it will provide clues to users on older - browsers why things like `from(iterable)` doesn't work. */ -if (!Symbol || !Symbol.iterator) { - console.warn('RxJS: Symbol.observable does not exist'); + return Symbol.iterator; } -/** The native Symbol.iterator instance or a string */ -export const iterator = Symbol && Symbol.iterator || '@@iterator'; +export const iterator = getSymbolIterator(); /** * @deprecated use {@link iterator} instead