Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 16, 2023
1 parent 3cf5064 commit 2f683c3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
node-version:
- 18
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"main": "./distribution/index.js",
"types": "./distribution/index.d.ts",
"sideEffects": false,
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 5 additions & 5 deletions source/core/Ky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Ky {
static create(input: Input, options: Options): ResponsePromise {
const ky = new Ky(input, options);

const fn = async (): Promise<Response> => {
const function_ = async (): Promise<Response> => {
if (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export class Ky {
};

const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());
const result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise;
const result = (isRetriableMethod ? ky._retry(function_) : function_()) as ResponsePromise;

for (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {
result[type] = async () => {
Expand Down Expand Up @@ -250,9 +250,9 @@ export class Ky {
return response;
}

protected async _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void> {
protected async _retry<T extends (...arguments_: any) => Promise<any>>(function_: T): Promise<ReturnType<T> | void> {
try {
return await fn();
return await function_();
} catch (error) {
const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);
if (ms !== 0 && this._retryCount > 0) {
Expand All @@ -273,7 +273,7 @@ export class Ky {
}
}

return this._retry(fn);
return this._retry(function_);
}

throw error;
Expand Down
5 changes: 2 additions & 3 deletions test/helpers/with-page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable ava/no-ignored-test-files */

import process from 'node:process';
import test from 'ava';
import test, {type ExecutionContext} from 'ava';
import {chromium, firefox, webkit, type BrowserType, type Page} from 'playwright';
import type {ExecutionContext} from 'ava';

type Run = (t: ExecutionContext, page: Page) => Promise<void>;

Expand Down
4 changes: 2 additions & 2 deletions test/helpers/with-performance-observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {performance, PerformanceObserver} from 'node:perf_hooks';
import process from 'node:process';
import type {ExecutionContext} from 'ava';

type Arg = {
type Argument = {
name: string;
expectedDuration: number;
t: ExecutionContext;
Expand All @@ -17,7 +17,7 @@ export async function withPerformanceObserver({
expectedDuration,
t,
test,
}: Arg) {
}: Argument) {
// Register observer that asserts on duration when a measurement is performed
const obs = new PerformanceObserver(items => {
const measurements = items.getEntries();
Expand Down

0 comments on commit 2f683c3

Please sign in to comment.