本文整理汇总了TypeScript中line-by-line.close函数的典型用法代码示例。如果您正苦于以下问题:TypeScript close函数的具体用法?TypeScript close怎么用?TypeScript close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了close函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
lr.on('line', (line: string) => {
if (shebangLines.length >= MAX_SHEBANG_LINES) {
lr.close();
return false;
}
var trimmedLine = line.trim();
if (trimmedLine.startsWith("#")) {
shebangLines.push(line);
}
else {
shebangLines.push("#");
}
});
示例2:
lr.on('line', (line: string) => {
//Two characters for the charriage return and line feeds
lengthOfEachLine.set(lineNumber, line.length + 2);
var totalCharactersUntillPreviousLine = totalCharactersRead;
totalCharactersRead += line.length + 2;
positions.forEach(pos => {
if (totalCharactersRead === pos) {
lineNumbersIndexedByPosition.set(pos, new vscode.Position(lineNumber, line.length));
return;
}
if (totalCharactersRead > pos && pos > totalCharactersUntillPreviousLine) {
lineNumbersIndexedByPosition.set(pos, new vscode.Position(lineNumber, pos - totalCharactersUntillPreviousLine));
}
});
//If we have read untill the position required, then bugger off from here
if (totalCharactersRead >= largestPosition) {
lr.close();
lineNumber++;
}
});
示例3: function
lr.on('line', function(line) {
lineNumber++;
//Valid parts of a try block include
//try:, except <error>:, except: else: finally:
//Anything other than this in the same column indicates a termination of the try block
var trimmedLine = line.trim();
var matches = line.match(/^\s*try(\s*):/);
if (matches !== null && matches.length > 0) {
let column = line.indexOf("try");
if (column === -1) {
return;
}
//If the new try starts at the same column
//Then the previous try block has ended
if (tryColumnBlocks.has(column)) {
var tryBlockClosed = tryColumnBlocks.get(column);
tryColumnBlocks.delete(column);
tryStatements.push(tryBlockClosed);
}
var tryStatement: ITryStatementEx = {
Column: column,
EndLineNumber: 0,
Exceptions: [],
StartLineNumber: lineNumber
};
tryColumnBlocks.set(column, tryStatement);
return;
}
//look for excepts
matches = line.match(/^\s*except/);
if (matches !== null && matches.length > 0 &&
(trimmedLine.startsWith("except ") || trimmedLine.startsWith("except:"))) {
//Oops something has gone wrong
if (tryColumnBlocks.size === 0) {
resolve(tryStatements);
lr.close();
return;
}
let column = line.indexOf("except");
//Do we have a try block for this same column
if (!tryColumnBlocks.has(column)) {
return;
}
let currentTryBlock = tryColumnBlocks.get(column);
let exceptions = extractExceptions(line);
currentTryBlock.Exceptions = currentTryBlock.Exceptions.concat(exceptions);
if (currentTryBlock.EndLineNumber === 0) {
currentTryBlock.EndLineNumber = lineNumber;
}
return;
}
//look for else
matches = line.match(/^\s*else(\s*):/);
if (matches !== null && matches.length > 0 &&
(trimmedLine.startsWith("else ") || trimmedLine.startsWith("else:"))) {
//This is possibly an if else...
if (tryColumnBlocks.size === 0) {
return;
}
let column = line.indexOf("else");
//Check if we have a try associated with this column
//If not found, this is probably an if else block or something else
if (!tryColumnBlocks.has(column)) {
return;
}
//Else marks the end of the try block (of course there could be a finally too)
let currentTryBlock = tryColumnBlocks.get(column);
if (currentTryBlock.EndLineNumber === 0) {
currentTryBlock.EndLineNumber = lineNumber;
}
tryColumnBlocks.delete(column);
tryStatements.push(currentTryBlock);
return;
}
//look for finally
matches = line.match(/^\s*finally(\s*):/);
if (matches !== null && matches.length > 0 &&
(trimmedLine.startsWith("finally ") || trimmedLine.startsWith("finally:"))) {
let column = line.indexOf("finally");
//Oops something has gone wrong, or we cleared the previous
//Try block because we encountered an else
if (tryColumnBlocks.size === 0) {
return;
}
//If this column doesn't match the current exception block, then it is likely we encountered an else for the try block..
//.........这里部分代码省略.........