An ES (JavaScript & TypeScript) module to extend fetch
.
Request
-Response
s to reduce network usage and response time.Retry-After
.Remote | JSR | NPM | |
---|---|---|---|
Bun >= v1.1.0 | ❌ | ❓ | ✔️ |
Cloudflare Workers | ❌ | ❓ | ✔️ |
Deno >= v1.42.0 | ✔️ | ✔️ | ✔️ |
NodeJS >= v18.12.0 | ❌ | ❓ | ✔️ |
https://deno.land/x/exfetch[@{Tag}]/mod.ts
https://raw.githubusercontent.com/hugoalh/exfetch-es/{Tag}/mod.ts
[jsr:]@hugoalh/exfetch[@{Tag}]
[npm:]@hugoalh/exfetch[@{Tag}]
For usage of remote resources, it is recommended to import the entire module with the main path mod.ts
, however it is also able to import part of the module with sub path if available, but do not import if:
_foo.ts
, _util/bar.ts
), orfoo.bench.ts
, foo.test.ts
), or_bar
, _foo
).These elements are not considered part of the public API, thus no stability is guaranteed for them.
For usage of JSR or NPM resources, it is recommended to import the entire module with the main entrypoint, however it is also able to import part of the module with sub entrypoint if available, please visit the file jsr.jsonc
property exports
for available sub entrypoints.
It is recommended to use this module with tag for immutability.
net
]
class ExFetch { constructor(options?: ExFetchOptions); single(input: string | URL, init?: RequestInit): Promise<Response>; urlPaginate(input: string | URL, init?: RequestInit): Promise<Response[]>; }
function exFetch(input: string | URL, init?: RequestInit, options?: ExFetchOptions): Promise<Response>;
function exFetchURLPaginate(input: string | URL, init?: RequestInit, options?: ExFetchOptions): Promise<Response[]>;
const responses: Response[] = await exFetchURLPaginate("https://api.github.com/repos/microsoft/vscode/labels?per_page=100"); responses.map((response: Response) => { return response.ok; }).includes(false); //=> false (`false` when no broken page, otherwise `true`) const result = []; for (const response of responses) { result.push(...(await response.json())); } result; /*=> [ { "id": 2339554941, "node_id": "MDU6TGFiZWwyMzM5NTU0OTQx", "url": "https://api.github.com/repos/microsoft/vscode/labels/:apple:%20si", "name": ":apple: si", "color": "e99695", "default": false, "description": "Issues related to apple silicon" }, { "id": 421131022, "node_id": "MDU6TGFiZWw0MjExMzEwMjI=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*as-designed", "name": "*as-designed", "color": "E2A1C2", "default": false, "description": "Described behavior is as designed" }, { "id": 409283388, "node_id": "MDU6TGFiZWw0MDkyODMzODg=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*caused-by-extension", "name": "*caused-by-extension", "color": "E2A1C2", "default": false, "description": "Issue identified to be caused by an extension" }, { "id": 766755777, "node_id": "MDU6TGFiZWw3NjY3NTU3Nzc=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*dev-question", "name": "*dev-question", "color": "E2A1C2", "default": false, "description": "VS Code Extension Development Question" }, { "id": 366106217, "node_id": "MDU6TGFiZWwzNjYxMDYyMTc=", "url": "https://api.github.com/repos/microsoft/vscode/labels/*duplicate", "name": "*duplicate", "color": "E2A1C2", "default": false, "description": "Issue identified as a duplicate of another issue(s)" }, ... +467 ] */
Add Package
deno add jsr:@hugoalh/exfetch
Import symbol
import * as exfetch from "@hugoalh/exfetch";
Import directly with a jsr specifier
import * as exfetch from "jsr:@hugoalh/exfetch";
Add Package
pnpm i jsr:@hugoalh/exfetch
pnpm dlx jsr add @hugoalh/exfetch
Import symbol
import * as exfetch from "@hugoalh/exfetch";
Add Package
yarn add jsr:@hugoalh/exfetch
yarn dlx jsr add @hugoalh/exfetch
Import symbol
import * as exfetch from "@hugoalh/exfetch";
Add Package
npx jsr add @hugoalh/exfetch
Import symbol
import * as exfetch from "@hugoalh/exfetch";
Add Package
bunx jsr add @hugoalh/exfetch
Import symbol
import * as exfetch from "@hugoalh/exfetch";