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

proto-fetch

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proto-fetch - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

.github/workflows/test.yaml

18

index.js

@@ -1,16 +0,18 @@

const url = require('url')
async function fetch (url, options) {
let protocol = null
function fetch (iri, options) {
const protocol = url.parse(iri).protocol.split(':').shift()
if (/^[a-z]+:/.test(url)) {
protocol = new URL(url).protocol.slice(0, -1)
}
if (protocol in this.protocols) {
return this.protocols[protocol](iri, options)
return this.protocols[protocol](url, options)
}
return Promise.reject(new Error('unknown protocol'))
throw new Error(`unknown protocol: ${protocol}`)
}
function factory (protocols) {
const instance = (iri, options) => {
return fetch.call(instance, iri, options)
const instance = (url, options) => {
return fetch.call(instance, url, options)
}

@@ -23,2 +25,2 @@

module.exports = factory
export default factory
{
"name": "proto-fetch",
"version": "1.0.0",
"version": "2.0.0",
"description": "Protocol handler wrapper for fetch",
"type": "module",
"main": "index.js",
"scripts": {
"test": "standard && mocha"
"test": "stricter-standard && c8 --reporter=lcov --reporter=text-summary mocha"
},
"repository": {
"type": "git",
"url": "git://github.com/bergos/file-fetch.git"
"url": "https://github.com/bergos/proto-fetch.git"
},
"keywords": [
"fetch",
"file",
"fs",
"readable",
"stream",
"file",
"fs"
"stream"
],

@@ -26,7 +27,9 @@ "author": "Thomas Bergwinkl <bergi@axolotlfarm.org> (https://www.bergnet.org/people/bergi/card#me)",

"homepage": "https://github.com/bergos/proto-fetch",
"dependencies": {},
"devDependencies": {
"mocha": "^4.0.1",
"standard": "^10.0.3"
"c8": "^8.0.1",
"file-fetch": "^2.0.0",
"mocha": "^10.2.0",
"nodeify-fetch": "^3.1.0",
"stricter-standard": "^0.3.0"
}
}
# proto-fetch
[![build status](https://img.shields.io/github/actions/workflow/status/bergos/proto-fetch/test.yaml?branch=master)](https://github.com/bergos/proto-fetch/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/proto-fetch.svg)](https://www.npmjs.com/package/proto-fetch)
A protocol handler wrapper for fetch.

@@ -11,8 +14,9 @@

```
const fileFetch = require('file-fetch')
const httpFetch = require('nodeify-fetch')
const protoFetch = require('proto-fetch')
```javascript
import fileFetch from 'file-fetch'
import httpFetch from 'nodeify-fetch'
import protoFetch from 'proto-fetch'
const fetch = protoFetch({
[null]: fileFetch,
file: fileFetch,

@@ -23,2 +27,3 @@ http: httpFetch,

const res = await fetch(`file://${process.cwd()}/package.json`)
```
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