@esm2cjs/got
Advanced tools
Comparing version 12.5.2 to 12.5.3
@@ -68,3 +68,2 @@ "use strict"; | ||
constructor(url, options, defaults) { | ||
var _a, _b; | ||
super({ | ||
@@ -194,2 +193,8 @@ autoDestroy: false, | ||
}); | ||
Object.defineProperty(this, "_removeListeners", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "_nativeResponse", { | ||
@@ -227,2 +232,3 @@ enumerable: true, | ||
this._cancelTimeouts = noop; | ||
this._removeListeners = noop; | ||
this._jobs = []; | ||
@@ -266,8 +272,2 @@ this._flushed = false; | ||
} | ||
if ((_a = this.options.signal) == null ? void 0 : _a.aborted) { | ||
this.destroy(new import_errors.AbortError(this)); | ||
} | ||
(_b = this.options.signal) == null ? void 0 : _b.addEventListener("abort", () => { | ||
this.destroy(new import_errors.AbortError(this)); | ||
}); | ||
const { body } = this.options; | ||
@@ -287,2 +287,15 @@ if (import_is.default.nodeStream(body)) { | ||
} | ||
if (this.options.signal) { | ||
const abort = () => { | ||
this.destroy(new import_errors.AbortError(this)); | ||
}; | ||
if (this.options.signal.aborted) { | ||
abort(); | ||
} else { | ||
this.options.signal.addEventListener("abort", abort); | ||
this._removeListeners = () => { | ||
this.options.signal.removeEventListener("abort", abort); | ||
}; | ||
} | ||
} | ||
} | ||
@@ -463,2 +476,3 @@ async flush() { | ||
this._cancelTimeouts(); | ||
this._removeListeners(); | ||
if (this.options) { | ||
@@ -465,0 +479,0 @@ const { body } = this.options; |
@@ -112,2 +112,3 @@ /// <reference types="node" resolution-mode="require"/> | ||
private _cancelTimeouts; | ||
private readonly _removeListeners; | ||
private _nativeResponse?; | ||
@@ -114,0 +115,0 @@ private _flushed; |
@@ -166,2 +166,8 @@ import process from 'node:process'; | ||
}); | ||
Object.defineProperty(this, "_removeListeners", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "_nativeResponse", { | ||
@@ -200,2 +206,3 @@ enumerable: true, | ||
this._cancelTimeouts = noop; | ||
this._removeListeners = noop; | ||
this._jobs = []; | ||
@@ -239,8 +246,2 @@ this._flushed = false; | ||
} | ||
if (this.options.signal?.aborted) { | ||
this.destroy(new AbortError(this)); | ||
} | ||
this.options.signal?.addEventListener('abort', () => { | ||
this.destroy(new AbortError(this)); | ||
}); | ||
// Important! If you replace `body` in a handler with another stream, make sure it's readable first. | ||
@@ -262,2 +263,16 @@ // The below is run only once. | ||
} | ||
if (this.options.signal) { | ||
const abort = () => { | ||
this.destroy(new AbortError(this)); | ||
}; | ||
if (this.options.signal.aborted) { | ||
abort(); | ||
} | ||
else { | ||
this.options.signal.addEventListener('abort', abort); | ||
this._removeListeners = () => { | ||
this.options.signal.removeEventListener('abort', abort); | ||
}; | ||
} | ||
} | ||
} | ||
@@ -459,2 +474,3 @@ async flush() { | ||
this._cancelTimeouts(); | ||
this._removeListeners(); | ||
if (this.options) { | ||
@@ -461,0 +477,0 @@ const { body } = this.options; |
{ | ||
"name": "@esm2cjs/got", | ||
"version": "12.5.2", | ||
"version": "12.5.3", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js. This is a fork of sindresorhus/got, but with CommonJS support.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
558745
9123