本文整理汇总了TypeScript中eol.split函数的典型用法代码示例。如果您正苦于以下问题:TypeScript split函数的具体用法?TypeScript split怎么用?TypeScript split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: parse
return function parse(contents, file) {
let comments: TodoComment[] = [];
split(contents).forEach(function(line, index) {
let hashMatch = commentsRegex.exec(line);
while (hashMatch) {
const comment = prepareComment(hashMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
hashMatch = commentsRegex.exec(line);
}
let multiLineMatch = multiLineRegex.exec(line);
while (multiLineMatch) {
const comment = prepareComment(multiLineMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
multiLineMatch = multiLineRegex.exec(line);
}
});
// sort by line number
comments = comments.sort((a, b) => a.line - b.line);
return comments;
};
示例2: parse
return function parse(contents, file) {
const comments: TodoComment[] = [];
split(contents).forEach(function(line, index) {
let bangCommentMatch = bangComment.exec(line);
while (bangCommentMatch) {
const comment = prepareComment(bangCommentMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
bangCommentMatch = bangComment.exec(line);
}
let htmlCommentMatch = htmlComment.exec(line);
while (htmlCommentMatch) {
const comment = prepareComment(htmlCommentMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
htmlCommentMatch = htmlComment.exec(line);
}
});
return comments;
};
示例3: getReport
function getReport(filename: string, reporter: ReporterName, parseOptions: ParseConfig) {
parseOptions.filename = filename;
const content = fs.readFileSync(filename, 'utf8');
const comments = leasot.parse(content, parseOptions);
const report = leasot.report(comments, reporter);
return split(report);
}
示例4: getLineFromPos
// Bases on get-line-from-pos to support Windows as well
// See https://github.com/pgilad/get-line-from-pos/blob/master/index.js
function getLineFromPos(str: string, pos: number) {
if (pos === 0) {
return 1;
}
//adjust for negative pos
if (pos < 0) {
pos = str.length + pos;
}
const lines = split(str.substr(0, pos));
return lines.length;
}
示例5: parse
return function parse(contents, file) {
const comments: TodoComment[] = [];
split(contents).forEach(function(line, index) {
let match = rLineComment.exec(line);
while (match) {
const comment = prepareComment(match, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
match = rLineComment.exec(line);
}
});
//look for block comments
let match = rBlockComment.exec(contents);
while (match) {
if (!match || !match.length) {
break;
}
//use first match as basis to look into todos/fixmes
const baseMatch = match[0];
// jshint loopfunc:true
split(baseMatch).forEach(function(line, index) {
let subMatch = rInnerBlock.exec(line);
while (subMatch) {
const adjustedLine = getLineFromPos(contents, match.index) + index;
const comment = prepareComment(subMatch, adjustedLine, file);
if (!comment) {
break;
}
comments.push(comment);
subMatch = rInnerBlock.exec(line);
}
});
match = rBlockComment.exec(contents);
}
return comments;
};
示例6: parse
return function parse(contents, file) {
const comments: TodoComment[] = [];
split(contents).forEach(function(line, index) {
const match = commentsRegex.exec(line);
const comment = prepareComment(match, index + 1, file);
if (!comment) {
return;
}
comments.push(comment);
});
return comments;
};
示例7: parse
return function parse(contents, file) {
const comments: TodoComment[] = [];
split(contents).forEach(function(line, index) {
let hamlRubyCommentMatch = hamlRubyComment.exec(line);
let hamlHtmlCommentMatch = hamlHtmlComment.exec(line);
let erbCommentMatch = erbComment.exec(line);
let htmlCommentMatch = htmlComment.exec(line);
while (hamlRubyCommentMatch) {
const comment = prepareComment(hamlRubyCommentMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
hamlRubyCommentMatch = hamlRubyComment.exec(line);
}
while (hamlHtmlCommentMatch) {
const comment = prepareComment(hamlHtmlCommentMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
hamlHtmlCommentMatch = hamlHtmlComment.exec(line);
}
while (erbCommentMatch) {
const comment = prepareComment(erbCommentMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
erbCommentMatch = erbComment.exec(line);
}
while (htmlCommentMatch) {
const comment = prepareComment(htmlCommentMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
htmlCommentMatch = htmlComment.exec(line);
}
});
return comments;
};
示例8: parse
return function parse(contents, file) {
const comments: TodoComment[] = [];
split(contents).forEach(function(line, index) {
let hashMatch = commentsRegex.exec(line);
while (hashMatch) {
const comment = prepareComment(hashMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
hashMatch = commentsRegex.exec(line);
}
});
return comments;
};
示例9: parse
return function parse(contents, file) {
const comments: TodoComment[] = [];
split(contents).forEach(function(line, index) {
let hashMatch = commentsRegex.exec(line);
while (hashMatch) {
const comment = prepareComment(hashMatch, index + 1, file);
if (!comment) {
break;
}
comments.push(comment);
hashMatch = commentsRegex.exec(line);
}
});
// doing the multiline match outside of the loop because we need
// multiple lines
const multilineRegex = new RegExp(
'^[ |\\t]*\\\\begin{comment}\\s*@?(todo|fixme)(?!\\w)\\s*(?:\\(([^)]*)\\))?\\s*:?\\s*((.*?)(?:\\s+([^\\s]+)\\s*)?)\\\\end{comment}',
'gmi'
);
let m;
while ((m = multilineRegex.exec(contents)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === multilineRegex.lastIndex) {
multilineRegex.lastIndex++;
}
// Since we no longer know the line number as index, we have to
// count it out. This could be inefficient for large files, so I
// hope it doesn't become a performance problem
const preceeding_lines = contents.slice(0, m.index);
const line_no = preceeding_lines.split(/\r\n|\r|\n/).length;
// Now prepare the comment
const comment = prepareComment(m, line_no, file);
comments.push(comment);
}
return comments;
};
示例10: function
cp.on('close', function(exitCode: number) {
cb(exitCode, split(stripAnsi(chunks)));
});