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


TypeScript through2.default函数代码示例

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


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

示例1: through

var createOutStream = function(socket, id: string) {
  return through(function(chunk, enc, cb) {
    socket.emit(id, {
      data: chunk.toString('utf8'),
    });
    cb();
  })
};
开发者ID:jhliberty,项目名称:topsoil,代码行数:8,代码来源:streaming.ts

示例2: function

var createInStream = function(socket, id : string){
  var stream = through(function(chunk, enc, cb){
    cb(null, String(chunk));
  });
  socket.on(id, function(data){
    if(!data.end){
      stream.write(data.payload);
    }else{
      stream.end();
    }
  });
  return stream;
};
开发者ID:jhliberty,项目名称:topsoil,代码行数:13,代码来源:streaming.ts

示例3: createStdoutStream

function createStdoutStream(out: NodeJS.WritableStream, logFormat: string) {
    const tapSafeLogOutput = through2(function(chunk: Buffer, enc: string, callback: Function) {
            // All log records always end in a newline, so we want to strip
            // it off pre-prefixing and add it back afterwards.
            const lines = stripAnsi(chunk.toString()).trim().split('\n'),
                prefixedLines = _.map(lines, function(line) {
                        return '# ' + chalk.grey('LOG: ' + line);
                    }).join('\n') + '\n';

            callback(null, prefixedLines);
        }),
        outputStream = process.env.TAP === '1' ? tapSafeLogOutput : out,
        formattedStream = bunyanFormat({outputMode: logFormat}, outputStream);

    tapSafeLogOutput.pipe(out);

    return formattedStream;
}
开发者ID:NickHeiner,项目名称:lambdascript,代码行数:18,代码来源:create-stdout-stream.ts

示例4: streamMissingWalletAddresses

 async streamMissingWalletAddresses(params: CSP.StreamWalletMissingAddressesParams) {
   const { chain, network, pubKey, res } = params;
   const wallet = await WalletStorage.collection.findOne({ pubKey });
   const walletId = wallet!._id!;
   const query = { chain, network, wallets: walletId, spentHeight: { $gte: SpentHeightIndicators.minimum } };
   const cursor = CoinStorage.collection.find(query).addCursorFlag('noCursorTimeout', true);
   const seen = {};
   const stringifyWallets = (wallets: Array<ObjectId>) => wallets.map(w => w.toHexString());
   const allMissingAddresses = new Array<string>();
   let totalMissingValue = 0;
   const missingStream = cursor.pipe(
     through2(
       { objectMode: true },
       async (spentCoin: MongoBound<ICoin>, _, done) => {
         if (!seen[spentCoin.spentTxid]) {
           seen[spentCoin.spentTxid] = true;
           // find coins that were spent with my coins
           const spends = await CoinStorage.collection
             .find({ chain, network, spentTxid: spentCoin.spentTxid })
             .addCursorFlag('noCursorTimeout', true)
             .toArray();
           const missing = spends
             .filter(coin => !stringifyWallets(coin.wallets).includes(walletId.toHexString()))
             .map(coin => {
               const { _id, wallets, address, value } = coin;
               totalMissingValue += value;
               allMissingAddresses.push(address);
               return { _id, wallets, address, value, expected: walletId.toHexString() };
             });
           if (missing.length > 0) {
             return done(undefined, { txid: spentCoin.spentTxid, missing });
           }
         }
         return done();
       },
       function(done) {
         this.push({ allMissingAddresses, totalMissingValue });
         done();
       }
     )
   );
   missingStream.pipe(new StringifyJsonStream()).pipe(res);
 }
开发者ID:bitjson,项目名称:bitcore,代码行数:43,代码来源:internal.ts

示例5: Promise

  new Promise((resolve) => {
    (gitRawCommits({
      from: args.from,
      to: args.to || 'HEAD',
      format: '%B%n-hash-%n%H%n-gitTags-%n%D%n-committerDate-%n%ci%n-authorName-%n%aN%n',
    }) as NodeJS.ReadStream)
      .on('error', err => {
        logger.fatal('An error happened: ' + err.message);
        process.exit(1);
      })
      .pipe(through((chunk: Buffer, enc: string, callback: Function) => {
        // Replace github URLs with `@XYZ#123`
        const commit = chunk.toString('utf-8')
          .replace(/https?:\/\/github.com\/(.*?)\/issues\/(\d+)/g, '@$1#$2');

        callback(undefined, new Buffer(commit));
      }))
      .pipe(conventionalCommitsParser({
        headerPattern: /^(\w*)(?:\(([^)]*)\))?: (.*)$/,
        headerCorrespondence: ['type', 'scope', 'subject'],
        noteKeywords: ['BREAKING CHANGE'],
        revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./,
        revertCorrespondence: [`header`, `hash`],
      }))
      .pipe(through.obj((chunk: JsonObject, _: string, cb: Function) => {
        try {
          const maybeTag = chunk.gitTags && (chunk.gitTags as string).match(/tag: (.*)/);
          const tags = maybeTag && maybeTag[1].split(/,/g);
          chunk['tags'] = tags;

          if (tags && tags.find(x => x == args.to)) {
            toSha = chunk.hash as string;
          }

          commits.push(chunk);
          cb();
        } catch (err) {
          cb(err);
        }
      }))
      .on('finish', resolve);
  })
开发者ID:fmalcher,项目名称:angular-cli,代码行数:42,代码来源:changelog.ts

示例6: createDuplex

var createSpawnStream = function(command, args, options, infoHandler) {
  options = options || {};
  options.stdio = ['pipe', 'pipe'];
  var outStream = createGenericStream(function(chunk, enc, cb) {
    cb(null, chunk);
  });
  var spawnThrough = through(function(chunk, enc, cb) {
    var stream = spawn(command, args, options);
    infoHandler({
      pid: stream.pid
    });
    stream.stdin.write(String(chunk));
    stream.stdin.end();
    stream.stdout.on('data', function(d) {
      outStream.write(String(d) + '\n');
    });
    cb();
  });
  return createDuplex(spawnThrough, outStream);
};
开发者ID:jhliberty,项目名称:topsoil,代码行数:20,代码来源:streaming.ts

示例7: through

    files.forEach(filepath => {
        console.log(filepath);
        var bundledStream = through();
        var fileParts = filepath.split('/');
        var directory = fileParts.slice(0, fileParts.length - 1).join('/');
        var filename = fileParts[fileParts.length - 1].replace('.ts', '.out.js');

        if (filename == 'app.js')
            return;

        if (filename.indexOf('.out.out.') !== -1) {
            return;
        }

         console.log(`dir: ${directory} filename: ${filename}`);

        bundledStream
            .pipe(source(filename))
            .pipe(buffer())
            // .pipe(sm.init({loadMaps: true}))
            // .pipe(uglify())
            // .pipe(sm.write('./'))
            .pipe(gulp.dest(directory));

        globby(taskPath, function(err, entries) {
            if (err) {
                bundledStream.emit('error', err);
                return;
            }

            var b = browserify({
                entries: [filepath],
                debug: true,
                paths: ['scripts'],
                noParse:['lodash.js'],
                standalone: 'GLib'

            }).plugin('tsify',{target:'es5'});
            b.bundle().pipe(bundledStream);
        });
    });
开发者ID:cmc19,项目名称:GutiarLibTS,代码行数:41,代码来源:gulpfile.ts


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