当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript event-stream.split函数代码示例

本文整理汇总了TypeScript中event-stream.split函数的典型用法代码示例。如果您正苦于以下问题:TypeScript split函数的具体用法?TypeScript split怎么用?TypeScript split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了split函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createReadStream

    .pipe(map((file, callback) => {
      let variableLine, variableName, defaultValue, multiline;
      createReadStream(file.path, { flags: 'r'})
        .pipe(split())
        .pipe(map((line, callback) => {
          if (line.charAt(0) === '$') {
            variableLine = line.split(/:(.+)/);
              variableName = variableLine[0];
              defaultValue = variableLine[1];

              // If there is a semicolon then it isn't a multiline value
              multiline = line.indexOf(';') > -1 ? false : true;
              if (!multiline && line.indexOf('!default') > -1) {
                addVariable(variableName, defaultValue, file);
              }
          } else if (multiline === true) {
              defaultValue += '\n' + line;

              // If the line has a semicolon then we've found the end of the value
              if (line.indexOf(';') > -1 && line.indexOf('!default') > -1) {
                addVariable(variableName, defaultValue, file);
                multiline = false;
              }
            }
            callback();
        }));
        callback();
    }).on('end', () => {
开发者ID:ciekawy,项目名称:ionic,代码行数:28,代码来源:docs.ts

示例2: parse_file_line

export function parse_file_line(file_path : string, parse : (line:string)=>void, error : () => void, success  : () => void){
        let fs = require('fs')
        let es = require('event-stream');
                
        let stream = fs.createReadStream(file_path).pipe(es.split()).pipe(
            es.mapSync(function(line){
                stream.pause();
                
                parse(line);               
                
                stream.resume();    
            }).on('error',function(){
                error();
            }).on('end',function(){
                success();
            })
        );    
}
开发者ID:hcyang1012,项目名称:vscode_ctags,代码行数:18,代码来源:file_manager.ts

示例3: require

var crc32 = require("crc-32");
var pgp = require('pg-promise')();

var cn = {
    host: 'localhost',
    port: 5432,
    database: 'Test',
    user: 'postgres',
    password: 'postgres'
};
var db = pgp(cn);
var currLineNumber = 0;

var fs = require('fs'), util = require('util'), stream = require('stream'), es = require('event-stream');
var s = fs.createReadStream('./Data/words.txt')
    .pipe(es.split())
    .pipe(es.mapSync(function(line){
            s.pause();
            var hash = crc32.str(line);
            db.none("INSERT INTO \"Words\"(\"Word\", \"Hash\", \"HashSigned\", \"HashInteger\") VALUES(${word}, ${hash}, ${hashSigned}, ${hashInteger})", {
                word: line,
                hash: numberToHex(hash, 2),
                hashSigned: numberToHexSigned(hash, 2),
                hashInteger: hash,
            }).then(() => {
                if(++currLineNumber % 1000 === 0) {
                    console.info("INSERT ROWS: " + Math.round(currLineNumber / 1000) + "k, latest line: " + line);
                }

                s.resume();
            }).catch((data) => {
开发者ID:Dyas,项目名称:challenge_word_classifier,代码行数:31,代码来源:FillDataBase.ts

示例4:

        console.info("--- --- Phase: 3 - Json convert\n");
        var packedDictionary: IPackedDictionary = {
            rule: {
                firstIndex: this.rule.firstIndex,
                charCount: this.rule.charCount
            },
            data: data
        };
        
        return JSON.stringify(packedDictionary);
    }
}


//var count = 0;
fs.createReadStream(wordsPath).pipe(es.split()).pipe(es.mapSync((line: string) => {
    word = line.toLowerCase();

    // if(word.indexOf("'") !== -1) {
    //     count++;
    // }
    //
    // var wordLength = word.length;
    //
    // if(wordLength > 6) {
    //     if(word.indexOf("'") > wordLength / 2 && word.lastIndexOf("'") < wordLength - 4) {
    //         console.info(word);
    //     }
    // }

    for(key in dictionaries) {
开发者ID:Dyas,项目名称:challenge_word_classifier,代码行数:31,代码来源:BuildTree.ts


注:本文中的event-stream.split函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。