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.

iterator.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = createIterator;
  6. var _isArrayLike = require('./isArrayLike');
  7. var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
  8. var _getIterator = require('./getIterator');
  9. var _getIterator2 = _interopRequireDefault(_getIterator);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function createArrayIterator(coll) {
  12. var i = -1;
  13. var len = coll.length;
  14. return function next() {
  15. return ++i < len ? { value: coll[i], key: i } : null;
  16. };
  17. }
  18. function createES2015Iterator(iterator) {
  19. var i = -1;
  20. return function next() {
  21. var item = iterator.next();
  22. if (item.done) return null;
  23. i++;
  24. return { value: item.value, key: i };
  25. };
  26. }
  27. function createObjectIterator(obj) {
  28. var okeys = obj ? Object.keys(obj) : [];
  29. var i = -1;
  30. var len = okeys.length;
  31. return function next() {
  32. var key = okeys[++i];
  33. return i < len ? { value: obj[key], key } : null;
  34. };
  35. }
  36. function createIterator(coll) {
  37. if ((0, _isArrayLike2.default)(coll)) {
  38. return createArrayIterator(coll);
  39. }
  40. var iterator = (0, _getIterator2.default)(coll);
  41. return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
  42. }
  43. module.exports = exports['default'];