Front end of the Slack clone application.

iterator.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { root } from '../util/root';
  2. export function symbolIteratorPonyfill(root) {
  3. const Symbol = root.Symbol;
  4. if (typeof Symbol === 'function') {
  5. if (!Symbol.iterator) {
  6. Symbol.iterator = Symbol('iterator polyfill');
  7. }
  8. return Symbol.iterator;
  9. }
  10. else {
  11. // [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC)
  12. const { Set } = root;
  13. if (Set && typeof new Set()['@@iterator'] === 'function') {
  14. return '@@iterator';
  15. }
  16. const { Map } = root;
  17. // required for compatability with es6-shim
  18. if (Map) {
  19. let keys = Object.getOwnPropertyNames(Map.prototype);
  20. for (let i = 0; i < keys.length; ++i) {
  21. let key = keys[i];
  22. // according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal.
  23. if (key !== 'entries' && key !== 'size' && Map.prototype[key] === Map.prototype['entries']) {
  24. return key;
  25. }
  26. }
  27. }
  28. return '@@iterator';
  29. }
  30. }
  31. export const iterator = symbolIteratorPonyfill(root);
  32. /**
  33. * @deprecated use iterator instead
  34. */
  35. export const $$iterator = iterator;
  36. //# sourceMappingURL=iterator.js.map