Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 67x 67x 67x 803x 420x 420x 420x 420x 114870x 114870x 112699x 112699x 112699x 112699x 112699x 112699x 114870x 420x 174539x 174539x 174539x 174539x 174539x 174539x 174539x 174539x 174539x 174539x 172794x 172794x 172794x 172794x 174539x 174539x 420x 420x 420x 420x 803x 67x | 'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = () => {
function splitTopLevelBlocks(sourceText) {
const blocks = [];
const lines = sourceText.split('\n');
let active = null;
function finish() {
if (!active)
return;
blocks.push({
sourceText: active.lines.join('\n'),
startLine: active.startLine,
endLine: active.endLine,
});
active = null;
}
lines.forEach((raw, index) => {
const line = index + 1;
const text = raw.endsWith('\r') ? raw.slice(0, -1) : raw;
const blank = text.trim().length === 0;
const indented = /^[ \t]/u.test(text);
const topLevelComment = text.startsWith(';');
if (!blank && !indented)
finish();
if (!active && !blank)
active = { startLine: line, endLine: line, lines: [] };
if (active) {
active.lines.push(raw);
if (!blank)
active.endLine = line;
}
if (topLevelComment)
finish();
});
finish();
return blocks;
}
return { splitTopLevelBlocks };
};
|