Files
med-notes/.pnpm-store/v10/files/92/e959ec55f567170a457aa2b57a639c2a2d5a38f1174cdc5f7e44fdb2947190098455f6a50722fed09ea42d8079428914859ce4791ee03456b6b8de25437e2b
2025-05-09 05:30:08 +02:00

40 lines
1.0 KiB
Plaintext

/**
* @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;
}
};