A protocol handler wrapper for the Fetch API that routes requests based on URL protocol (e.g., file, http, https) to custom fetch implementations. Version 2.0.0 is current; the library is stable with no active development. Unlike a monolithic fetch polyfill, proto-fetch delegates protocol handling to separate fetch modules (like file-fetch or nodeify-fetch), enabling modular and extensible fetching in Node.js and custom runtimes. It does not ship its own fetch implementations and requires an explicit protocol-to-implementation map at construction time.
npm install proto-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a proto-fetch instance with protocol handlers for file and http/https using separate fetch modules, then fetching a local file.
Include [null]: handler in the configuration object for protocol-relative URLs like //example.com/path.
Ensure each handler is a function that accepts a Request/URL and returns a Promise<Response>.
Use string keys for protocols (e.g., 'http', 'https', 'file') and null for protocol-relative URLs.
Call protoFetch with a protocol-to-handler map to get the fetch function: const fetch = protoFetch({file: fileFetch}).Add a handler for 'ftp' in the map: const fetch = protoFetch({ftp: ftpFetch, ...}).No dependency data recorded yet.