Skip to content

Commit fa20934

Browse files
committed
chore: merge with use-native-fetch-if-available
2 parents 5ee5285 + 8bbfc10 commit fa20934

File tree

7 files changed

+10
-31
lines changed

7 files changed

+10
-31
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
],
1414
"browser": {
1515
"./src/http/fetch.js": "./src/http/fetch.browser.js",
16-
"./src/abort-controller.js": "./src/abort-controller.browser.js",
1716
"./src/text-encoder.js": "./src/text-encoder.browser.js",
1817
"./src/text-decoder.js": "./src/text-decoder.browser.js",
1918
"./src/temp-dir.js": "./src/temp-dir.browser.js",
@@ -36,7 +35,7 @@
3635
"license": "MIT",
3736
"dependencies": {
3837
"abort-controller": "^3.0.0",
39-
"any-signal": "^1.2.0",
38+
"any-signal": "^2.1.0",
4039
"buffer": "^5.6.0",
4140
"err-code": "^2.0.0",
4241
"fs-extra": "^9.0.1",
@@ -45,7 +44,8 @@
4544
"it-glob": "0.0.8",
4645
"merge-options": "^2.0.0",
4746
"nanoid": "^3.1.3",
48-
"node-fetch": "^2.6.0",
47+
"native-abort-controller": "0.0.3",
48+
"native-fetch": "^2.0.0",
4949
"stream-to-it": "^0.2.0",
5050
"it-to-stream": "^0.1.2"
5151
},

src/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { TimeoutError, HTTPError } = require('./http/error')
66
const merge = require('merge-options').bind({ ignoreUndefined: true })
77
const { URL, URLSearchParams } = require('iso-url')
88
const TextDecoder = require('./text-decoder')
9-
const AbortController = require('./abort-controller')
9+
const AbortController = require('native-abort-controller')
1010
const anySignal = require('any-signal')
1111

1212
const timeout = (promise, ms, abortController) => {

src/http/fetch.browser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
/* eslint-env browser */
33

44
const { TimeoutError, AbortError } = require('./error')
5-
const { Request, Response, Headers, fetch } = require('./fetch.polyfill')
5+
const fetch = require('native-fetch')
6+
const { Request, Response, Headers } = fetch
67

78
/**
89
* @typedef {RequestInit & ExtraFetchOptions} FetchOptions

src/http/fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Electron has `XMLHttpRequest` and should get the browser implementation
44
// instead of node.
5-
if (typeof XMLHttpRequest !== 'undefined') {
5+
if (typeof XMLHttpRequest === 'function') {
66
module.exports = require('./fetch.browser')
77
} else {
88
module.exports = require('./fetch.node')

src/http/fetch.node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/** @type {import('node-fetch') & typeof fetch} */
55
// @ts-ignore
6-
const nodeFetch = require('node-fetch')
6+
const nodeFetch = require('native-fetch')
77
const toStream = require('it-to-stream')
88
const { Buffer } = require('buffer')
99
const { Request, Response, Headers } = nodeFetch
@@ -72,7 +72,7 @@ const bodyWithUploadProgress = (init, onUploadProgress) => {
7272
}
7373

7474
/**
75-
* Takes body from node-fetch response as body and `onUploadProgress` handler
75+
* Takes body from native-fetch response as body and `onUploadProgress` handler
7676
* and returns async iterable that emits body chunks and emits
7777
* `onUploadProgress`.
7878
* @param {Buffer|null|Readable} body

src/http/fetch.polyfill.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

test/http.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { expect } = require('aegir/utils/chai')
55
const HTTP = require('../src/http')
66
const toStream = require('it-to-stream')
77
const delay = require('delay')
8-
const AbortController = require('../src/abort-controller')
8+
const AbortController = require('native-abort-controller')
99
const drain = require('it-drain')
1010
const all = require('it-all')
1111
const { isBrowser, isWebWorker } = require('../src/env')

0 commit comments

Comments
 (0)