项目原始demo,不改动
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Este repositório está arquivado. Você pode visualizar os arquivos e realizar clone, mas não poderá realizar push nem abrir issues e pull requests.
 
 
 
 

41 linhas
1.1 KiB

  1. "use strict";
  2. var setPrototypeOf = require("es5-ext/object/set-prototype-of")
  3. , d = require("d")
  4. , Iterator = require("../")
  5. , validIterable = require("../valid-iterable")
  6. , push = Array.prototype.push
  7. , defineProperties = Object.defineProperties
  8. , IteratorChain;
  9. IteratorChain = function (iterators) {
  10. defineProperties(this, {
  11. __iterators__: d("", iterators),
  12. __current__: d("w", iterators.shift())
  13. });
  14. };
  15. if (setPrototypeOf) setPrototypeOf(IteratorChain, Iterator);
  16. IteratorChain.prototype = Object.create(Iterator.prototype, {
  17. constructor: d(IteratorChain),
  18. next: d(function () {
  19. var result;
  20. if (!this.__current__) return { done: true, value: undefined };
  21. result = this.__current__.next();
  22. while (result.done) {
  23. this.__current__ = this.__iterators__.shift();
  24. if (!this.__current__) return { done: true, value: undefined };
  25. result = this.__current__.next();
  26. }
  27. return result;
  28. })
  29. });
  30. module.exports = function () {
  31. var iterators = [this];
  32. push.apply(iterators, arguments);
  33. iterators.forEach(validIterable);
  34. return new IteratorChain(iterators);
  35. };