Comparing version 14.2.1 to 14.3.0
@@ -6,3 +6,3 @@ import { EventEmitter } from 'node:events'; | ||
import Request from '../core/index.js'; | ||
import { parseBody, isResponseOk, ParseError } from '../core/response.js'; | ||
import { parseBody, isResponseOk, ParseError, } from '../core/response.js'; | ||
import proxyEvents from '../core/utils/proxy-events.js'; | ||
@@ -134,8 +134,8 @@ import { CancelError } from './types.js'; | ||
}); | ||
promise.on = (event, fn) => { | ||
emitter.on(event, fn); | ||
promise.on = (event, function_) => { | ||
emitter.on(event, function_); | ||
return promise; | ||
}; | ||
promise.off = (event, fn) => { | ||
emitter.off(event, fn); | ||
promise.off = (event, function_) => { | ||
emitter.off(event, function_); | ||
return promise; | ||
@@ -142,0 +142,0 @@ }; |
import type { RetryFunction } from './options.js'; | ||
type Returns<T extends (...args: any) => unknown, V> = (...args: Parameters<T>) => V; | ||
type Returns<T extends (...arguments_: any) => unknown, V> = (...arguments_: Parameters<T>) => V; | ||
declare const calculateRetryDelay: Returns<RetryFunction, number>; | ||
export default calculateRetryDelay; |
@@ -827,5 +827,3 @@ import process from 'node:process'; | ||
} | ||
if (!request) { | ||
request = options.getRequestFunction(); | ||
} | ||
request ||= options.getRequestFunction(); | ||
const url = options.url; | ||
@@ -840,7 +838,7 @@ this._requestOptions = options.createNativeRequestOptions(); | ||
// Cache support | ||
const fn = options.cache ? this._createCacheableRequest : request; | ||
const function_ = options.cache ? this._createCacheableRequest : request; | ||
try { | ||
// We can't do `await fn(...)`, | ||
// because stream `error` event can be emitted before `Promise.resolve()`. | ||
let requestOrResponse = fn(url, this._requestOptions); | ||
let requestOrResponse = function_(url, this._requestOptions); | ||
if (is.promise(requestOrResponse)) { | ||
@@ -847,0 +845,0 @@ requestOrResponse = await requestOrResponse; |
@@ -41,4 +41,4 @@ /// <reference types="node" resolution-mode="require"/> | ||
export type ToughCookieJar = { | ||
getCookieString: ((currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookies: string) => void) => void) & ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => void); | ||
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, cb: (error: Error | null, cookie: unknown) => void) => void) & ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void); | ||
getCookieString: ((currentUrl: string, options: Record<string, unknown>, callback: (error: Error | null, cookies: string) => void) => void) & ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => void); | ||
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, callback: (error: Error | null, cookie: unknown) => void) => void) & ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void); | ||
}; | ||
@@ -45,0 +45,0 @@ export type PromiseCookieJar = { |
@@ -177,3 +177,3 @@ import process from 'node:process'; | ||
backoff: 0, | ||
requestLimit: 10000, | ||
requestLimit: 10_000, | ||
stackAllItems: false, | ||
@@ -180,0 +180,0 @@ }, |
export default function proxyEvents(from, to, events) { | ||
const eventFunctions = {}; | ||
for (const event of events) { | ||
const eventFunction = (...args) => { | ||
to.emit(event, ...args); | ||
const eventFunction = (...arguments_) => { | ||
to.emit(event, ...arguments_); | ||
}; | ||
@@ -7,0 +7,0 @@ eventFunctions[event] = eventFunction; |
@@ -5,5 +5,5 @@ /// <reference types="node" resolution-mode="require"/> | ||
type Event = string | symbol; | ||
type Fn = (...args: any[]) => void; | ||
type AnyFunction = (...arguments_: any[]) => void; | ||
type Unhandler = { | ||
once: (origin: Origin, event: Event, fn: Fn) => void; | ||
once: (origin: Origin, event: Event, function_: AnyFunction) => void; | ||
unhandleAll: () => void; | ||
@@ -10,0 +10,0 @@ }; |
@@ -8,5 +8,5 @@ // When attaching listeners, it's very easy to forget about them. | ||
return { | ||
once(origin, event, fn) { | ||
origin.once(event, fn); | ||
handlers.push({ origin, event, fn }); | ||
once(origin, event, function_) { | ||
origin.once(event, function_); | ||
handlers.push({ origin, event, fn: function_ }); | ||
}, | ||
@@ -13,0 +13,0 @@ unhandleAll() { |
@@ -41,5 +41,3 @@ import is, { assert } from '@sindresorhus/is'; | ||
} | ||
if (!promise) { | ||
promise = asPromise(request); | ||
} | ||
promise ||= asPromise(request); | ||
return promise; | ||
@@ -52,5 +50,3 @@ }; | ||
if (is.promise(result) && !request.options.isStream) { | ||
if (!promise) { | ||
promise = asPromise(request); | ||
} | ||
promise ||= asPromise(request); | ||
if (result !== promise) { | ||
@@ -57,0 +53,0 @@ const descriptors = Object.getOwnPropertyDescriptors(promise); |
{ | ||
"name": "got", | ||
"version": "14.2.1", | ||
"version": "14.3.0", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -51,6 +51,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@sindresorhus/is": "^6.1.0", | ||
"@sindresorhus/is": "^6.3.1", | ||
"@szmarczak/http-timer": "^5.0.1", | ||
"cacheable-lookup": "^7.0.0", | ||
"cacheable-request": "^10.2.14", | ||
"cacheable-request": "^12.0.1", | ||
"decompress-response": "^6.0.0", | ||
@@ -70,5 +70,5 @@ "form-data-encoder": "^4.0.2", | ||
"@types/express": "^4.17.21", | ||
"@types/node": "^20.10.0", | ||
"@types/node": "^20.12.12", | ||
"@types/pem": "^1.14.4", | ||
"@types/readable-stream": "^4.0.9", | ||
"@types/readable-stream": "^4.0.14", | ||
"@types/request": "^2.48.12", | ||
@@ -78,3 +78,3 @@ "@types/sinon": "^17.0.2", | ||
"ava": "^5.3.1", | ||
"axios": "^1.6.2", | ||
"axios": "^1.6.8", | ||
"benchmark": "^2.1.4", | ||
@@ -87,10 +87,10 @@ "bluebird": "^3.7.2", | ||
"delay": "^6.0.0", | ||
"express": "^4.18.2", | ||
"express": "^4.19.2", | ||
"form-data": "^4.0.0", | ||
"formdata-node": "^6.0.3", | ||
"nock": "^13.4.0", | ||
"nock": "^13.5.4", | ||
"node-fetch": "^3.3.2", | ||
"np": "^9.0.0", | ||
"np": "^10.0.5", | ||
"nyc": "^15.1.0", | ||
"p-event": "^6.0.0", | ||
"p-event": "^6.0.1", | ||
"pem": "^1.14.8", | ||
@@ -100,10 +100,10 @@ "pify": "^6.1.0", | ||
"request": "^2.88.2", | ||
"sinon": "^17.0.1", | ||
"sinon": "^18.0.0", | ||
"slow-stream": "0.0.4", | ||
"tempy": "^3.1.0", | ||
"then-busboy": "^5.2.1", | ||
"tough-cookie": "^4.1.3", | ||
"tsx": "^4.6.0", | ||
"tough-cookie": "^4.1.4", | ||
"tsx": "^4.10.4", | ||
"type-fest": "^4.8.2", | ||
"typescript": "^5.3.2", | ||
"typescript": "^5.4.5", | ||
"xo": "^0.56.0" | ||
@@ -115,3 +115,3 @@ }, | ||
], | ||
"timeout": "1m", | ||
"timeout": "10m", | ||
"extensions": { | ||
@@ -118,0 +118,0 @@ "ts": "module" |
@@ -15,7 +15,9 @@ <div align="center"> | ||
<br> | ||
<br> | ||
<a href="https://retool.com/?utm_campaign=sindresorhus"> | ||
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="210"> | ||
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="220"> | ||
</a> | ||
<br> | ||
<br> | ||
<br> | ||
<a href="https://strapi.io/?ref=sindresorhus"> | ||
@@ -49,15 +51,8 @@ <div> | ||
<br> | ||
<a href="https://dutchis.net/?ref=sindresorhus#gh-light-mode-only"> | ||
<div> | ||
<img src="https://sindresorhus.com/assets/thanks/dutchis-logo-light.png" width="200" alt="DutchIS"> | ||
</div> | ||
<br> | ||
<b>VPS hosting with taste π</b> | ||
<br> | ||
<a href="https://www.fame.fi#gh-light-mode-only"> | ||
<img src="https://sindresorhus.com/assets/thanks/fame-logo-light.svg" width="200" alt="Fame Helsinki"> | ||
</a> | ||
<a href="https://dutchis.net/?ref=sindresorhus#gh-dark-mode-only"> | ||
<div> | ||
<img src="https://sindresorhus.com/assets/thanks/dutchis-logo-dark.png" width="200" alt="DutchIS"> | ||
</div> | ||
<br> | ||
<b>VPS hosting with taste π</b> | ||
<a href="https://www.fame.fi#gh-dark-mode-only"> | ||
<img src="https://sindresorhus.com/assets/thanks/fame-logo-dark.svg" width="200" alt="Fame Helsinki"> | ||
</a> | ||
@@ -69,3 +64,2 @@ <br> | ||
<br> | ||
<br> | ||
</p> | ||
@@ -72,0 +66,0 @@ <br> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
241518
5296
503
+ Added@sec-ant/readable-stream@0.4.1(transitive)
+ Addedcacheable-request@12.0.1(transitive)
+ Addedget-stream@9.0.1(transitive)
+ Addedis-stream@4.0.1(transitive)
- Removedcacheable-request@10.2.14(transitive)
- Removedget-stream@6.0.1(transitive)
Updated@sindresorhus/is@^6.3.1
Updatedcacheable-request@^12.0.1