Meta tweaks
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by Sindre Sorhus · parent 8764419 · Browse files · 8 files·+34 added−18 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+34 added−18 removed
- tests:+11 added−3 removed
- other:+23 added−15 removed
Provenance
- Commit
db4247b- Tree
53f5a9e- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
8764419
8 files changed+34 added−18 removed
modified:source/core/Ky.ts+7 added-1 removed
1 import {HTTPError} from '../errors/HTTPError.js';2 import {TimeoutError} from '../errors/TimeoutError.js';3 import type {Hooks} from '../types/hooks.js';4-import type {Input, InternalOptions, NormalizedOptions, Options, SearchParamsInit} from '../types/options.js';4+import type {5+ Input,6+ InternalOptions,7+ NormalizedOptions,8+ Options,9+ SearchParamsInit,10+} from '../types/options.js';11 import {type ResponsePromise} from '../types/ResponsePromise.js';12 import {deepMerge, mergeHeaders} from '../utils/merge.js';13 import {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';14 import timeout, {type TimeoutOptions} from '../utils/timeout.js';357 unmodified linesmodified:source/types/ky.ts+1 added-1 removed
82 unmodified lines8384858687878889909146 unmodified lines82 unmodified lines
You can also refer to parent defaults by providing a function to `.extend()`.
@example ```js ``` import ky from 'ky';
const api = ky.create({prefixUrl: 'https://example.com/api'});
46 unmodified linesmodified:source/utils/delay.ts+1 added-1 removed
16 unmodified lines171819202121222324254 unmodified lines16 unmodified lines }
function abortHandler() { clearTimeout(timeoutId); reject(signal!.reason); reject(signal!.reason as Error); }
const timeoutId = setTimeout(() => { signal?.removeEventListener('abort', abortHandler);4 unmodified linesmodified:test/helpers/with-page.ts+7 added-1 removed
12334567891011121319 unmodified linesimport process from 'node:process';import test, {type ExecutionContext} from 'ava';import {chromium, firefox, webkit, type BrowserType, type Page} from 'playwright';import { chromium, firefox, webkit, type BrowserType, type Page,} from 'playwright';
type Run = (t: ExecutionContext, page: Page) => Promise<void>;
const PWDEBUG = Boolean(process.env['PWDEBUG']);19 unmodified linesmodified:test/browser.ts+2 added-2 removed
1 import test, {type ExecutionContext} from 'ava';2 import busboy from 'busboy';3 import express from 'express';4 import {chromium, webkit, type Page} from 'playwright';5-import type ky from '../source/index.js';6-import type {DownloadProgress} from '../source/index.js';5+import type ky from '../source/index.js'; // eslint-disable-line import/no-duplicates6+import type {DownloadProgress} from '../source/index.js'; // eslint-disable-line import/no-duplicates7 import {createHttpTestServer, type ExtendedHttpTestServer, type HttpServerOptions} from './helpers/create-http-test-server.js';8 import {parseRawBody} from './helpers/parse-body.js';9 import {browserTest, defaultBrowsersTest} from './helpers/with-page.js';10 477 unmodified linesmodified:test/main.ts+2 added
703 unmodified lines704 body: requestBody,705 });706 707 server.post('/', (request, response) => {708+ // eslint-disable-next-line @typescript-eslint/ban-types709 const body: Buffer[] = [];710 711+ // eslint-disable-next-line @typescript-eslint/ban-types712 request.on('data', (chunk: Buffer) => {713 body.push(chunk);714 });715 99 unmodified linesmodified:package.json+10 added-9 removed
1 {2 "name": "ky",3 "version": "1.4.0",4- "description": "Tiny and elegant HTTP client based on the browser Fetch API",4+ "description": "Tiny and elegant HTTP client based on the Fetch API",5 "license": "MIT",6 "repository": "sindresorhus/ky",7 "funding": "https://github.com/sindresorhus/ky?sponsor=1",8 "author": {44 unmodified lines53 "axios",54 "node-fetch"55 ],56 "devDependencies": {57- "@sindresorhus/tsconfig": "^4.0.0",57+ "@sindresorhus/tsconfig": "^6.0.0",58 "@type-challenges/utils": "^0.1.1",59 "@types/body-parser": "^1.19.2",60 "@types/busboy": "^1.5.0",61 "@types/express": "^4.17.17",62- "@types/node": "^20.5.7",62+ "@types/node": "^20.14.12",63 "ava": "^5.3.1",64 "body-parser": "^1.20.2",65 "busboy": "^1.6.0",66 "del-cli": "^5.1.0",67 "delay": "^6.0.0",68- "expect-type": "^0.16.0",68+ "expect-type": "^0.19.0",69 "express": "^4.18.2",70 "pify": "^6.1.0",71- "playwright": "^1.40.1",71+ "playwright": "^1.45.3",72 "raw-body": "^2.5.2",73- "tsx": "^4.7.0",74- "typescript": "^5.2.2",75- "xo": "^0.56.0"73+ "tsx": "^4.16.2",74+ "typescript": "^5.5.4",75+ "xo": "^0.58.0"76 },77 "xo": {78 "envs": [79 "browser"4 unmodified lines84 "@typescript-eslint/no-unsafe-argument": "off",85 "@typescript-eslint/no-unsafe-assignment": "off",86 "@typescript-eslint/no-unsafe-return": "off",87 "@typescript-eslint/no-unsafe-call": "off",88- "@typescript-eslint/naming-convention": "off"88+ "@typescript-eslint/naming-convention": "off",89+ "n/no-unsupported-features/node-builtins": "off"90 }91 },92 "ava": {93 "extensions": {21 unmodified linesmodified:readme.md+4 added-3 removed
49 unmodified lines50 <br>51 <br>52 </div>53 54-> Ky is a tiny and elegant HTTP client based on the browser [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch)54+> Ky is a tiny and elegant HTTP client based on the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch)55 56 [](https://codecov.io/gh/sindresorhus/ky)57 [](https://bundlephobia.com/result?p=ky)58 59-Ky targets [modern browsers](#browser-support), Node.js, and Deno.59+Ky targets [modern browsers](#browser-support), Node.js, Bun, and Deno.60 61 It's just a tiny package with no dependencies.62 63 ## Benefits over plain `fetch`640 unmodified lines704 705 const json = await ky('https://jsonplaceholder.typicode.com/todos/1').json();706 707 console.log(json.title);708-//=> 'delectus aut autem708+//=> 'delectus aut autem'709 </script>710 ```711 712 #### How is it different from [`got`](https://github.com/sindresorhus/got)23 unmodified lines736 Node.js 18 and later.737 738 ## Related739 740+- [fetch-extras](https://github.com/sindresorhus/fetch-extras) - Useful utilities for working with Fetch741 - [got](https://github.com/sindresorhus/got) - Simplified HTTP requests for Node.js742 - [ky-hooks-change-case](https://github.com/alice-health/ky-hooks-change-case) - Ky hooks to modify cases on requests and responses of objects743 744 ## Maintainers4 unmodified lines