當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript eol.split函數代碼示例

本文整理匯總了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;
    };
開發者ID:pgilad,項目名稱:leasot,代碼行數:28,代碼來源:pascalParser.ts

示例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;
    };
開發者ID:pgilad,項目名稱:leasot,代碼行數:26,代碼來源:twigParser.ts

示例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);
}
開發者ID:pgilad,項目名稱:leasot,代碼行數:8,代碼來源:reporter-spec.ts

示例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;
}
開發者ID:pgilad,項目名稱:leasot,代碼行數:13,代碼來源:defaultParser.ts

示例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;
    };
開發者ID:pgilad,項目名稱:leasot,代碼行數:41,代碼來源:defaultParser.ts

示例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;
    };
開發者ID:pgilad,項目名稱:leasot,代碼行數:13,代碼來源:haskellParser.ts

示例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;
    };
開發者ID:pgilad,項目名稱:leasot,代碼行數:48,代碼來源:hamlParser.ts

示例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;
    };
開發者ID:pgilad,項目名稱:leasot,代碼行數:16,代碼來源:erlangParser.ts

示例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;
    };
開發者ID:pgilad,項目名稱:leasot,代碼行數:38,代碼來源:latexParser.ts

示例10: function

 cp.on('close', function(exitCode: number) {
     cb(exitCode, split(stripAnsi(chunks)));
 });
開發者ID:pgilad,項目名稱:leasot,代碼行數:3,代碼來源:cli-spec.ts


注:本文中的eol.split函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。