Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

esnext.iterator.take.js 878B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. // https://github.com/tc39/proposal-iterator-helpers
  3. var $ = require('../internals/export');
  4. var anObject = require('../internals/an-object');
  5. var toPositiveInteger = require('../internals/to-positive-integer');
  6. var createIteratorProxy = require('../internals/iterator-create-proxy');
  7. var iteratorClose = require('../internals/iterator-close');
  8. var IteratorProxy = createIteratorProxy(function (arg) {
  9. var iterator = this.iterator;
  10. if (!this.remaining--) {
  11. this.done = true;
  12. return iteratorClose(iterator);
  13. }
  14. var result = anObject(this.next.call(iterator, arg));
  15. var done = this.done = !!result.done;
  16. if (!done) return result.value;
  17. });
  18. $({ target: 'Iterator', proto: true, real: true }, {
  19. take: function take(limit) {
  20. return new IteratorProxy({
  21. iterator: anObject(this),
  22. remaining: toPositiveInteger(limit)
  23. });
  24. }
  25. });