mirror of
https://github.com/nodejs/node.git
synced 2025-05-13 21:08:15 +00:00

This is required because we need to add the babel-eslint dependency and it has to be able to resolve "eslint". babel-eslint is required to support future ES features such as async iterators and import.meta. Refs: https://github.com/nodejs/node/pull/17755 PR-URL: https://github.com/nodejs/node/pull/17820 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
/**
|
|
* @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;
|
|
}
|
|
};
|