• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript stream.Readable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onData

function onData(stream: Readable, session: SMTPServerSession, callback: (err?: Error) => void): void {
    console.log(`[${session.id}] onData started`);

    let messageLength = 0;

    stream.on('data', (chunk: Buffer) => {
        console.log(`[${session.id}] onData got data chunk ${chunk.length} bytes`);
        messageLength += chunk.length;
    });

    stream.once('end', () => {
        console.log(`[${session.id}] onData finished after reading ${messageLength} bytes`);
        callback();
    });
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:15,代码来源:smtp-server-tests.ts


示例2: forwardData

	private forwardData(stream: Readable, encoding: string, cb: (err: Error, stdout?: string) => void): NodeStringDecoder {
		const decoder = new StringDecoder(encoding);
		stream.on('data', (data: Buffer) => {
			cb(null, decoder.write(data));
		});
		return decoder;
	}
开发者ID:naturtle,项目名称:vscode,代码行数:7,代码来源:fileSearch.ts


示例3: collectData

	private collectData(stream: Readable): Buffer[] {
		const buffers: Buffer[] = [];
		stream.on('data', (data: Buffer) => {
			buffers.push(data);
		});
		return buffers;
	}
开发者ID:naturtle,项目名称:vscode,代码行数:7,代码来源:fileSearch.ts


示例4: it

 it("Copy Complete", () => {
     log("Init Output / Input Stream");
     inSource = new FileSource({path: file});
     file0 = path.resolve(file0dir, "./out.log");
     outSource = new FileSource();
     input = inSource.createReadableStream(
       (option) => {log("input option", option); return option; },
     ) as Readable;
     output = outSource.createWritableStream(
       (option) => {
         option.path = file0,
         log("output option", option);
         return option;
       },
     ) as Writable;
     input.pipe(output);
     return new Promise((resolve, reject) => {
         input.on("end", () => {
             log("Input End!");
             const json = fse.readJsonSync(file0);
             if (JSON.stringify(TEST_JSON) === JSON.stringify(json)) {
                 log("Successfully Copy");
                 resolve();
             } else {
                 log("Failed to Copy");
                 reject();
             }
         });
     });
 });
开发者ID:node-dmr,项目名称:dmr-source,代码行数:30,代码来源:source-file.ts


示例5: lint

    lint(html: string): Promise<Issue[]> {

        var parser: SAXParser = new SAXParser({ locationInfo: true });
        var parseState: ParseState = new ParseState(this.scopes, this.voids);
        var stream: Readable = new Readable();

        parseState.initPreRules(parser);

        let rules = this.rules;

        rules.forEach((rule) => {
            rule.init(parser, parseState);
        });

        parseState.initPostRules(parser);

        stream.push(html);
        stream.push(null);
        var work = stream.pipe(parser);

        var completed = new Promise<void>(function (resolve, reject) {
            work.on("end", () => {
                parseState.finalise();
                resolve();
            });
        });

        var ruleTasks = [];

        rules.forEach((rule) => {
            let task = completed.then(() => {
                return rule.finalise();
            });
            ruleTasks.push(task);
        });

        return Promise.all(ruleTasks).then(results => {

            var all = new Array<Issue>();

            results.forEach(parts => {
                all = all.concat(parts);
            });

            return all;
        });
    }
开发者ID:gitter-badger,项目名称:template-lint,代码行数:47,代码来源:linter.ts


示例6: readToEnd

export function readToEnd(stream: Readable,
                          callback: (error: Error, chunks?: any[]) => void) {
  const chunks: Array<Buffer | string> = [];
  return stream
  .on('error', callback)
  .on('data', chunk => chunks.push(chunk))
  .on('end', () => callback(null, chunks));
}
开发者ID:chbrown,项目名称:streaming,代码行数:8,代码来源:index.ts


示例7: Promise

	return Promise.resolve(mkdirp(targetDirName, void 0, token)).then(() => new Promise((c, e) => {
		if (token.isCancellationRequested) {
			return;
		}

		try {
			istream = createWriteStream(targetFileName, { mode });
			istream.once('close', () => c());
			istream.once('error', e);
			stream.once('error', e);
			stream.pipe(istream);
		} catch (error) {
			e(error);
		}
	}));
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:15,代码来源:zip.ts


示例8: handleError

 (err, result) => {
     if (err) {
         handleError(err)
     } else {
         result.rows.map(row => stream.push(row))
         stream.push(null)
     }
 }
开发者ID:jakobrun,项目名称:gandalf,代码行数:8,代码来源:pgConnector.ts


示例9: c

	return new Promise<string>((c, e) => {
		const shasum = crypto.createHash(hashName);

		stream
			.on('data', shasum.update.bind(shasum))
			.on('error', e)
			.on('close', () => c(shasum.digest('hex')));
	});
开发者ID:PKRoma,项目名称:vscode,代码行数:8,代码来源:publish.ts


示例10: initialize

function initialize(){
  GERRIT_STREAM
  .pipe(TO_GERRIT_EVENT(), { end: false })
  .pipe(REGISTER_REVIEWER_ADDED(), { end: false })
  .pipe(TO_NOTIFICATION_OBJECT(), { end: false })
  .pipe(TO_NATIVE_NOTIFICATION(platform), { end: false })
  .pipe(TO_FILE(), { end: false });
}
开发者ID:adasq,项目名称:gerrit-native-notifications,代码行数:8,代码来源:test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript stream.Stream类代码示例发布时间:2022-05-25
下一篇:
TypeScript stream.PassThrough类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap