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.

filter-cursor.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * @fileoverview Define the cursor which ignores specified 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 ignores specified tokens.
  15. */
  16. module.exports = class FilterCursor extends DecorativeCursor {
  17. /**
  18. * Initializes this cursor.
  19. * @param {Cursor} cursor The cursor to be decorated.
  20. * @param {Function} predicate The predicate function to decide tokens this cursor iterates.
  21. */
  22. constructor(cursor, predicate) {
  23. super(cursor);
  24. this.predicate = predicate;
  25. }
  26. /** @inheritdoc */
  27. moveNext() {
  28. const predicate = this.predicate;
  29. while (super.moveNext()) {
  30. if (predicate(this.current)) {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. };