UNPKG

@trifrost/core

Version:

Blazingly fast, runtime-agnostic server framework for modern edge and node environments

16 lines (15 loc) 554 B
/** * Verifies that an unknown stream is file-stream-like for usage in new Response * * @param {unknown} stream */ export function verifyFileStream(stream) { if (stream instanceof ReadableStream || stream instanceof Uint8Array || stream instanceof ArrayBuffer || (typeof Blob !== 'undefined' && stream instanceof Blob) || typeof stream === 'string') return; const type = Object.prototype.toString.call(stream); throw new Error(`verifyFileStream: Unsupported stream type (${type}) for response`); }