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

fetch-any

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-any

README.md

  • 1.0.2
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

fetch-any

Extendible fetch, you can write native fetch unsupported scheme, such as file|data|memory....

install

> npm install fetch-any

fetch-any API

support(fetcher) any fetcher implementation should call this function to register itself.

fetcher API

support([url,[option]]) global fetch calls this function to choose a correct fetcher. if no arguments, it should test for environment, such as node, or browser

example

//file.js to support file:///c:/temp/a.txt
var isNode=require("is-node")

module.exports=function(url,options){
	let path=url.trim().substr("file://".length)
	return new Response(require("fs").createReadStream(path),options)
}

module.exports.support=function(url){
	if(arguments.length==0){
		return isNode
	}else if(/^file:\/\//i.test(url.trim())){
		return true
	}else{
		return false
	}
}

fetch.support(module.exports)

Keywords

FAQs

Package last updated on 05 May 2018

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