import type { SWRResponse } from "swr"; import { Failure, Pending } from "../async-op.ts"; import type { FailurePayload } from "../types.ts"; export function swrResponseToResult(response: SWRResponse) { const { data, error } = response; if (data !== undefined) { return data; } if (error !== undefined) { console.error(error); return new Failure({ type: "UNKNOWN_ERROR" }); } return new Pending(); }