Require Node.js 14
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 cff4c7a · Browse files · 6 files·+45 added−52 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+45 added−52 removed
- tests:+18 added−18 removed
- other:+27 added−34 removed
Provenance
- Commit
e557973- Tree
775299c- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
cff4c7a
6 files changed+45 added−52 removed
modified:.github/workflows/main.yml+2 added-2 removed
10 unmodified lines1112131415161516171819205 unmodified lines10 unmodified lines matrix: node-version: - 14 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test5 unmodified linesmodified:source/index.ts+4 added-4 removed
25 unmodified lines262728293030313233343536373838394041424344454647484748495025 unmodified linesconst ky = createInstance();
export default ky;
export {export type { Options, NormalizedOptions, RetryOptions, SearchParamsOption, DownloadProgress,} from './types/options.js';
export {export type { Hooks, BeforeRequestHook, BeforeRetryHook, BeforeRetryState, BeforeErrorHook, AfterResponseHook,} from './types/hooks.js';
export {ResponsePromise} from './types/ResponsePromise.js';export {KyResponse} from './types/response.js';export type {ResponsePromise} from './types/ResponsePromise.js';export type {KyResponse} from './types/response.js';export {HTTPError} from './errors/HTTPError.js';export {TimeoutError} from './errors/TimeoutError.js';modified:test/browser.ts+18 added-18 removed
1 import test, {ExecutionContext} from 'ava';2-import Busboy from 'busboy';2+import busboy from 'busboy';3 import express from 'express';4 import {Page} from 'playwright-chromium';5 import ky from '../source/index.js';6 import {createHttpTestServer, HttpServerOptions} from './helpers/create-http-test-server.js';43 unmodified lines50 page.evaluate(async () => window.ky('/foo', {prefixUrl: '/'})),51 {message: /`input` must not begin with a slash when using `prefixUrl`/},52 );53 54- const results = await page.evaluate(async url => Promise.all([54+ const results = await page.evaluate(async (url: string) => Promise.all([55 window.ky(`${url}/api/unicorn`).text(),56 // @ts-expect-error unsupported {prefixUrl: null} type57 window.ky(`${url}/api/unicorn`, {prefixUrl: null}).text(),58 window.ky('api/unicorn', {prefixUrl: url}).text(),20 unmodified lines79 80 await page.goto(server.url);81 await addKyScriptToPage(page);82 83- const error = await page.evaluate(async url => {83+ const error = await page.evaluate(async (url: string) => {84 const controller = new AbortController();85 const request = window.ky(`${url}/test`, {signal: controller.signal}).text();86 controller.abort();87 return request.catch(error_ => error_.toString());19 unmodified lines107 }, 500);108 });109 await page.goto(server.url);110 await addKyScriptToPage(page);111- const data = await page.evaluate(async url => {111+ const data = await page.evaluate(async (url: string) => {112 // eslint-disable-next-line @typescript-eslint/no-empty-function113 const request = window.ky.get(`${url}/test`, {onDownloadProgress() {}}).then(async v => ({114 headers: v.headers.get('X-ky-Header'),115 status: v.status,32 unmodified lines148 149 await page.goto(server.url);150 await addKyScriptToPage(page);151 152- const error = await page.evaluate(async url => {152+ const error = await page.evaluate(async (url: string) => {153 const controller = new AbortController();154 // eslint-disable-next-line @typescript-eslint/no-empty-function155 const request = window.ky(`${url}/test`, {signal: controller.signal, onDownloadProgress() {}}).text();156 setTimeout(() => {26 unmodified lines183 await page.goto(server.url);184 await page.addScriptTag({content: 'window.AbortController = undefined;\n'});185 await addKyScriptToPage(page);186 187- const error = await page.evaluate(async url => {187+ const error = await page.evaluate(async (url: string) => {188 const request = window.ky(`${url}/slow`, {timeout: 500}).text();189 return request.catch(error_ => ({190 message: error_.toString(),191 request: {url: error_.request.url},27 unmodified lines219 220 await page.goto(server.url);221 await addKyScriptToPage(page);222 223- const result = await page.evaluate(async url => {223+ const result = await page.evaluate(async (url: string) => {224 // `new TextDecoder('utf-8').decode` hangs up?225 const decodeUtf8 = (array: Uint8Array) => String.fromCodePoint(...array);226 227 const data: any[] = [];28 unmodified lines256 257 await page.goto(server.url);258 await addKyScriptToPage(page);259 260- const error = await page.evaluate(async url => {260+ const error = await page.evaluate(async (url: string) => {261 // @ts-expect-error262 const request = window.ky(url, {onDownloadProgress: 1}).text();263 return request.catch(error_ => error_.toString());264 }, server.url);12 unmodified lines277 await page.goto(server.url);278 await page.addScriptTag({content: 'window.ReadableStream = undefined;\n'});279 await addKyScriptToPage(page);280 281- const error = await page.evaluate(async url => {281+ const error = await page.evaluate(async (url: string) => {282 // eslint-disable-next-line @typescript-eslint/no-empty-function283 const request = window.ky(url, {onDownloadProgress() {}}).text();284 return request.catch(error_ => error_.toString());285 }, server.url);24 unmodified lines310 311 await page.goto(server.url);312 await addKyScriptToPage(page);313 314- await page.evaluate(async url => {314+ await page.evaluate(async (url: string) => {315 const formData = new window.FormData();316 formData.append('file', new window.File(['bubblegum pie'], 'my-file'));317 return window.ky(url, {318 method: 'post',16 unmodified lines335 336 server.post('/', async (request, response) => {337 const [body, error] = await new Promise(resolve => {338 // @ts-expect-error339- const busboy = new Busboy({headers: request.headers});339+ const busboyInstance = busboy({headers: request.headers});340 341- busboy.on('error', (error: Error) => {341+ busboyInstance.on('error', (error: Error) => {342 resolve([null, error]);343 });344 345 // eslint-disable-next-line max-params346- busboy.on('file', async (fieldname, file, filename, encoding, mimetype) => {346+ busboyInstance.on('file', async (fieldname, file, filename, encoding, mimetype) => {347 let fileContent = '';348 try {349 for await (const chunk of file) {350 fileContent += chunk; // eslint-disable-line @typescript-eslint/restrict-plus-operands4 unmodified lines355 resolve([null, error_]);356 }357 });358 359- busboy.on('finish', () => {359+ busboyInstance.on('finish', () => {360 response.writeHead(303, {Connection: 'close', Location: '/'});361 response.end();362 });363 364 setTimeout(() => {365 resolve([null, new Error('Timeout')]);366 }, 3000);367 368- request.pipe(busboy);368+ request.pipe(busboyInstance);369 });370 371 t.falsy(error);372 t.deepEqual(request.query, {foo: '1'});44 unmodified lines417 418 await page.goto(server.url);419 await addKyScriptToPage(page);420 421- await page.evaluate(async url => {422- const request = new window.Request(url + '/test', {421+ await page.evaluate(async (url: string) => {422+ const request = new window.Request(`${url}/test`, {423 headers: {'content-type': 'text/css'},424 });425 426 return window27 unmodified lines454 await page.goto(server.url);455 await addKyScriptToPage(page);456 457 await t.throwsAsync(458- page.evaluate(async url => window.ky(url + '/test', {458+ page.evaluate(async (url: string) => window.ky(`${url}/test`, {459 body: 'foo',460 method: 'PUT',461 retry: 2,462 }), server.url),7 unmodified linesmodified:.gitignore+2 added-2 removed
1-distribution/1 node_modules/3-package-lock.json2 yarn.lock3+distribution/4+package-lock.jsonmodified:package.json+12 added-12 removed
13 unmodified lines1415161718181920212226 unmodified lines495051525353545555565758585960616261626364656666676869706970717273747273747576777841 unmodified lines13 unmodified lines "main": "./distribution/index.js", "exports": "./distribution/index.js", "types": "./distribution/index.d.ts", "engines": { "node": ">=12" "node": ">=14.16" }, "scripts": { "test": "xo && npm run build && ava", "debug": "PWDEBUG=1 ava --timeout=2m",26 unmodified lines "axios", "node-fetch" ], "devDependencies": { "@sindresorhus/tsconfig": "^2.0.0", "@sindresorhus/tsconfig": "^3.0.1", "@type-challenges/utils": "^0.1.1", "@types/body-parser": "^1.19.1", "@types/body-parser": "^1.19.2", "@types/busboy": "^0.3.1", "@types/express": "^4.17.13", "@types/node-fetch": "^2.5.10", "@types/node-fetch": "^2.6.2", "@types/pify": "^5.0.1", "abort-controller": "^3.0.0", "ava": "4.0.0-alpha.2", "body-parser": "^1.19.0", "ava": "4.3.0", "body-parser": "^1.20.0", "busboy": "^0.3.1", "del-cli": "^4.0.1", "delay": "^5.0.0", "express": "^4.17.1", "express": "^4.18.1", "form-data": "^4.0.0", "node-fetch": "^2.6.1", "pify": "^5.0.0", "playwright-chromium": "^1.19.2", "pify": "^6.0.0", "playwright-chromium": "^1.22.2", "raw-body": "^2.5.1", "ts-node": "^10.6.0", "typescript": "~4.6.2", "xo": "^0.48.0", "ts-node": "^10.8.1", "typescript": "~4.7.4", "xo": "^0.50.0", "expect-type": "^0.13.0" }, "sideEffects": false, "xo": {41 unmodified linesmodified:tsconfig.json+7 added-14 removed
1 {2 "extends": "@sindresorhus/tsconfig",3- "compilerOptions": {4- "target": "ES2019", // Node.js 125- "lib": [6- "ES2019",7- "DOM",8- "DOM.Iterable",9- ],10- "useDefineForClassFields": false,11- "allowSyntheticDefaultImports": true,12- "module": "ES2020"13- },3 "include": [15- "source",16- "test"17- ]4+ "source"5+ ],6+ "ts-node": {7+ "transpileOnly": true,8+ "files": true,9+ "experimentalResolver": true10+ }11 }