@trifrost/core
Version:
Blazingly fast, runtime-agnostic server framework for modern edge and node environments
19 lines (18 loc) • 669 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.verifyFileStream = verifyFileStream;
/**
* Verifies that an unknown stream is file-stream-like for usage in new Response
*
* @param {unknown} stream
*/
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`);
}