summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-05-12 02:57:59 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2019-06-11 15:59:17 +0200
commit8845a77f74f4cc17820ac50ca94bf2658ee95323 (patch)
tree9c5f4dec163f9c89476b0b28ac3c8fb5f6f1b45b /tools/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js
parent6a5376bb94f10d262df881226c05699c28cdd139 (diff)
downloadandroid-node-v8-8845a77f74f4cc17820ac50ca94bf2658ee95323.tar.gz
android-node-v8-8845a77f74f4cc17820ac50ca94bf2658ee95323.tar.bz2
android-node-v8-8845a77f74f4cc17820ac50ca94bf2658ee95323.zip
tools: update eslint
PR-URL: https://github.com/nodejs/node/pull/27670 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js')
-rw-r--r--tools/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js b/tools/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js
new file mode 100644
index 0000000000..523ed398fa
--- /dev/null
+++ b/tools/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js
@@ -0,0 +1,63 @@
+/**
+ * @fileoverview Define the cursor which iterates tokens only.
+ * @author Toru Nagashima
+ */
+"use strict";
+
+//------------------------------------------------------------------------------
+// Requirements
+//------------------------------------------------------------------------------
+
+const Cursor = require("./cursor");
+const utils = require("./utils");
+
+//------------------------------------------------------------------------------
+// Exports
+//------------------------------------------------------------------------------
+
+/**
+ * The cursor which iterates tokens only.
+ */
+module.exports = class ForwardTokenCursor extends Cursor {
+
+ /**
+ * Initializes this cursor.
+ * @param {Token[]} tokens - The array of tokens.
+ * @param {Comment[]} comments - The array of comments.
+ * @param {Object} indexMap - The map from locations to indices in `tokens`.
+ * @param {number} startLoc - The start location of the iteration range.
+ * @param {number} endLoc - The end location of the iteration range.
+ */
+ constructor(tokens, comments, indexMap, startLoc, endLoc) {
+ super();
+ this.tokens = tokens;
+ this.index = utils.getFirstIndex(tokens, indexMap, startLoc);
+ this.indexEnd = utils.getLastIndex(tokens, indexMap, endLoc);
+ }
+
+ /** @inheritdoc */
+ moveNext() {
+ if (this.index <= this.indexEnd) {
+ this.current = this.tokens[this.index];
+ this.index += 1;
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ *
+ * Shorthand for performance.
+ *
+ */
+
+ /** @inheritdoc */
+ getOneToken() {
+ return (this.index <= this.indexEnd) ? this.tokens[this.index] : null;
+ }
+
+ /** @inheritdoc */
+ getAllTokens() {
+ return this.tokens.slice(this.index, this.indexEnd + 1);
+ }
+};