1
import { Readable } from 'stream';
2 1
export const convert = (
3
	stream: Blob | Readable | ReadableStream
4
): Promise<Uint8Array> => {
5 1
	if (stream instanceof Blob || stream instanceof ReadableStream) {
6 1
		return new Response(stream)
7
			.arrayBuffer()
8 1
			.then(buffer => new Uint8Array(buffer));
9
	} else {
10 0
		throw new Error('Readable is not supported.');
11
	}
12
};

Read our documentation on viewing source code .

Loading