fetch-switcher
An utility dispatching to multiple implementations of fetch() depending on the URL scheme.
Installation
npm install fetch-switcher
Usage
import { fetchSwitcher } from 'fetch-switcher'
const { fetchSwitcher } = require('fetch-switcher')
const fetchGeneric = ...
const fetchFile = ...
const fetchFtp = ...
const fetch = fetchSwitcher({
'': fetchGeneric,
'file': fetchFile,
'ftp': fetchFtp
})
fetch('http://example.com')
fetch('https://example.com')
fetch('file:///example.txt')
fetch('ftp://exampleftp.com')
Compatibility
fetch-switcher
has no dependencies and is simple enough that it should work on all browsers and Node versions. (Which may of course
not the case of the fetch()
implementations you choose to use.)
Changelog
The changelog.
Contribution Guide
The contribution guide
License
The license.