Permalink
Cannot retrieve contributors at this time
40 lines (34 sloc)
1.08 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/limit-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 limits the number of tokens. | |
* @author Toru Nagashima | |
*/ | |
"use strict"; | |
//------------------------------------------------------------------------------ | |
// Requirements | |
//------------------------------------------------------------------------------ | |
const DecorativeCursor = require("./decorative-cursor"); | |
//------------------------------------------------------------------------------ | |
// Exports | |
//------------------------------------------------------------------------------ | |
/** | |
* The decorative cursor which limits the number of tokens. | |
*/ | |
module.exports = class LimitCursor extends DecorativeCursor { | |
/** | |
* Initializes this cursor. | |
* @param {Cursor} cursor The cursor to be decorated. | |
* @param {number} count The count of tokens this cursor iterates. | |
*/ | |
constructor(cursor, count) { | |
super(cursor); | |
this.count = count; | |
} | |
/** @inheritdoc */ | |
moveNext() { | |
if (this.count > 0) { | |
this.count -= 1; | |
return super.moveNext(); | |
} | |
return false; | |
} | |
}; |