A fetch-like function. Deliberately looser than typeof fetch for the same reason as
FetchLikeResponse - so alternatives like undici's fetch (or any other spec-compliant
implementation) are assignable as-is. input is narrowed to string | URL (dropping
Request) because that's genuinely all notify() ever passes - generateRequest()'s
endpoint is always a plain string - and lib.dom's Request vs. undici's own aren't
mutually assignable (undici's requires duplex), which would otherwise force a
consumer-side cast for no real gain: nothing here ever constructs a Request object.
A plain FetchLikeInit (not the global RequestInit) for the same reason, and to keep
generateRequest()'s own return type consistent with what gets passed to it - see
FetchLikeInit. generateRequest()'s returned init is usable as a real RequestInit
unchanged (its fields are a subset). The other direction - a value typed typeof fetch isn't
structurally assignable to FetchLike, purely a TS/Node generic-Uint8Array version quirk on
body, not a real runtime mismatch - is why WebPush adapts the global fetch through one
small wrapper internally (see defaultFetch in webpush.ts) rather than relying on that
assignability here.
A fetch-like function. Deliberately looser than
typeof fetchfor the same reason as FetchLikeResponse - so alternatives like undici'sfetch(or any other spec-compliant implementation) are assignable as-is.inputis narrowed tostring | URL(droppingRequest) because that's genuinely allnotify()ever passes -generateRequest()'sendpointis always a plain string - and lib.dom'sRequestvs. undici's own aren't mutually assignable (undici's requiresduplex), which would otherwise force a consumer-side cast for no real gain: nothing here ever constructs aRequestobject.A plain
FetchLikeInit(not the globalRequestInit) for the same reason, and to keepgenerateRequest()'s own return type consistent with what gets passed to it - see FetchLikeInit.generateRequest()'s returnedinitis usable as a realRequestInitunchanged (its fields are a subset). The other direction - a value typedtypeof fetchisn't structurally assignable toFetchLike, purely a TS/Node generic-Uint8Arrayversion quirk onbody, not a real runtime mismatch - is whyWebPushadapts the global fetch through one small wrapper internally (seedefaultFetchin webpush.ts) rather than relying on that assignability here.