.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / lib / source-code / token-store / skip-cursor.js
1 /**
2  * @fileoverview Define the cursor which ignores the first few 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 ignores the first few tokens.
19  */
20 module.exports = class SkipCursor 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 skips.
26      */
27     constructor(cursor, count) {
28         super(cursor);
29         this.count = count;
30     }
31
32     /** @inheritdoc */
33     moveNext() {
34         while (this.count > 0) {
35             this.count -= 1;
36             if (!super.moveNext()) {
37                 return false;
38             }
39         }
40         return super.moveNext();
41     }
42 };