forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Symbol): introduce unified Symbol module
closes ReactiveX#844
- Loading branch information
Showing
9 changed files
with
70 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,48 @@ | ||
import {root} from './root'; | ||
|
||
if (!root.Symbol) { | ||
root.Symbol = {}; | ||
} | ||
|
||
if (!root.Symbol.iterator) { | ||
if (typeof root.Symbol.for === 'function') { | ||
root.Symbol.iterator = root.Symbol.for('iterator'); | ||
} else if (root.Set && typeof new root.Set()['@@iterator'] === 'function') { | ||
// Bug for mozilla version | ||
root.Symbol.iterator = '@@iterator'; | ||
} else if (root.Map) { | ||
// es6-shim specific logic | ||
let keys = Object.getOwnPropertyNames(root.Map.prototype); | ||
for (let i = 0; i < keys.length; ++i) { | ||
let key = keys[i]; | ||
if (key !== 'entries' && key !== 'size' && root.Map.prototype[key] === root.Map.prototype['entries']) { | ||
root.Symbol.iterator = key; | ||
break; | ||
} | ||
} | ||
} else { | ||
root.Symbol.iterator = '@@iterator'; | ||
} | ||
} | ||
|
||
export const $$iterator = root.Symbol.iterator; | ||
|
||
// // 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'; | ||
// } | ||
import {root} from './root'; | ||
|
||
if (!root.Symbol) { | ||
root.Symbol = {}; | ||
} | ||
|
||
if (!root.Symbol.observable) { | ||
if (typeof root.Symbol.for === 'function') { | ||
root.Symbol.observable = root.Symbol.for('observable'); | ||
} else { | ||
root.Symbol.observable = '@@observable'; | ||
} | ||
} | ||
|
||
if (!root.Symbol.iterator) { | ||
if (typeof root.Symbol.for === 'function') { | ||
root.Symbol.iterator = root.Symbol.for('iterator'); | ||
} else if (root.Set && typeof new root.Set()['@@iterator'] === 'function') { | ||
// Bug for mozilla version | ||
root.Symbol.iterator = '@@iterator'; | ||
} else if (root.Map) { | ||
// es6-shim specific logic | ||
let keys = Object.getOwnPropertyNames(root.Map.prototype); | ||
for (let i = 0; i < keys.length; ++i) { | ||
let key = keys[i]; | ||
if (key !== 'entries' && key !== 'size' && root.Map.prototype[key] === root.Map.prototype['entries']) { | ||
root.Symbol.iterator = key; | ||
break; | ||
} | ||
} | ||
} else { | ||
root.Symbol.iterator = '@@iterator'; | ||
} | ||
} | ||
|
||
if (!root.Symbol.dispose) { | ||
if (typeof root.Symbol.for === 'function') { | ||
root.Symbol.dispose = root.Symbol.for('dispose'); | ||
} else { | ||
root.Symbol.dispose = '@@dispose'; | ||
} | ||
} | ||
|
||
export module SymbolShim { | ||
export const observable: symbol = root.Symbol.observable; | ||
export const iterator: symbol = root.Symbol.iterator; | ||
export const dispose: symbol = root.Symbol.dispose; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters