Buckets:
ktongue/docker_container / .cache /opencode /node_modules /hono /dist /client /fetch-result-please.js
| // src/client/fetch-result-please.ts | |
| var nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]); | |
| async function fetchRP(fetchRes) { | |
| const _fetchRes = await fetchRes; | |
| const hasBody = (_fetchRes.body || _fetchRes._bodyInit) && !nullBodyResponses.has(_fetchRes.status); | |
| if (hasBody) { | |
| const responseType = detectResponseType(_fetchRes); | |
| _fetchRes._data = await _fetchRes[responseType](); | |
| } | |
| if (!_fetchRes.ok) { | |
| throw new DetailedError(`${_fetchRes.status} ${_fetchRes.statusText}`, { | |
| statusCode: _fetchRes?.status, | |
| detail: { | |
| data: _fetchRes?._data, | |
| statusText: _fetchRes?.statusText | |
| } | |
| }); | |
| } | |
| return _fetchRes._data; | |
| } | |
| var DetailedError = class extends Error { | |
| /** | |
| * Additional `message` that will be logged AND returned to client | |
| */ | |
| detail; | |
| /** | |
| * Additional `code` that will be logged AND returned to client | |
| */ | |
| code; | |
| /** | |
| * Additional value that will be logged AND NOT returned to client | |
| */ | |
| log; | |
| /** | |
| * Optionally set the status code to return, in a web server context | |
| */ | |
| statusCode; | |
| constructor(message, options = {}) { | |
| super(message); | |
| this.name = "DetailedError"; | |
| this.log = options.log; | |
| this.detail = options.detail; | |
| this.code = options.code; | |
| this.statusCode = options.statusCode; | |
| } | |
| }; | |
| var jsonRegex = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(?:;.+)?$/i; | |
| function detectResponseType(response) { | |
| const _contentType = response.headers.get("content-type"); | |
| if (!_contentType) { | |
| return "text"; | |
| } | |
| const contentType = _contentType.split(";").shift(); | |
| if (jsonRegex.test(contentType)) { | |
| return "json"; | |
| } | |
| return "text"; | |
| } | |
| export { | |
| DetailedError, | |
| fetchRP | |
| }; | |
Xet Storage Details
- Size:
- 1.72 kB
- Xet hash:
- f25554d3a694ba9ed8cfa4c660729a39996e1066a4e425027df58d352a4c8d91
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.