Skip to content
Myr

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

6 files+45 added−52 removed

modified:.github/workflows/main.yml+2 added-2 removed
modified:source/index.ts+4 added-4 removed
modified:test/browser.ts+18 added-18 removed
1import test, {ExecutionContext} from 'ava';2import Busboy from 'busboy';2import busboy from 'busboy';3import express from 'express';4import {Page} from 'playwright-chromium';5import ky from '../source/index.js';6import {createHttpTestServer, HttpServerOptions} from './helpers/create-http-test-server.js';
43 unmodified lines
50 page.evaluate(async () => window.ky('/foo', {prefixUrl: '/'})),51 {message: /`input` must not begin with a slash when using `prefixUrl`/},52 );5354 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 lines
7980 await page.goto(server.url);81 await addKyScriptToPage(page);8283 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 lines
107 }, 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 lines
148149 await page.goto(server.url);150 await addKyScriptToPage(page);151152 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 lines
183 await page.goto(server.url);184 await page.addScriptTag({content: 'window.AbortController = undefined;\n'});185 await addKyScriptToPage(page);186187 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 lines
219220 await page.goto(server.url);221 await addKyScriptToPage(page);222223 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);226227 const data: any[] = [];
28 unmodified lines
256257 await page.goto(server.url);258 await addKyScriptToPage(page);259260 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 lines
277 await page.goto(server.url);278 await page.addScriptTag({content: 'window.ReadableStream = undefined;\n'});279 await addKyScriptToPage(page);280281 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 lines
310311 await page.goto(server.url);312 await addKyScriptToPage(page);313314 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 lines
335336 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});340341 busboy.on('error', (error: Error) => {341 busboyInstance.on('error', (error: Error) => {342 resolve([null, error]);343 });344345 // 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-operands
4 unmodified lines
355 resolve([null, error_]);356 }357 });358359 busboy.on('finish', () => {359 busboyInstance.on('finish', () => {360 response.writeHead(303, {Connection: 'close', Location: '/'});361 response.end();362 });363364 setTimeout(() => {365 resolve([null, new Error('Timeout')]);366 }, 3000);367368 request.pipe(busboy);368 request.pipe(busboyInstance);369 });370371 t.falsy(error);372 t.deepEqual(request.query, {foo: '1'});
44 unmodified lines
417418 await page.goto(server.url);419 await addKyScriptToPage(page);420421 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 });425426 return window
27 unmodified lines
454 await page.goto(server.url);455 await addKyScriptToPage(page);456457 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 lines
modified:.gitignore+2 added-2 removed
1distribution/1node_modules/3package-lock.json2yarn.lock3distribution/4package-lock.json
modified:package.json+12 added-12 removed
modified: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}