source: imaps-frontend/node_modules/eslint/lib/source-code/token-store/limit-cursor.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 * @fileoverview Define the cursor which limits the number of tokens.
3 * @author Toru Nagashima
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Requirements
9//------------------------------------------------------------------------------
10
11const DecorativeCursor = require("./decorative-cursor");
12
13//------------------------------------------------------------------------------
14// Exports
15//------------------------------------------------------------------------------
16
17/**
18 * The decorative cursor which limits the number of tokens.
19 */
20module.exports = class LimitCursor extends DecorativeCursor {
21
22 /**
23 * Initializes this cursor.
24 * @param {Cursor} cursor The cursor to be decorated.
25 * @param {number} count The count of tokens this cursor iterates.
26 */
27 constructor(cursor, count) {
28 super(cursor);
29 this.count = count;
30 }
31
32 /** @inheritdoc */
33 moveNext() {
34 if (this.count > 0) {
35 this.count -= 1;
36 return super.moveNext();
37 }
38 return false;
39 }
40};
Note: See TracBrowser for help on using the repository browser.