summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/token-store/skip-cursor.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/lib/token-store/skip-cursor.js')
-rw-r--r--tools/node_modules/eslint/lib/token-store/skip-cursor.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/token-store/skip-cursor.js b/tools/node_modules/eslint/lib/token-store/skip-cursor.js
new file mode 100644
index 0000000000..ab34dfab0d
--- /dev/null
+++ b/tools/node_modules/eslint/lib/token-store/skip-cursor.js
@@ -0,0 +1,42 @@
+/**
+ * @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();
+ }
+};