Permalink
Cannot retrieve contributors at this time
42 lines (36 sloc)
1.13 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint/lib/source-code/token-store/skip-cursor.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Define the cursor which ignores the first few tokens. | |
* @author Toru Nagashima | |
*/ | |
"use strict"; | |
//------------------------------------------------------------------------------ | |
// Requirements | |
//------------------------------------------------------------------------------ | |
const DecorativeCursor = require("./decorative-cursor"); | |
//------------------------------------------------------------------------------ | |
// Exports | |
//------------------------------------------------------------------------------ | |
/** | |
* The decorative cursor which ignores the first few tokens. | |
*/ | |
module.exports = class SkipCursor extends DecorativeCursor { | |
/** | |
* Initializes this cursor. | |
* @param {Cursor} cursor The cursor to be decorated. | |
* @param {number} count The count of tokens this cursor skips. | |
*/ | |
constructor(cursor, count) { | |
super(cursor); | |
this.count = count; | |
} | |
/** @inheritdoc */ | |
moveNext() { | |
while (this.count > 0) { | |
this.count -= 1; | |
if (!super.moveNext()) { | |
return false; | |
} | |
} | |
return super.moveNext(); | |
} | |
}; |