Comparing version 1.1.3 to 1.2.0
@@ -13,5 +13,5 @@ import type { Input, InternalOptions, Options } from '../types/options.js'; | ||
protected _decorateResponse(response: Response): Response; | ||
protected _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void>; | ||
protected _retry<T extends (...arguments_: any) => Promise<any>>(function_: T): Promise<ReturnType<T> | void>; | ||
protected _fetch(): Promise<Response>; | ||
protected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']): Response; | ||
} |
@@ -12,3 +12,3 @@ import { HTTPError } from '../errors/HTTPError.js'; | ||
const ky = new Ky(input, options); | ||
const fn = async () => { | ||
const function_ = async () => { | ||
if (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) { | ||
@@ -50,3 +50,3 @@ throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`); | ||
const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase()); | ||
const result = (isRetriableMethod ? ky._retry(fn) : fn()); | ||
const result = (isRetriableMethod ? ky._retry(function_) : function_()); | ||
for (const [type, mimeType] of Object.entries(responseTypes)) { | ||
@@ -179,3 +179,3 @@ result[type] = async () => { | ||
this._retryCount++; | ||
if (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) { | ||
if (this._retryCount <= this._options.retry.limit && !(error instanceof TimeoutError)) { | ||
if (error instanceof HTTPError) { | ||
@@ -214,5 +214,5 @@ if (!this._options.retry.statusCodes.includes(error.response.status)) { | ||
} | ||
async _retry(fn) { | ||
async _retry(function_) { | ||
try { | ||
return await fn(); | ||
return await function_(); | ||
} | ||
@@ -236,3 +236,3 @@ catch (error) { | ||
} | ||
return this._retry(fn); | ||
return this._retry(function_); | ||
} | ||
@@ -239,0 +239,0 @@ throw error; |
@@ -6,3 +6,3 @@ /*! MIT License © Sindre Sorhus */ | ||
export type { KyInstance } from './types/ky.js'; | ||
export type { Options, NormalizedOptions, RetryOptions, SearchParamsOption, DownloadProgress, } from './types/options.js'; | ||
export type { Input, Options, NormalizedOptions, RetryOptions, SearchParamsOption, DownloadProgress, } from './types/options.js'; | ||
export type { Hooks, BeforeRequestHook, BeforeRetryHook, BeforeRetryState, BeforeErrorHook, AfterResponseHook, } from './types/hooks.js'; | ||
@@ -9,0 +9,0 @@ export type { ResponsePromise } from './types/ResponsePromise.js'; |
@@ -16,3 +16,3 @@ import type { LiteralUnion, Required } from './common.js'; | ||
}; | ||
export type KyHeadersInit = HeadersInit | Record<string, string | undefined>; | ||
export type KyHeadersInit = NonNullable<RequestInit['headers']> | Record<string, string | undefined>; | ||
/** | ||
@@ -161,3 +161,3 @@ Custom Ky options | ||
*/ | ||
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>; | ||
fetch?: (input: Input, init?: RequestInit) => Promise<Response>; | ||
}; | ||
@@ -229,4 +229,4 @@ /** | ||
export interface NormalizedOptions extends RequestInit { | ||
method: RequestInit['method']; | ||
credentials: RequestInit['credentials']; | ||
method: NonNullable<RequestInit['method']>; | ||
credentials: NonNullable<RequestInit['credentials']>; | ||
retry: RetryOptions; | ||
@@ -233,0 +233,0 @@ prefixUrl: string; |
{ | ||
"name": "ky", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Tiny and elegant HTTP client based on the browser Fetch API", | ||
@@ -20,2 +20,3 @@ "license": "MIT", | ||
"types": "./distribution/index.d.ts", | ||
"sideEffects": false, | ||
"engines": { | ||
@@ -71,9 +72,8 @@ "node": ">=18" | ||
"pify": "^6.1.0", | ||
"playwright": "^1.39.0", | ||
"playwright": "^1.40.1", | ||
"raw-body": "^2.5.2", | ||
"ts-node": "^10.9.1", | ||
"tsx": "^4.7.0", | ||
"typescript": "^5.2.2", | ||
"xo": "^0.56.0" | ||
}, | ||
"sideEffects": false, | ||
"xo": { | ||
@@ -98,4 +98,5 @@ "envs": [ | ||
"nodeArguments": [ | ||
"--loader=ts-node/esm" | ||
] | ||
"--import=tsx/esm" | ||
], | ||
"workerThreads": false | ||
}, | ||
@@ -102,0 +103,0 @@ "nyc": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
143748