UNPKG

@credo-ts/core

Version:

<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1

1 lines • 991 B
{"version":3,"file":"fetch.mjs","names":[],"sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { AgentDependencies } from '../agent/AgentDependencies'\n\nexport async function fetchWithTimeout(\n fetch: AgentDependencies['fetch'],\n url: string,\n init?: Omit<RequestInit, 'signal'> & {\n /**\n * @default 5000\n */\n timeoutMs?: number\n }\n) {\n const abortController = new AbortController()\n const timeoutMs = init?.timeoutMs ?? 5000\n\n const timeout = setTimeout(() => abortController.abort(), timeoutMs)\n\n try {\n return await fetch(url, {\n ...init,\n signal: abortController.signal as NonNullable<RequestInit['signal']>,\n })\n } finally {\n clearTimeout(timeout)\n }\n}\n"],"mappings":";;;AAEA,eAAsB,iBACpB,OACA,KACA,MAMA;CACA,MAAM,kBAAkB,IAAI,iBAAiB;CAC7C,MAAM,YAAY,MAAM,aAAa;CAErC,MAAM,UAAU,iBAAiB,gBAAgB,OAAO,EAAE,UAAU;AAEpE,KAAI;AACF,SAAO,MAAM,MAAM,KAAK;GACtB,GAAG;GACH,QAAQ,gBAAgB;GACzB,CAAC;WACM;AACR,eAAa,QAAQ"}