本文整理汇总了TypeScript中web-stream-tools.concatStream函数的典型用法代码示例。如果您正苦于以下问题:TypeScript concatStream函数的具体用法?TypeScript concatStream怎么用?TypeScript concatStream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了concatStream函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should not close the underlying WhatWG ReadableStream when reading multiple tables to completion', async () => {
expect.hasAssertions();
const tables = [...generateRandomTables([10, 20, 30])];
const stream = concatStream(tables.map((table, i) =>
RecordBatchStreamWriter.writeAll(table).toDOMStream({
// Alternate between bytes mode and regular mode because code coverage
type: i % 2 === 0 ? 'bytes' : undefined
})
)) as ReadableStream<Uint8Array>;
let tableIndex = -1;
let reader = await RecordBatchReader.from(stream);
validateStreamState(reader, stream, false);
for await (reader of RecordBatchReader.readAll(reader)) {
validateStreamState(reader, stream, false);
const sourceTable = tables[++tableIndex];
const streamTable = await Table.from(reader);
expect(streamTable).toEqualTable(sourceTable);
}
validateStreamState(reader, stream, true);
expect(tableIndex).toBe(tables.length - 1);
});
示例2: it
it('readAll() should pipe to separate WhatWG WritableStreams', async () => {
expect.hasAssertions();
const tables = [...generateRandomTables([10, 20, 30])];
const stream = concatStream(tables.map((table, i) =>
RecordBatchStreamWriter.writeAll(table).toDOMStream({
// Alternate between bytes mode and regular mode because code coverage
type: i % 2 === 0 ? 'bytes' : undefined
})
)) as ReadableStream<Uint8Array>;
let tableIndex = -1;
let reader: RecordBatchReader | undefined;
for await (reader of RecordBatchReader.readAll(stream)) {
validateStreamState(reader, stream, false);
const output = reader
.pipeThrough(RecordBatchStreamWriter.throughDOM())
.pipeThrough(new TransformStream());
validateStreamState(reader, output, false, false);
const sourceTable = tables[++tableIndex];
const streamTable = await Table.from(output);
expect(streamTable).toEqualTable(sourceTable);
expect(output.locked).toBe(false);
}
expect(reader).toBeDefined();
validateStreamState(reader!, stream, true);
expect(tableIndex).toBe(tables.length - 1);
});