MCPcopy Index your code
hub / github.com/processing/p5.js / splitLines

Function splitLines

utils/sample-linter.mjs:220–247  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

218}
219
220function splitLines(text) {
221 const lines = [];
222
223 lines.lineFromIndex = function(index) {
224 const lines = this;
225 const lineCount = lines.length;
226 for (let i = 0; i < lineCount; i++) {
227 if (index < lines[i].index) return i - 1;
228 }
229 return lineCount - 1;
230 };
231
232 let m;
233 const reSplit = /(( *\* ?)?.*)(?:\r\n|\r|\n)/g;
234 while ((m = reSplit.exec(text)) != null) {
235 if (m.index === reSplit.lastIndex) {
236 reSplit.lastIndex++;
237 }
238
239 lines.push({
240 index: m.index,
241 text: m[1],
242 prefixLength: m[2] ? m[2].length : 0
243 });
244 }
245
246 return lines;
247}
248
249eslintFiles(null, process.argv.slice(2))
250 .then(result => {

Callers 1

sample-linter.mjsFile · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected