Skip to content
1 min read · 124 words

Function: fromFetch()

ts
function fromFetch(url: string | URL, init?: RequestInit): MediaReader;

Constructs a @nhtio/adk!MediaReader backed by a fetch call.

Parameters

ParameterTypeDescription
urlstring | URLThe URL to fetch on each call.
init?RequestInitOptional fetch init forwarded verbatim.

Returns

MediaReader

A @nhtio/adk!MediaReader that re-issues fetch(url, init) on every call.

Remarks

Each stream() call re-issues the fetch. Tool authors whose underlying source is rate-limited or expensive must cache locally before constructing the reader — the framework cannot make that decision for them.

byteLength() returns undefined because most remote sources do not promise it without an extra HEAD request; consumers that need a byte size should resolve it out-of-band.