Front end of the Slack clone application.

iterator.js 1.1KB

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. var setPrototypeOf = require('es5-ext/object/set-prototype-of')
  3. , contains = require('es5-ext/string/#/contains')
  4. , d = require('d')
  5. , Iterator = require('es6-iterator')
  6. , toStringTagSymbol = require('es6-symbol').toStringTag
  7. , defineProperty = Object.defineProperty
  8. , SetIterator;
  9. SetIterator = module.exports = function (set, kind) {
  10. if (!(this instanceof SetIterator)) return new SetIterator(set, kind);
  11. Iterator.call(this, set.__setData__, set);
  12. if (!kind) kind = 'value';
  13. else if (contains.call(kind, 'key+value')) kind = 'key+value';
  14. else kind = 'value';
  15. defineProperty(this, '__kind__', d('', kind));
  16. };
  17. if (setPrototypeOf) setPrototypeOf(SetIterator, Iterator);
  18. SetIterator.prototype = Object.create(Iterator.prototype, {
  19. constructor: d(SetIterator),
  20. _resolve: d(function (i) {
  21. if (this.__kind__ === 'value') return this.__list__[i];
  22. return [this.__list__[i], this.__list__[i]];
  23. }),
  24. toString: d(function () { return '[object Set Iterator]'; })
  25. });
  26. defineProperty(SetIterator.prototype, toStringTagSymbol, d('c', 'Set Iterator'));