當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。