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


TypeScript web-stream-tools.concatStream函数代码示例

本文整理汇总了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);
    });
开发者ID:laurentgo,项目名称:arrow,代码行数:30,代码来源:streams-dom-tests.ts

示例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);
    });
开发者ID:emkornfield,项目名称:arrow,代码行数:36,代码来源:streams-dom-tests.ts


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