// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { readerFromStreamReader as _readerFromStreamReader } from "jsr:/@std/io@^0.224.1/reader-from-stream-reader";
import type { Reader } from "jsr:/@std/io@^0.224.1/types";

/**
 * Create a {@linkcode https://jsr.io/@std/io/doc/types/~/Reader | Reader} from a {@linkcode ReadableStreamDefaultReader}.
 *
 * @param streamReader A `ReadableStreamDefaultReader` to convert into a `Reader`.
 * @returns A `Reader` that reads from the `streamReader`.
 *
 * @example Copy the response body of a fetch request to the blackhole
 * ```ts no-eval no-assert
 * import { copy } from "@std/io/copy";
 * import { readerFromStreamReader } from "@std/streams/reader-from-stream-reader";
 * import { devNull } from "node:os";
 *
 * const res = await fetch("https://deno.land");
 * using blackhole = await Deno.open(devNull, { write: true });
 *
 * const reader = readerFromStreamReader(res.body!.getReader());
 * await copy(reader, blackhole);
 * ```
 *
 * @deprecated This will be removed in 1.0.0. Import from
 * {@link https://jsr.io/@std/io | @std/io} instead.
 */
export function readerFromStreamReader(
  streamReader: ReadableStreamDefaultReader<Uint8Array>,
): Reader {
  return _readerFromStreamReader(streamReader);
}

// denoCacheMetadata={"headers":{"cross-origin-resource-policy":"cross-origin","etag":"\"b8b116e5784336a844f40f5ad7fa182d\"","date":"Tue, 28 Jul 2026 12:31:15 GMT","content-type":"text/typescript","vary":"Origin","x-content-type-options":"nosniff","x-jsr-backend":"modules","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=a7xHb1TCHkIE5OeX7S4At%2Fi04KSKYXDjUmJrwCuyEqXWurmTBciQWZCbVDrlzGbvtc4XgCSIFdgkoE3Fxz%2FO1JN5x%2FlQER1qvDP3b%2FYISQrVn78NheIUkoQ%3D\"}]}","set-cookie":"__cf_bm=s4H7yjCSMH5m2okPGgt92wOHMVYLM6JNJnWKtvVlN3U-1785241875.18165-1.0.1.1-E8VIYvIK.on80LVVPp6LCPWRAZdEjkWdHvr3LXEeLT2Yxj0WPzECHHlF9nuMNILmKd3FUNCs9wA4P9Mz8tE7mWRPccTP7EoogUgO.6vWeSuo3IDbPRzikikE5y_Dk4m2; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","cf-ray":"a223e657dac07db6-LAX","cf-cache-status":"HIT","accept-ranges":"bytes","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","server":"cloudflare","age":"112265","alt-svc":"h3=\":443\"; ma=86400","cache-control":"public, max-age=31536000, immutable","x-robots-tag":"noindex","access-control-allow-origin":"*","content-length":"1328","access-control-expose-headers":"*"},"url":"https://jsr.io/@std/streams/0.224.5/reader_from_stream_reader.ts","time":1785241875}