How to use the @hapi/wreck.toReadableStream function in @hapi/wreck

To help you get started, we’ve selected a few @hapi/wreck examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hapijs / hapi / test / headers.js View on Github external
it('returns a normal response when JSONP requested but stream returned', async () => {

            const server = Hapi.server();
            const stream = Wreck.toReadableStream('test');
            stream.size = 4;                                    // Non function for coverage
            server.route({ method: 'GET', path: '/', options: { jsonp: 'callback', handler: () => stream } });

            const res = await server.inject('/?callback=me');
            expect(res.payload).to.equal('test');
        });
    });
github hapijs / ammo / test / index.js View on Github external
it('returns a subset of a stream', async () => {

        const random = Buffer.alloc(5000);
        const source = Wreck.toReadableStream(random);
        const range = Ammo.header('bytes=1000-4000', 5000);
        const stream = new Ammo.Clip(range[0]);

        const buffer = await Wreck.read(source.pipe(stream));
        expect(buffer.toString()).to.equal(random.slice(1000, 4001).toString());
    });

@hapi/wreck

HTTP Client Utilities

BSD-3-Clause
Latest version published 22 days ago

Package Health Score

89 / 100
Full package analysis