Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors Symbol_iterator to compile in typescript versions targeting < ES6 #168

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/observables/IteratorObservable.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import Scheduler from '../Scheduler';
import Observable from '../Observable';

import {root} from '../util/root';
import {$iterator$} from '../util/Symbol_iterator';
import $iterator$ from '../util/Symbol_iterator';
import tryCatch from '../util/tryCatch';
import {errorObject} from '../util/errorObject';

28 changes: 23 additions & 5 deletions src/util/Symbol_iterator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import {root} from './root';

// Shim in iterator support
export var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || '_es6shim_iterator_';
if (!root.Symbol) {
root.Symbol = {};
}

// Bug for mozilla version
if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
$iterator$ = '@@iterator';
if (!root.Symbol.iterator) {
if (typeof root.Symbol.for === 'function') {
root.Symbol.iterator = root.Symbol.for('iterator');
}
// Bug for mozilla version
else if(root.Set && typeof new root.Set()['@@iterator'] === 'function') {
root.Symbol.iterator = '@@iterator';
} else {
root.Symbol.iterator = '_es6shim_iterator_';
}
}

export default root.Symbol.dispose;

// // Shim in iterator support
// export var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || '_es6shim_iterator_';

// // Bug for mozilla version
// if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
// $iterator$ = '@@iterator';
// }