Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress events without breaking pub-sub #60

Merged
merged 13 commits into from
Nov 13, 2020
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
],
"browser": {
"./src/http/fetch.js": "./src/http/fetch.browser.js",
"./src/abort-controller.js": "./src/abort-controller.browser.js",
"./src/text-encoder.js": "./src/text-encoder.browser.js",
"./src/text-decoder.js": "./src/text-decoder.browser.js",
"./src/temp-dir.js": "./src/temp-dir.browser.js",
Expand All @@ -36,7 +35,7 @@
"license": "MIT",
"dependencies": {
"abort-controller": "^3.0.0",
"any-signal": "^1.2.0",
"any-signal": "^2.1.0",
"buffer": "^5.6.0",
"err-code": "^2.0.0",
"fs-extra": "^9.0.1",
Expand All @@ -45,7 +44,8 @@
"it-glob": "0.0.8",
"merge-options": "^2.0.0",
"nanoid": "^3.1.3",
"node-fetch": "^2.6.0",
"native-abort-controller": "0.0.3",
"native-fetch": "^2.0.0",
"stream-to-it": "^0.2.0",
"it-to-stream": "^0.1.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { TimeoutError, HTTPError } = require('./http/error')
const merge = require('merge-options').bind({ ignoreUndefined: true })
const { URL, URLSearchParams } = require('iso-url')
const TextDecoder = require('./text-decoder')
const AbortController = require('./abort-controller')
const AbortController = require('native-abort-controller')
const anySignal = require('any-signal')

const timeout = (promise, ms, abortController) => {
Expand Down
3 changes: 2 additions & 1 deletion src/http/fetch.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/* eslint-env browser */

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

/**
* @typedef {RequestInit & ExtraFetchOptions} FetchOptions
Expand Down
2 changes: 1 addition & 1 deletion src/http/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Electron has `XMLHttpRequest` and should get the browser implementation
// instead of node.
if (typeof XMLHttpRequest !== 'undefined') {
if (typeof XMLHttpRequest === 'function') {
module.exports = require('./fetch.browser')
} else {
module.exports = require('./fetch.node')
Expand Down
4 changes: 2 additions & 2 deletions src/http/fetch.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/** @type {import('node-fetch') & typeof fetch} */
// @ts-ignore
const nodeFetch = require('node-fetch')
const nodeFetch = require('native-fetch')
const toStream = require('it-to-stream')
const { Buffer } = require('buffer')
const { Request, Response, Headers } = nodeFetch
Expand Down Expand Up @@ -72,7 +72,7 @@ const bodyWithUploadProgress = (init, onUploadProgress) => {
}

/**
* Takes body from node-fetch response as body and `onUploadProgress` handler
* Takes body from native-fetch response as body and `onUploadProgress` handler
* and returns async iterable that emits body chunks and emits
* `onUploadProgress`.
* @param {Buffer|null|Readable} body
Expand Down
22 changes: 0 additions & 22 deletions src/http/fetch.polyfill.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/http.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { expect } = require('aegir/utils/chai')
const HTTP = require('../src/http')
const toStream = require('it-to-stream')
const delay = require('delay')
const AbortController = require('../src/abort-controller')
const AbortController = require('native-abort-controller')
const drain = require('it-drain')
const all = require('it-all')
const { isBrowser, isWebWorker } = require('../src/env')
Expand Down