MCPcopy
hub / github.com/eslint/eslint / createCursorWithSkip

Function createCursorWithSkip

lib/languages/js/source-code/token-store/index.js:89–128  ·  view source on GitHub ↗

* Creates the cursor iterates tokens with options. * @param {CursorFactory} factory The cursor factory to initialize 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

(
	factory,
	tokens,
	comments,
	indexMap,
	startLoc,
	endLoc,
	opts,
)

Source from the content-addressed store, hash-verified

87 * @private
88 */
89function createCursorWithSkip(
90 factory,
91 tokens,
92 comments,
93 indexMap,
94 startLoc,
95 endLoc,
96 opts,
97) {
98 let includeComments = false;
99 let skip = 0;
100 let filter = null;
101
102 if (typeof opts === "number") {
103 skip = opts | 0;
104 } else if (typeof opts === "function") {
105 filter = opts;
106 } else if (opts) {
107 includeComments = !!opts.includeComments;
108 skip = opts.skip | 0;
109 filter = opts.filter || null;
110 }
111 assert(skip >= 0, "options.skip should be zero or a positive integer.");
112 assert(
113 !filter || typeof filter === "function",
114 "options.filter should be a function.",
115 );
116
117 return factory.createCursor(
118 tokens,
119 comments,
120 indexMap,
121 startLoc,
122 endLoc,
123 includeComments,
124 filter,
125 skip,
126 -1,
127 );
128}
129
130/**
131 * Creates the cursor iterates tokens with options.

Callers 6

getFirstTokenMethod · 0.85
getLastTokenMethod · 0.85
getTokenBeforeMethod · 0.85
getTokenAfterMethod · 0.85
getFirstTokenBetweenMethod · 0.85
getLastTokenBetweenMethod · 0.85

Calls 2

createCursorMethod · 0.80
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…