TypeScript web-stream-tools toStream示例

说明

typescript web-stream-tools tostream示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: TypeScript

命名空间/包名称: web-stream-tools

示例#1
文件: fromdomstream-spec.ts 项目: ReactiveX/IxJS

 test('objectMode: false', async () => {
   const c = toStream(new Counter({ objectMode: false }));
   const xs = fromDOMStream(c) as AsyncIterable<Buffer>;
   const expected = AsyncIterable.from(['1', '2', '3'].map(s => Buffer.from(s)));
   await expect(xs).toEqualStream(expected, compare);
 });

示例#2
文件: fromdomstream-spec.ts 项目: ReactiveX/IxJS

 test('objectMode: true', async () => {
   const c = toStream(new Counter({ objectMode: true }));
   const xs = fromDOMStream(c) as AsyncIterable<string>;
   const expected = AsyncIterable.from(['1', '2', '3']);
   await expect(xs).toEqualStream(expected, compare);
 });

展开阅读全文