import ResponseError from './response-error.js';
function baseTypedResponse(thenFn = (value) => value) {
    return (Err = ResponseError) => {
        return async (response) => {
            if (!response.ok) {
                throw new Err(response);
            }
            return response.json().then(thenFn);
        };
    };
}
export function blobResponse(Err = ResponseError) {
    return (response) => {
        if (!response.ok)
            throw new Err(response);
        return response.blob();
    };
}
export const typedResponse = baseTypedResponse();
export const typedDataResponse = baseTypedResponse(({ data }) => data);
export const typedVoidResponse = baseTypedResponse(() => { });
