1 | import fileFetch from 'file-fetch'
|
2 | import httpFetch from 'nodeify-fetch'
|
3 | import protoFetch from '../index.js'
|
4 |
|
5 | const fetch = protoFetch({
|
6 | [null]: fileFetch,
|
7 | file: fileFetch,
|
8 | http: httpFetch,
|
9 | https: httpFetch
|
10 | })
|
11 |
|
12 | async function contentLength (url) {
|
13 | const length = (await (await fetch(url)).text()).length
|
14 |
|
15 | console.log(`content length of ${url}: ${length}`)
|
16 | }
|
17 |
|
18 | await contentLength('package.json')
|
19 | await contentLength('file:package.json')
|
20 | await contentLength(`file://${process.cwd()}/package.json`)
|
21 | await contentLength('https://www.unpkg.com/proto-fetch/package.json')
|