Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-switcher

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-switcher

An utility dispatching to multiple implementations of fetch() depending on the URL scheme

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

fetch-switcher

GitHub Repo stars Node.js CI npm Coverage Status

An utility dispatching to multiple implementations of fetch() depending on the URL scheme.

Installation

npm install fetch-switcher

Usage

import { fetchSwitcher } from 'fetch-switcher'
// or
const { fetchSwitcher } = require('fetch-switcher')

// assuming you have multiple fetch() implementations
const fetchGeneric = ...
const fetchFile = ...
const fetchFtp = ...

const fetch = fetchSwitcher({
  '': fetchGeneric, // '' is the default
  'file': fetchFile,
  'ftp': fetchFtp
})

fetch('http://example.com') // will dispatch to fetchGeneric
fetch('https://example.com') // will also dispatch to fetchGeneric
fetch('file:///example.txt') // will dispatch to fetchFile
fetch('ftp://exampleftp.com') // will dispacth to fetchFtp

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.

Keywords

FAQs

Package last updated on 24 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc