Skip to content

Concepts: return model

Eugene Lazutkin edited this page Jul 3, 2026 · 2 revisions

Concepts: the return model

double-meh's central rule: the method you call fixes what comes back — options tune behavior, never the return type. You always know a call's shape from its name.

Call Returns
io.get(url) (any bare verb) the parsed data
io.full.get(url) the full response envelope
io.stream.get(url) a Web ReadableStream of the response body
io.stream.put(url, opts?) (also post/patch) a streaming {writable, readable, response} duplex
io.head(url) / io.options(url) derived metadata (no body)

Why fix the shape by method

An option that flipped the return type would force every caller to know which options were passed before they could use the result. double-meh makes the verb + namespace the single source of truth instead:

  • io.get(url) — the 99% path: const person = await io.get(url).
  • io.full.get(url) — when you need status / headers / validators. The bare verb is the envelope's .data: io.get(url)(await io.full.get(url)).data.
  • io.stream.get(url) — when you want the raw body stream.
  • io.stream.put/post/patch(...) — when you are streaming a request body — see Streaming.

io.full and io.stream are modifier namespaces that only change the shape: io.full carries every verb; io.stream carries get for the response stream and the write duplexes put/post/patch.

Options tune behavior, not shape

ifMatch, as, cache, retry, signal, fetch change what a call does, never what type it returns. (This is why there is no {envelope: true} flag — an option that flipped the type would leak into every caller; the io.full namespace declares it instead.)

See also

Clone this wiki locally