.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / lib / source-code / token-store / limit-cursor.js
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
11 const DecorativeCursor = require("./decorative-cursor");
12
13 //------------------------------------------------------------------------------
14 // Exports
15 //------------------------------------------------------------------------------
16
17 /**
18  * The decorative cursor which limits the number of tokens.
19  */
20 module.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 };