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.

limit-cursor.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @fileoverview Define the cursor which limits the number of tokens.
  3. * @author Toru Nagashima
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Requirements
  8. //------------------------------------------------------------------------------
  9. const DecorativeCursor = require("./decorative-cursor");
  10. //------------------------------------------------------------------------------
  11. // Exports
  12. //------------------------------------------------------------------------------
  13. /**
  14. * The decorative cursor which limits the number of tokens.
  15. */
  16. module.exports = class LimitCursor extends DecorativeCursor {
  17. /**
  18. * Initializes this cursor.
  19. * @param {Cursor} cursor The cursor to be decorated.
  20. * @param {number} count The count of tokens this cursor iterates.
  21. */
  22. constructor(cursor, count) {
  23. super(cursor);
  24. this.count = count;
  25. }
  26. /** @inheritdoc */
  27. moveNext() {
  28. if (this.count > 0) {
  29. this.count -= 1;
  30. return super.moveNext();
  31. }
  32. return false;
  33. }
  34. };