UNPKG

@typespec/ts-http-runtime

Version:

Isomorphic client library for making HTTP requests in node.js and browser.

1 lines 1.28 kB
{"version":3,"file":"typeGuards-browser.mjs","sourceRoot":"","sources":["../../../src/util/typeGuards-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,OAAO,CACL,CAAC,KAAK,IAAI;QACV,CAAC,KAAK,SAAS;QACf,OAAO,CAAC,KAAK,QAAQ;QACrB,MAAM,IAAI,CAAC;QACX,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU;QAC5B,MAAM,IAAI,CAAC;QACX,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,CAC7B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAU;IAC5C,OAAO,CAAC,YAAY,cAAc,CAAC;AACrC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Node.js readable streams are not natively available in the browser, but apps\n * may polyfill them. Use duck-typing so polyfilled streams are detected at runtime.\n *\n * @internal\n */\nexport function isNodeReadableStream(x: unknown): x is never {\n return (\n x !== null &&\n x !== undefined &&\n typeof x === \"object\" &&\n \"pipe\" in x &&\n typeof x.pipe === \"function\" &&\n \"read\" in x &&\n typeof x.read === \"function\"\n );\n}\n\n/**\n * Checks if the given value is a web ReadableStream.\n *\n * @internal\n */\nexport function isWebReadableStream(x: unknown): x is ReadableStream {\n return x instanceof ReadableStream;\n}\n"]}