This commit is contained in:
董刚
2022-03-22 14:36:30 +08:00
parent 2cb86cd277
commit 60658fb11e
56 changed files with 1860 additions and 4 deletions

19
node_modules/.package-lock.json generated vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "oops-framework",
"version": "3.4.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"node_modules/ky": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/ky/-/ky-0.30.0.tgz",
"integrity": "sha512-X/u76z4JtDVq10u1JA5UQfatPxgPaVDMYTrgHyiTpGN2z4TMEJkIHsoSBBSg9SWZEIXTKsi9kHgiQ9o3Y/4yog==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sindresorhus/ky?sponsor=1"
}
}
}
}

16
node_modules/ky/distribution/core/Ky.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import type { Input, InternalOptions, Options } from '../types/options.js';
import { ResponsePromise } from '../types/response.js';
export declare class Ky {
static create(input: Input, options: Options): ResponsePromise;
request: Request;
protected abortController?: AbortController;
protected _retryCount: number;
protected _input: Input;
protected _options: InternalOptions;
constructor(input: Input, options?: Options);
protected _calculateRetryDelay(error: unknown): number;
protected _decorateResponse(response: Response): Response;
protected _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void>;
protected _fetch(): Promise<Response>;
protected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']): Response;
}

244
node_modules/ky/distribution/core/Ky.js generated vendored Normal file
View File

@@ -0,0 +1,244 @@
import { HTTPError } from '../errors/HTTPError.js';
import { TimeoutError } from '../errors/TimeoutError.js';
import { deepMerge, mergeHeaders } from '../utils/merge.js';
import { normalizeRequestMethod, normalizeRetryOptions } from '../utils/normalize.js';
import { delay, timeout } from '../utils/time.js';
import { maxSafeTimeout, responseTypes, stop, supportsAbortController, supportsFormData, supportsStreams } from './constants.js';
export class Ky {
// eslint-disable-next-line complexity
constructor(input, options = {}) {
var _a, _b, _c;
this._retryCount = 0;
this._input = input;
this._options = {
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
credentials: this._input.credentials || 'same-origin',
...options,
headers: mergeHeaders(this._input.headers, options.headers),
hooks: deepMerge({
beforeRequest: [],
beforeRetry: [],
beforeError: [],
afterResponse: [],
}, options.hooks),
method: normalizeRequestMethod((_a = options.method) !== null && _a !== void 0 ? _a : this._input.method),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
prefixUrl: String(options.prefixUrl || ''),
retry: normalizeRetryOptions(options.retry),
throwHttpErrors: options.throwHttpErrors !== false,
timeout: typeof options.timeout === 'undefined' ? 10000 : options.timeout,
fetch: (_b = options.fetch) !== null && _b !== void 0 ? _b : globalThis.fetch.bind(globalThis),
};
if (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {
throw new TypeError('`input` must be a string, URL, or Request');
}
if (this._options.prefixUrl && typeof this._input === 'string') {
if (this._input.startsWith('/')) {
throw new Error('`input` must not begin with a slash when using `prefixUrl`');
}
if (!this._options.prefixUrl.endsWith('/')) {
this._options.prefixUrl += '/';
}
this._input = this._options.prefixUrl + this._input;
}
if (supportsAbortController) {
this.abortController = new globalThis.AbortController();
if (this._options.signal) {
this._options.signal.addEventListener('abort', () => {
this.abortController.abort();
});
}
this._options.signal = this.abortController.signal;
}
this.request = new globalThis.Request(this._input, this._options);
if (this._options.searchParams) {
// eslint-disable-next-line unicorn/prevent-abbreviations
const textSearchParams = typeof this._options.searchParams === 'string'
? this._options.searchParams.replace(/^\?/, '')
: new URLSearchParams(this._options.searchParams).toString();
// eslint-disable-next-line unicorn/prevent-abbreviations
const searchParams = '?' + textSearchParams;
const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one
if (((supportsFormData && this._options.body instanceof globalThis.FormData)
|| this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {
this.request.headers.delete('content-type');
}
this.request = new globalThis.Request(new globalThis.Request(url, this.request), this._options);
}
if (this._options.json !== undefined) {
this._options.body = JSON.stringify(this._options.json);
this.request.headers.set('content-type', (_c = this._options.headers.get('content-type')) !== null && _c !== void 0 ? _c : 'application/json');
this.request = new globalThis.Request(this.request, { body: this._options.body });
}
}
// eslint-disable-next-line @typescript-eslint/promise-function-async
static create(input, options) {
const ky = new Ky(input, options);
const fn = async () => {
if (ky._options.timeout > maxSafeTimeout) {
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
}
// Delay the fetch so that body method shortcuts can set the Accept header
await Promise.resolve();
let response = await ky._fetch();
for (const hook of ky._options.hooks.afterResponse) {
// eslint-disable-next-line no-await-in-loop
const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));
if (modifiedResponse instanceof globalThis.Response) {
response = modifiedResponse;
}
}
ky._decorateResponse(response);
if (!response.ok && ky._options.throwHttpErrors) {
let error = new HTTPError(response, ky.request, ky._options);
for (const hook of ky._options.hooks.beforeError) {
// eslint-disable-next-line no-await-in-loop
error = await hook(error);
}
throw error;
}
// If `onDownloadProgress` is passed, it uses the stream API internally
/* istanbul ignore next */
if (ky._options.onDownloadProgress) {
if (typeof ky._options.onDownloadProgress !== 'function') {
throw new TypeError('The `onDownloadProgress` option must be a function');
}
if (!supportsStreams) {
throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');
}
return ky._stream(response.clone(), ky._options.onDownloadProgress);
}
return response;
};
const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());
const result = (isRetriableMethod ? ky._retry(fn) : fn());
for (const [type, mimeType] of Object.entries(responseTypes)) {
result[type] = async () => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);
const awaitedResult = await result;
const response = awaitedResult.clone();
if (type === 'json') {
if (response.status === 204) {
return '';
}
if (options.parseJson) {
return options.parseJson(await response.text());
}
}
return response[type]();
};
}
return result;
}
_calculateRetryDelay(error) {
this._retryCount++;
if (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {
if (error instanceof HTTPError) {
if (!this._options.retry.statusCodes.includes(error.response.status)) {
return 0;
}
const retryAfter = error.response.headers.get('Retry-After');
if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {
let after = Number(retryAfter);
if (Number.isNaN(after)) {
after = Date.parse(retryAfter) - Date.now();
}
else {
after *= 1000;
}
if (typeof this._options.retry.maxRetryAfter !== 'undefined' && after > this._options.retry.maxRetryAfter) {
return 0;
}
return after;
}
if (error.response.status === 413) {
return 0;
}
}
const BACKOFF_FACTOR = 0.3;
return BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000;
}
return 0;
}
_decorateResponse(response) {
if (this._options.parseJson) {
response.json = async () => this._options.parseJson(await response.text());
}
return response;
}
async _retry(fn) {
try {
return await fn();
// eslint-disable-next-line @typescript-eslint/no-implicit-any-catch
}
catch (error) {
const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);
if (ms !== 0 && this._retryCount > 0) {
await delay(ms);
for (const hook of this._options.hooks.beforeRetry) {
// eslint-disable-next-line no-await-in-loop
const hookResult = await hook({
request: this.request,
options: this._options,
error: error,
retryCount: this._retryCount,
});
// If `stop` is returned from the hook, the retry process is stopped
if (hookResult === stop) {
return;
}
}
return this._retry(fn);
}
throw error;
}
}
async _fetch() {
for (const hook of this._options.hooks.beforeRequest) {
// eslint-disable-next-line no-await-in-loop
const result = await hook(this.request, this._options);
if (result instanceof Request) {
this.request = result;
break;
}
if (result instanceof Response) {
return result;
}
}
if (this._options.timeout === false) {
return this._options.fetch(this.request.clone());
}
return timeout(this.request.clone(), this.abortController, this._options);
}
/* istanbul ignore next */
_stream(response, onDownloadProgress) {
const totalBytes = Number(response.headers.get('content-length')) || 0;
let transferredBytes = 0;
return new globalThis.Response(new globalThis.ReadableStream({
async start(controller) {
const reader = response.body.getReader();
if (onDownloadProgress) {
onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());
}
async function read() {
const { done, value } = await reader.read();
if (done) {
controller.close();
return;
}
if (onDownloadProgress) {
transferredBytes += value.byteLength;
const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
onDownloadProgress({ percent, transferredBytes, totalBytes }, value);
}
controller.enqueue(value);
await read();
}
await read();
},
}));
}
}
//# sourceMappingURL=Ky.js.map

1
node_modules/ky/distribution/core/Ky.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

13
node_modules/ky/distribution/core/constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
export declare const supportsAbortController: boolean;
export declare const supportsStreams: boolean;
export declare const supportsFormData: boolean;
export declare const requestMethods: readonly ["get", "post", "put", "patch", "head", "delete"];
export declare const responseTypes: {
readonly json: "application/json";
readonly text: "text/*";
readonly formData: "multipart/form-data";
readonly arrayBuffer: "*/*";
readonly blob: "*/*";
};
export declare const maxSafeTimeout = 2147483647;
export declare const stop: unique symbol;

17
node_modules/ky/distribution/core/constants.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
export const supportsAbortController = typeof globalThis.AbortController === 'function';
export const supportsStreams = typeof globalThis.ReadableStream === 'function';
export const supportsFormData = typeof globalThis.FormData === 'function';
export const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'];
const validate = () => undefined;
validate();
export const responseTypes = {
json: 'application/json',
text: 'text/*',
formData: 'multipart/form-data',
arrayBuffer: '*/*',
blob: '*/*',
};
// The maximum value of a 32bit int (see issue #117)
export const maxSafeTimeout = 2147483647;
export const stop = Symbol('stop');
//# sourceMappingURL=constants.js.map

1
node_modules/ky/distribution/core/constants.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../source/core/constants.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,UAAU,CAAC,eAAe,KAAK,UAAU,CAAC;AACxF,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,UAAU,CAAC,cAAc,KAAK,UAAU,CAAC;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,UAAU,CAAC,QAAQ,KAAK,UAAU,CAAC;AAE1E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC;AAEzF,MAAM,QAAQ,GAAG,GAA0B,EAAE,CAAC,SAAyB,CAAC;AACxE,QAAQ,EAEJ,CAAC;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,qBAAqB;IAC/B,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,KAAK;CACF,CAAC;AAEX,oDAAoD;AACpD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import type {Expect, Equal} from '@type-challenges/utils';\nimport {HttpMethod} from '../types/options.js';\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], HttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\nexport const stop = Symbol('stop');\n"]}

7
node_modules/ky/distribution/errors/HTTPError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import type { NormalizedOptions } from '../types/options.js';
export declare class HTTPError extends Error {
response: Response;
request: Request;
options: NormalizedOptions;
constructor(response: Response, request: Request, options: NormalizedOptions);
}

15
node_modules/ky/distribution/errors/HTTPError.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
// eslint-lint-disable-next-line @typescript-eslint/naming-convention
export class HTTPError extends Error {
constructor(response, request, options) {
const code = (response.status || response.status === 0) ? response.status : '';
const title = response.statusText || '';
const status = `${code} ${title}`.trim();
const reason = status ? `status code ${status}` : 'an unknown error';
super(`Request failed with ${reason}`);
this.name = 'HTTPError';
this.response = response;
this.request = request;
this.options = options;
}
}
//# sourceMappingURL=HTTPError.js.map

1
node_modules/ky/distribution/errors/HTTPError.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"HTTPError.js","sourceRoot":"","sources":["../../source/errors/HTTPError.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,MAAM,OAAO,SAAU,SAAQ,KAAK;IAKnC,YAAY,QAAkB,EAAE,OAAgB,EAAE,OAA0B;QAC3E,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/E,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC;QAErE,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;QAEvC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD","sourcesContent":["import type {NormalizedOptions} from '../types/options.js';\n\n// eslint-lint-disable-next-line @typescript-eslint/naming-convention\nexport class HTTPError extends Error {\n\tpublic response: Response;\n\tpublic request: Request;\n\tpublic options: NormalizedOptions;\n\n\tconstructor(response: Response, request: Request, options: NormalizedOptions) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText || '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}`);\n\n\t\tthis.name = 'HTTPError';\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n"]}

View File

@@ -0,0 +1,4 @@
export declare class TimeoutError extends Error {
request: Request;
constructor(request: Request);
}

8
node_modules/ky/distribution/errors/TimeoutError.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export class TimeoutError extends Error {
constructor(request) {
super('Request timed out');
this.name = 'TimeoutError';
this.request = request;
}
}
//# sourceMappingURL=TimeoutError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../../source/errors/TimeoutError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAGtC,YAAY,OAAgB;QAC3B,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD","sourcesContent":["export class TimeoutError extends Error {\n\tpublic request: Request;\n\n\tconstructor(request: Request) {\n\t\tsuper('Request timed out');\n\t\tthis.name = 'TimeoutError';\n\t\tthis.request = request;\n\t}\n}\n"]}

9
node_modules/ky/distribution/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
/*! MIT License © Sindre Sorhus */
import type { KyInstance } from './types/ky.js';
declare const ky: KyInstance;
export default ky;
export { Options, NormalizedOptions, RetryOptions, SearchParamsOption, DownloadProgress, } from './types/options.js';
export { Hooks, BeforeRequestHook, BeforeRetryHook, BeforeErrorHook, AfterResponseHook, } from './types/hooks.js';
export { ResponsePromise } from './types/response.js';
export { HTTPError } from './errors/HTTPError.js';
export { TimeoutError } from './errors/TimeoutError.js';

21
node_modules/ky/distribution/index.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
/*! MIT License © Sindre Sorhus */
import { Ky } from './core/Ky.js';
import { requestMethods, stop } from './core/constants.js';
import { validateAndMerge } from './utils/merge.js';
const createInstance = (defaults) => {
// eslint-disable-next-line @typescript-eslint/promise-function-async
const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
for (const method of requestMethods) {
// eslint-disable-next-line @typescript-eslint/promise-function-async
ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
}
ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
ky.extend = (newDefaults) => createInstance(validateAndMerge(defaults, newDefaults));
ky.stop = stop;
return ky;
};
const ky = createInstance();
export default ky;
export { HTTPError } from './errors/HTTPError.js';
export { TimeoutError } from './errors/TimeoutError.js';
//# sourceMappingURL=index.js.map

1
node_modules/ky/distribution/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAChC,OAAO,EAAC,cAAc,EAAE,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGlD,MAAM,cAAc,GAAG,CAAC,QAA2B,EAAc,EAAE;IAClE,qEAAqE;IACrE,MAAM,EAAE,GAAiC,CAAC,KAAY,EAAE,OAAiB,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAEpI,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE;QACpC,qEAAqE;QACrE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAY,EAAE,OAAiB,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;KAClH;IAED,EAAE,CAAC,MAAM,GAAG,CAAC,WAA8B,EAAE,EAAE,CAAC,cAAc,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9F,EAAE,CAAC,MAAM,GAAG,CAAC,WAA8B,EAAE,EAAE,CAAC,cAAc,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IACxG,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;IAEf,OAAO,EAAgB,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;AAE5B,eAAe,EAAE,CAAC;AAmBlB,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC","sourcesContent":["/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(defaults, newDefaults));\n\tky.stop = stop;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport {\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tSearchParamsOption,\n\tDownloadProgress,\n} from './types/options.js';\n\nexport {\n\tHooks,\n\tBeforeRequestHook,\n\tBeforeRetryHook,\n\tBeforeErrorHook,\n\tAfterResponseHook,\n} from './types/hooks.js';\n\nexport {ResponsePromise} from './types/response.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\n"]}

7
node_modules/ky/distribution/types/common.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
export declare type Required<T, K extends keyof T = keyof T> = T & {
[P in K]-?: T[P];
};
export declare type LiteralUnion<LiteralType extends BaseType, BaseType extends Primitive> = LiteralType | (BaseType & {
_?: never;
});

2
node_modules/ky/distribution/types/common.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=common.js.map

1
node_modules/ky/distribution/types/common.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../source/types/common.ts"],"names":[],"mappings":"","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-types\nexport type Primitive = null | undefined | string | number | boolean | symbol | bigint;\n\nexport type Required<T, K extends keyof T = keyof T> = T & {[P in K]-?: T[P]};\n\nexport type LiteralUnion<LiteralType extends BaseType, BaseType extends Primitive> =\n\t| LiteralType\n\t| (BaseType & {_?: never});\n"]}

114
node_modules/ky/distribution/types/hooks.d.ts generated vendored Normal file
View File

@@ -0,0 +1,114 @@
import { stop } from '../core/constants.js';
import { HTTPError } from '../index.js';
import type { NormalizedOptions } from './options.js';
export declare type BeforeRequestHook = (request: Request, options: NormalizedOptions) => Request | Response | void | Promise<Request | Response | void>;
export declare type BeforeRetryState = {
request: Request;
options: NormalizedOptions;
error: Error;
retryCount: number;
};
export declare type BeforeRetryHook = (options: BeforeRetryState) => typeof stop | void | Promise<typeof stop | void>;
export declare type AfterResponseHook = (request: Request, options: NormalizedOptions, response: Response) => Response | void | Promise<Response | void>;
export declare type BeforeErrorHook = (error: HTTPError) => HTTPError | Promise<HTTPError>;
export interface Hooks {
/**
This hook enables you to modify the request right before it is sent. Ky will make no further changes to the request after this. The hook function receives normalized input and options as arguments. You could, forf example, modiy `options.headers` here.
A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from this hook to completely avoid making a HTTP request. This can be used to mock a request, check an internal cache, etc. An **important** consideration when returning a `Response` from this hook is that all the following hooks will be skipped, so **ensure you only return a `Response` from the last hook**.
@default []
*/
beforeRequest?: BeforeRequestHook[];
/**
This hook enables you to modify the request right before retry. Ky will make no further changes to the request after this. The hook function receives an object with the normalized request and options, an error instance, and the retry count. You could, for example, modify `request.headers` here.
If the request received a response, the error will be of type `HTTPError` and the `Response` object will be available at `error.response`. Be aware that some types of errors, such as network errors, inherently mean that a response was not received. In that case, the error will not be an instance of `HTTPError`.
You can prevent Ky from retrying the request by throwing an error. Ky will not handle it in any way and the error will be propagated to the request initiator. The rest of the `beforeRetry` hooks will not be called in this case. Alternatively, you can return the [`ky.stop`](#ky.stop) symbol to do the same thing but without propagating an error (this has some limitations, see `ky.stop` docs for details).
@example
```
import ky from 'ky';
const response = await ky('https://example.com', {
hooks: {
beforeRetry: [
async ({request, options, error, retryCount}) => {
const token = await ky('https://example.com/refresh-token');
options.headers.set('Authorization', `token ${token}`);
}
]
}
});
```
@default []
*/
beforeRetry?: BeforeRetryHook[];
/**
This hook enables you to read and optionally modify the response. The hook function receives normalized input, options, and a clone of the response as arguments. The return value of the hook function will be used by Ky as the response object if it's an instance of [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
@default []
@example
```
import ky from 'ky';
const response = await ky('https://example.com', {
hooks: {
afterResponse: [
(_input, _options, response) => {
// You could do something with the response, for example, logging.
log(response);
// Or return a `Response` instance to overwrite the response.
return new Response('A different response', {status: 200});
},
// Or retry with a fresh token on a 403 error
async (input, options, response) => {
if (response.status === 403) {
// Get a fresh token
const token = await ky('https://example.com/token').text();
// Retry with the token
options.headers.set('Authorization', `token ${token}`);
return ky(input, options);
}
}
]
}
});
```
*/
afterResponse?: AfterResponseHook[];
/**
This hook enables you to modify the `HTTPError` right before it is thrown. The hook function receives a `HTTPError` as an argument and should return an instance of `HTTPError`.
@default []
@example
```
import ky from 'ky';
await ky('https://example.com', {
hooks: {
beforeError: [
error => {
const {response} = error;
if (response && response.body) {
error.name = 'GitHubError';
error.message = `${response.body.message} (${response.statusCode})`;
}
return error;
}
]
}
});
```
*/
beforeError?: BeforeErrorHook[];
}

2
node_modules/ky/distribution/types/hooks.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=hooks.js.map

1
node_modules/ky/distribution/types/hooks.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

110
node_modules/ky/distribution/types/ky.d.ts generated vendored Normal file
View File

@@ -0,0 +1,110 @@
import { stop } from '../core/constants.js';
import type { Input, Options } from './options.js';
import type { ResponsePromise } from './response.js';
export interface KyInstance {
/**
Fetch the given `url`.
@param url - `Request` object, `URL` object, or URL string.
@returns A promise with `Body` method added.
@example
```
import ky from 'ky';
const json = await ky('https://example.com', {json: {foo: true}}).json();
console.log(json);
//=> `{data: '🦄'}`
```
*/
(url: Input, options?: Options): ResponsePromise;
/**
Fetch the given `url` using the option `{method: 'get'}`.
@param url - `Request` object, `URL` object, or URL string.
@returns A promise with `Body` methods added.
*/
get: (url: Input, options?: Options) => ResponsePromise;
/**
Fetch the given `url` using the option `{method: 'post'}`.
@param url - `Request` object, `URL` object, or URL string.
@returns A promise with `Body` methods added.
*/
post: (url: Input, options?: Options) => ResponsePromise;
/**
Fetch the given `url` using the option `{method: 'put'}`.
@param url - `Request` object, `URL` object, or URL string.
@returns A promise with `Body` methods added.
*/
put: (url: Input, options?: Options) => ResponsePromise;
/**
Fetch the given `url` using the option `{method: 'delete'}`.
@param url - `Request` object, `URL` object, or URL string.
@returns A promise with `Body` methods added.
*/
delete: (url: Input, options?: Options) => ResponsePromise;
/**
Fetch the given `url` using the option `{method: 'patch'}`.
@param url - `Request` object, `URL` object, or URL string.
@returns A promise with `Body` methods added.
*/
patch: (url: Input, options?: Options) => ResponsePromise;
/**
Fetch the given `url` using the option `{method: 'head'}`.
@param url - `Request` object, `URL` object, or URL string.
@returns A promise with `Body` methods added.
*/
head: (url: Input, options?: Options) => ResponsePromise;
/**
Create a new Ky instance with complete new defaults.
@returns A new Ky instance.
*/
create: (defaultOptions: Options) => KyInstance;
/**
Create a new Ky instance with some defaults overridden with your own.
In contrast to `ky.create()`, `ky.extend()` inherits defaults from its parent.
@returns A new Ky instance.
*/
extend: (defaultOptions: Options) => KyInstance;
/**
A `Symbol` that can be returned by a `beforeRetry` hook to stop the retry. This will also short circuit the remaining `beforeRetry` hooks.
Note: Returning this symbol makes Ky abort and return with an `undefined` response. Be sure to check for a response before accessing any properties on it or use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining). It is also incompatible with body methods, such as `.json()` or `.text()`, because there is no response to parse. In general, we recommend throwing an error instead of returning this symbol, as that will cause Ky to abort and then throw, which avoids these limitations.
A valid use-case for `ky.stop` is to prevent retries when making requests for side effects, where the returned data is not important. For example, logging client activity to the server.
@example
```
import ky from 'ky';
const options = {
hooks: {
beforeRetry: [
async ({request, options, error, retryCount}) => {
const shouldStopRetry = await ky('https://example.com/api');
if (shouldStopRetry) {
return ky.stop;
}
}
]
}
};
// Note that response will be `undefined` in case `ky.stop` is returned.
const response = await ky.post('https://example.com', options);
// Using `.text()` or other body methods is not supported.
const text = await ky('https://example.com', options).text();
```
*/
readonly stop: typeof stop;
}

2
node_modules/ky/distribution/types/ky.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ky.js.map

1
node_modules/ky/distribution/types/ky.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ky.js","sourceRoot":"","sources":["../../source/types/ky.ts"],"names":[],"mappings":"","sourcesContent":["import {stop} from '../core/constants.js';\nimport type {Input, Options} from './options.js';\nimport type {ResponsePromise} from './response.js';\n\nexport interface KyInstance {\n\t/**\n\tFetch the given `url`.\n\n\t@param url - `Request` object, `URL` object, or URL string.\n\t@returns A promise with `Body` method added.\n\n\t@example\n\t```\n\timport ky from 'ky';\n\n\tconst json = await ky('https://example.com', {json: {foo: true}}).json();\n\n\tconsole.log(json);\n\t//=> `{data: '🦄'}`\n\t```\n\t*/\n\t(url: Input, options?: Options): ResponsePromise;\n\n\t/**\n\tFetch the given `url` using the option `{method: 'get'}`.\n\n\t@param url - `Request` object, `URL` object, or URL string.\n\t@returns A promise with `Body` methods added.\n\t*/\n\tget: (url: Input, options?: Options) => ResponsePromise;\n\n\t/**\n\tFetch the given `url` using the option `{method: 'post'}`.\n\n\t@param url - `Request` object, `URL` object, or URL string.\n\t@returns A promise with `Body` methods added.\n\t*/\n\tpost: (url: Input, options?: Options) => ResponsePromise;\n\n\t/**\n\tFetch the given `url` using the option `{method: 'put'}`.\n\n\t@param url - `Request` object, `URL` object, or URL string.\n\t@returns A promise with `Body` methods added.\n\t*/\n\tput: (url: Input, options?: Options) => ResponsePromise;\n\n\t/**\n\tFetch the given `url` using the option `{method: 'delete'}`.\n\n\t@param url - `Request` object, `URL` object, or URL string.\n\t@returns A promise with `Body` methods added.\n\t*/\n\tdelete: (url: Input, options?: Options) => ResponsePromise;\n\n\t/**\n\tFetch the given `url` using the option `{method: 'patch'}`.\n\n\t@param url - `Request` object, `URL` object, or URL string.\n\t@returns A promise with `Body` methods added.\n\t*/\n\tpatch: (url: Input, options?: Options) => ResponsePromise;\n\n\t/**\n\tFetch the given `url` using the option `{method: 'head'}`.\n\n\t@param url - `Request` object, `URL` object, or URL string.\n\t@returns A promise with `Body` methods added.\n\t*/\n\thead: (url: Input, options?: Options) => ResponsePromise;\n\n\t/**\n\tCreate a new Ky instance with complete new defaults.\n\n\t@returns A new Ky instance.\n\t*/\n\tcreate: (defaultOptions: Options) => KyInstance;\n\n\t/**\n\tCreate a new Ky instance with some defaults overridden with your own.\n\n\tIn contrast to `ky.create()`, `ky.extend()` inherits defaults from its parent.\n\n\t@returns A new Ky instance.\n\t*/\n\textend: (defaultOptions: Options) => KyInstance;\n\n\t/**\n\tA `Symbol` that can be returned by a `beforeRetry` hook to stop the retry. This will also short circuit the remaining `beforeRetry` hooks.\n\n\tNote: Returning this symbol makes Ky abort and return with an `undefined` response. Be sure to check for a response before accessing any properties on it or use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining). It is also incompatible with body methods, such as `.json()` or `.text()`, because there is no response to parse. In general, we recommend throwing an error instead of returning this symbol, as that will cause Ky to abort and then throw, which avoids these limitations.\n\n\tA valid use-case for `ky.stop` is to prevent retries when making requests for side effects, where the returned data is not important. For example, logging client activity to the server.\n\n\t@example\n\t```\n\timport ky from 'ky';\n\n\tconst options = {\n\t\thooks: {\n\t\t\tbeforeRetry: [\n\t\t\t\tasync ({request, options, error, retryCount}) => {\n\t\t\t\t\tconst shouldStopRetry = await ky('https://example.com/api');\n\t\t\t\t\tif (shouldStopRetry) {\n\t\t\t\t\t\treturn ky.stop;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t};\n\n\t// Note that response will be `undefined` in case `ky.stop` is returned.\n\tconst response = await ky.post('https://example.com', options);\n\n\t// Using `.text()` or other body methods is not supported.\n\tconst text = await ky('https://example.com', options).text();\n\t```\n\t*/\n\treadonly stop: typeof stop;\n}\n"]}

220
node_modules/ky/distribution/types/options.d.ts generated vendored Normal file
View File

@@ -0,0 +1,220 @@
import type { LiteralUnion, Required } from './common.js';
import type { Hooks } from './hooks.js';
import type { RetryOptions } from './retry.js';
export declare type SearchParamsInit = string | string[][] | Record<string, string> | URLSearchParams | undefined;
export declare type SearchParamsOption = SearchParamsInit | Record<string, string | number | boolean> | Array<Array<string | number | boolean>>;
export declare type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete';
export declare type Input = string | URL | Request;
export interface DownloadProgress {
percent: number;
transferredBytes: number;
/**
Note: If it's not possible to retrieve the body size, it will be `0`.
*/
totalBytes: number;
}
export declare type KyHeadersInit = HeadersInit | Record<string, string | undefined>;
/**
Options are the same as `window.fetch`, with some exceptions.
*/
export interface Options extends Omit<RequestInit, 'headers'> {
/**
HTTP method used to make the request.
Internally, the standard methods (`GET`, `POST`, `PUT`, `PATCH`, `HEAD` and `DELETE`) are uppercased in order to avoid server errors due to case sensitivity.
*/
method?: LiteralUnion<HttpMethod, string>;
/**
HTTP headers used to make the request.
You can pass a `Headers` instance or a plain object.
You can remove a header with `.extend()` by passing the header with an `undefined` value.
@example
```
import ky from 'ky';
const url = 'https://sindresorhus.com';
const original = ky.create({
headers: {
rainbow: 'rainbow',
unicorn: 'unicorn'
}
});
const extended = original.extend({
headers: {
rainbow: undefined
}
});
const response = await extended(url).json();
console.log('rainbow' in response);
//=> false
console.log('unicorn' in response);
//=> true
```
*/
headers?: KyHeadersInit;
/**
Shortcut for sending JSON. Use this instead of the `body` option.
Accepts any plain object or value, which will be `JSON.stringify()`'d and sent in the body with the correct header set.
*/
json?: unknown;
/**
User-defined JSON-parsing function.
Use-cases:
1. Parse JSON via the [`bourne` package](https://github.com/hapijs/bourne) to protect from prototype pollution.
2. Parse JSON with [`reviver` option of `JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
@default JSON.parse()
@example
```
import ky from 'ky';
import bourne from '@hapijs/bourne';
const json = await ky('https://example.com', {
parseJson: text => bourne(text)
}).json();
```
*/
parseJson?: (text: string) => unknown;
/**
Search parameters to include in the request URL. Setting this will override all existing search parameters in the input URL.
Accepts any value supported by [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams).
*/
searchParams?: SearchParamsOption;
/**
A prefix to prepend to the `input` URL when making the request. It can be any valid URL, either relative or absolute. A trailing slash `/` is optional and will be added automatically, if needed, when it is joined with `input`. Only takes effect when `input` is a string. The `input` argument cannot start with a slash `/` when using this option.
Useful when used with [`ky.extend()`](#kyextenddefaultoptions) to create niche-specific Ky-instances.
Notes:
- After `prefixUrl` and `input` are joined, the result is resolved against the [base URL](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI) of the page (if any).
- Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion about how the `input` URL is handled, given that `input` will not follow the normal URL resolution rules when `prefixUrl` is being used, which changes the meaning of a leading slash.
@example
```
import ky from 'ky';
// On https://example.com
const response = await ky('unicorn', {prefixUrl: '/api'});
//=> 'https://example.com/api/unicorn'
const response = await ky('unicorn', {prefixUrl: 'https://cats.com'});
//=> 'https://cats.com/unicorn'
```
*/
prefixUrl?: URL | string;
/**
An object representing `limit`, `methods`, `statusCodes` and `maxRetryAfter` fields for maximum retry count, allowed methods, allowed status codes and maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time.
If `retry` is a number, it will be used as `limit` and other defaults will remain in place.
If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`. If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
Delays between retries is calculated with the function `0.3 * (2 ** (retry - 1)) * 1000`, where `retry` is the attempt number (starts from 1).
Retries are not triggered following a timeout.
@example
```
import ky from 'ky';
const json = await ky('https://example.com', {
retry: {
limit: 10,
methods: ['get'],
statusCodes: [413]
}
}).json();
```
*/
retry?: RetryOptions | number;
/**
Timeout in milliseconds for getting a response, including any retries. Can not be greater than 2147483647.
If set to `false`, there will be no timeout.
@default 10000
*/
timeout?: number | false;
/**
Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.
*/
hooks?: Hooks;
/**
Throw an `HTTPError` when, after following redirects, the response has a non-2xx status code. To also throw for redirects instead of following them, set the [`redirect`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) option to `'manual'`.
Setting this to `false` may be useful if you are checking for resource availability and are expecting error responses.
Note: If `false`, error responses are considered successful and the request will not be retried.
@default true
*/
throwHttpErrors?: boolean;
/**
Download progress event handler.
@param chunk - Note: It's empty for the first call.
@example
```
import ky from 'ky';
const response = await ky('https://example.com', {
onDownloadProgress: (progress, chunk) => {
// Example output:
// `0% - 0 of 1271 bytes`
// `100% - 1271 of 1271 bytes`
console.log(`${progress.percent * 100}% - ${progress.transferredBytes} of ${progress.totalBytes} bytes`);
}
});
```
*/
onDownloadProgress?: (progress: DownloadProgress, chunk: Uint8Array) => void;
/**
User-defined `fetch` function.
Has to be fully compatible with the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) standard.
Use-cases:
1. Use custom `fetch` implementations like [`isomorphic-unfetch`](https://www.npmjs.com/package/isomorphic-unfetch).
2. Use the `fetch` wrapper function provided by some frameworks that use server-side rendering (SSR).
@default fetch
@example
```
import ky from 'ky';
import fetch from 'isomorphic-unfetch';
const json = await ky('https://example.com', {fetch}).json();
```
*/
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
}
export declare type InternalOptions = Required<Omit<Options, 'hooks' | 'retry'>, 'credentials' | 'fetch' | 'prefixUrl' | 'timeout'> & {
headers: Required<Headers>;
hooks: Required<Hooks>;
retry: Required<RetryOptions>;
prefixUrl: string;
};
/**
Normalized options passed to the `fetch` call and the `beforeRequest` hooks.
*/
export interface NormalizedOptions extends RequestInit {
method: RequestInit['method'];
credentials: RequestInit['credentials'];
retry: RetryOptions;
prefixUrl: string;
onDownloadProgress: Options['onDownloadProgress'];
}
export type { RetryOptions } from './retry.js';

2
node_modules/ky/distribution/types/options.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=options.js.map

1
node_modules/ky/distribution/types/options.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

31
node_modules/ky/distribution/types/response.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/**
Returns a `Response` object with `Body` methods added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if the response status is `204` instead of throwing a parse error due to an empty body.
*/
export interface ResponsePromise extends Promise<Response> {
arrayBuffer: () => Promise<ArrayBuffer>;
blob: () => Promise<Blob>;
formData: () => Promise<FormData>;
/**
Get the response body as JSON.
@example
```
import ky from 'ky';
const json = await ky(…).json();
```
@example
```
import ky from 'ky';
interface Result {
value: number;
}
const result = await ky(…).json<Result>();
```
*/
json: <T = unknown>() => Promise<T>;
text: () => Promise<string>;
}

2
node_modules/ky/distribution/types/response.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=response.js.map

1
node_modules/ky/distribution/types/response.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../source/types/response.ts"],"names":[],"mappings":"","sourcesContent":["/**\nReturns a `Response` object with `Body` methods added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if the response status is `204` instead of throwing a parse error due to an empty body.\n*/\nexport interface ResponsePromise extends Promise<Response> {\n\tarrayBuffer: () => Promise<ArrayBuffer>;\n\n\tblob: () => Promise<Blob>;\n\n\tformData: () => Promise<FormData>;\n\n\t// TODO: Use `json<T extends JSONValue>(): Promise<T>;` when it's fixed in TS.\n\t// See https://github.com/microsoft/TypeScript/issues/15300 and https://github.com/sindresorhus/ky/pull/80\n\t/**\n\tGet the response body as JSON.\n\n\t@example\n\t```\n\timport ky from 'ky';\n\n\tconst json = await ky(…).json();\n\t```\n\n\t@example\n\t```\n\timport ky from 'ky';\n\n\tinterface Result {\n\t\tvalue: number;\n\t}\n\n\tconst result = await ky(…).json<Result>();\n\t```\n\t*/\n\tjson: <T = unknown>() => Promise<T>;\n\n\ttext: () => Promise<string>;\n}\n"]}

32
node_modules/ky/distribution/types/retry.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
export interface RetryOptions {
/**
The number of times to retry failed requests.
@default 2
*/
limit?: number;
/**
The HTTP methods allowed to retry.
@default ['get', 'put', 'head', 'delete', 'options', 'trace']
*/
methods?: string[];
/**
The HTTP status codes allowed to retry.
@default [408, 413, 429, 500, 502, 503, 504]
*/
statusCodes?: number[];
/**
The HTTP status codes allowed to retry with a `Retry-After` header.
@default [413, 429, 503]
*/
afterStatusCodes?: number[];
/**
If the `Retry-After` header is greater than `maxRetryAfter`, the request will be canceled.
@default Infinity
*/
maxRetryAfter?: number;
}

2
node_modules/ky/distribution/types/retry.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=retry.js.map

1
node_modules/ky/distribution/types/retry.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../source/types/retry.ts"],"names":[],"mappings":"","sourcesContent":["export interface RetryOptions {\n\t/**\n\tThe number of times to retry failed requests.\n\n\t@default 2\n\t*/\n\tlimit?: number;\n\n\t/**\n\tThe HTTP methods allowed to retry.\n\n\t@default ['get', 'put', 'head', 'delete', 'options', 'trace']\n\t*/\n\tmethods?: string[];\n\n\t/**\n\tThe HTTP status codes allowed to retry.\n\n\t@default [408, 413, 429, 500, 502, 503, 504]\n\t*/\n\tstatusCodes?: number[];\n\n\t/**\n\tThe HTTP status codes allowed to retry with a `Retry-After` header.\n\n\t@default [413, 429, 503]\n\t*/\n\tafterStatusCodes?: number[];\n\n\t/**\n\tIf the `Retry-After` header is greater than `maxRetryAfter`, the request will be canceled.\n\n\t@default Infinity\n\t*/\n\tmaxRetryAfter?: number;\n}\n"]}

1
node_modules/ky/distribution/utils/is.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare const isObject: (value: unknown) => value is object;

3
node_modules/ky/distribution/utils/is.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
// eslint-disable-next-line @typescript-eslint/ban-types
export const isObject = (value) => value !== null && typeof value === 'object';
//# sourceMappingURL=is.js.map

1
node_modules/ky/distribution/utils/is.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"is.js","sourceRoot":"","sources":["../../source/utils/is.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n"]}

4
node_modules/ky/distribution/utils/merge.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { KyHeadersInit, Options } from '../types/options.js';
export declare const validateAndMerge: (...sources: Array<Partial<Options> | undefined>) => Partial<Options>;
export declare const mergeHeaders: (source1?: KyHeadersInit, source2?: KyHeadersInit) => Headers;
export declare const deepMerge: <T>(...sources: (Partial<T> | undefined)[]) => T;

50
node_modules/ky/distribution/utils/merge.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import { isObject } from './is.js';
export const validateAndMerge = (...sources) => {
for (const source of sources) {
if ((!isObject(source) || Array.isArray(source)) && typeof source !== 'undefined') {
throw new TypeError('The `options` argument must be an object');
}
}
return deepMerge({}, ...sources);
};
export const mergeHeaders = (source1 = {}, source2 = {}) => {
const result = new globalThis.Headers(source1);
const isHeadersInstance = source2 instanceof globalThis.Headers;
const source = new globalThis.Headers(source2);
for (const [key, value] of source.entries()) {
if ((isHeadersInstance && value === 'undefined') || value === undefined) {
result.delete(key);
}
else {
result.set(key, value);
}
}
return result;
};
// TODO: Make this strongly-typed (no `any`).
export const deepMerge = (...sources) => {
let returnValue = {};
let headers = {};
for (const source of sources) {
if (Array.isArray(source)) {
if (!Array.isArray(returnValue)) {
returnValue = [];
}
returnValue = [...returnValue, ...source];
}
else if (isObject(source)) {
for (let [key, value] of Object.entries(source)) {
if (isObject(value) && key in returnValue) {
value = deepMerge(returnValue[key], value);
}
returnValue = { ...returnValue, [key]: value };
}
if (isObject(source.headers)) {
headers = mergeHeaders(headers, source.headers);
returnValue.headers = headers;
}
}
}
return returnValue;
};
//# sourceMappingURL=merge.js.map

1
node_modules/ky/distribution/utils/merge.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../source/utils/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,OAA4C,EAAoB,EAAE;IACrG,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC7B,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YAClF,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;SAChE;KACD;IAED,OAAO,SAAS,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,UAAyB,EAAE,EAAE,UAAyB,EAAE,EAAE,EAAE;IACxF,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,OAAsB,CAAC,CAAC;IAC9D,MAAM,iBAAiB,GAAG,OAAO,YAAY,UAAU,CAAC,OAAO,CAAC;IAChE,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,OAAsB,CAAC,CAAC;IAE9D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE;QAC5C,IAAI,CAAC,iBAAiB,IAAI,KAAK,KAAK,WAAW,CAAC,IAAI,KAAK,KAAK,SAAS,EAAE;YACxE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACnB;aAAM;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SACvB;KACD;IAED,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,GAAG,OAAsC,EAAK,EAAE;IAC5E,IAAI,WAAW,GAAQ,EAAE,CAAC;IAC1B,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBAChC,WAAW,GAAG,EAAE,CAAC;aACjB;YAED,WAAW,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC;SAC1C;aAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;YAC5B,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBAChD,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,WAAW,EAAE;oBAC1C,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;iBAC3C;gBAED,WAAW,GAAG,EAAC,GAAG,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAC,CAAC;aAC7C;YAED,IAAI,QAAQ,CAAE,MAAc,CAAC,OAAO,CAAC,EAAE;gBACtC,OAAO,GAAG,YAAY,CAAC,OAAO,EAAG,MAAc,CAAC,OAAO,CAAC,CAAC;gBACzD,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;aAC9B;SACD;KACD;IAED,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import type {KyHeadersInit, Options} from '../types/options.js';\nimport {isObject} from './is.js';\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && typeof source !== 'undefined') {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as HeadersInit);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as HeadersInit);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers = {};\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\tif (isObject(value) && key in returnValue) {\n\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\theaders = mergeHeaders(headers, (source as any).headers);\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn returnValue;\n};\n"]}

3
node_modules/ky/distribution/utils/normalize.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { RetryOptions } from '../types/retry.js';
export declare const normalizeRequestMethod: (input: string) => string;
export declare const normalizeRetryOptions: (retry?: number | RetryOptions) => Required<RetryOptions>;

32
node_modules/ky/distribution/utils/normalize.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
import { requestMethods } from '../core/constants.js';
export const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
const retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];
const retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
const retryAfterStatusCodes = [413, 429, 503];
const defaultRetryOptions = {
limit: 2,
methods: retryMethods,
statusCodes: retryStatusCodes,
afterStatusCodes: retryAfterStatusCodes,
maxRetryAfter: Number.POSITIVE_INFINITY,
};
export const normalizeRetryOptions = (retry = {}) => {
if (typeof retry === 'number') {
return {
...defaultRetryOptions,
limit: retry,
};
}
if (retry.methods && !Array.isArray(retry.methods)) {
throw new Error('retry.methods must be an array');
}
if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {
throw new Error('retry.statusCodes must be an array');
}
return {
...defaultRetryOptions,
...retry,
afterStatusCodes: retryAfterStatusCodes,
};
};
//# sourceMappingURL=normalize.js.map

1
node_modules/ky/distribution/utils/normalize.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../source/utils/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAIpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAU,EAAE,CAC/D,cAAc,CAAC,QAAQ,CAAC,KAAmB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAE5E,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAE1E,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE7D,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE9C,MAAM,mBAAmB,GAA2B;IACnD,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,YAAY;IACrB,WAAW,EAAE,gBAAgB;IAC7B,gBAAgB,EAAE,qBAAqB;IACvC,aAAa,EAAE,MAAM,CAAC,iBAAiB;CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAA+B,EAAE,EAA0B,EAAE;IAClG,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC9B,OAAO;YACN,GAAG,mBAAmB;YACtB,KAAK,EAAE,KAAK;SACZ,CAAC;KACF;IAED,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KAClD;IAED,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACtD;IAED,OAAO;QACN,GAAG,mBAAmB;QACtB,GAAG,KAAK;QACR,gBAAgB,EAAE,qBAAqB;KACvC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import {requestMethods} from '../core/constants.js';\nimport type {HttpMethod} from '../types/options.js';\nimport type {RetryOptions} from '../types/retry.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as HttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\n\nconst defaultRetryOptions: Required<RetryOptions> = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): Required<RetryOptions> => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\tlimit: retry,\n\t\t};\n\t}\n\n\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\treturn {\n\t\t...defaultRetryOptions,\n\t\t...retry,\n\t\tafterStatusCodes: retryAfterStatusCodes,\n\t};\n};\n"]}

6
node_modules/ky/distribution/utils/time.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export declare type TimeoutOptions = {
timeout: number;
fetch: typeof fetch;
};
export declare const timeout: (request: Request, abortController: AbortController | undefined, options: TimeoutOptions) => Promise<Response>;
export declare const delay: (ms: number) => Promise<unknown>;

21
node_modules/ky/distribution/utils/time.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import { TimeoutError } from '../errors/TimeoutError.js';
// `Promise.race()` workaround (#91)
export const timeout = async (request, abortController, options) => new Promise((resolve, reject) => {
const timeoutId = setTimeout(() => {
if (abortController) {
abortController.abort();
}
reject(new TimeoutError(request));
}, options.timeout);
void options
.fetch(request)
.then(resolve)
.catch(reject)
.then(() => {
clearTimeout(timeoutId);
});
});
export const delay = async (ms) => new Promise(resolve => {
setTimeout(resolve, ms);
});
//# sourceMappingURL=time.js.map

1
node_modules/ky/distribution/utils/time.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../source/utils/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAOvD,oCAAoC;AACpC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC3B,OAAgB,EAChB,eAA4C,EAC5C,OAAuB,EACH,EAAE,CACtB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC/B,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;QACjC,IAAI,eAAe,EAAE;YACpB,eAAe,CAAC,KAAK,EAAE,CAAC;SACxB;QAED,MAAM,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACnC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,KAAK,OAAO;SACV,KAAK,CAAC,OAAO,CAAC;SACd,IAAI,CAAC,OAAO,CAAC;SACb,KAAK,CAAC,MAAM,CAAC;SACb,IAAI,CAAC,GAAG,EAAE;QACV,YAAY,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;IAChE,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC","sourcesContent":["import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport const timeout = async (\n\trequest: Request,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> =>\n\tnew Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n\nexport const delay = async (ms: number) => new Promise(resolve => {\n\tsetTimeout(resolve, ms);\n});\n"]}

6
node_modules/ky/distribution/utils/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export declare type Mutable<T> = {
-readonly [P in keyof T]: T[P];
};
export declare type ObjectEntries<T> = T extends ArrayLike<infer U> ? Array<[string, U]> : Array<{
[K in keyof T]: [K, T[K]];
}[keyof T]>;

2
node_modules/ky/distribution/utils/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

1
node_modules/ky/distribution/utils/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../source/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export type Mutable<T> = {\n\t-readonly[P in keyof T]: T[P]\n};\n\nexport type ObjectEntries<T> = T extends ArrayLike<infer U>\n\t? Array<[string, U]>\n\t: Array<{[K in keyof T]: [K, T[K]]}[keyof T]>;\n"]}

9
node_modules/ky/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

118
node_modules/ky/package.json generated vendored Normal file
View File

@@ -0,0 +1,118 @@
{
"name": "ky",
"version": "0.30.0",
"description": "Tiny and elegant HTTP client based on the browser Fetch API",
"license": "MIT",
"repository": "sindresorhus/ky",
"funding": "https://github.com/sindresorhus/ky?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"main": "./distribution/index.js",
"exports": "./distribution/index.js",
"types": "./distribution/index.d.ts",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && npm run build && ava",
"debug": "PWDEBUG=1 ava --timeout=2m",
"release": "np",
"build": "del-cli distribution && tsc --project tsconfig.dist.json",
"prepare": "npm run build"
},
"files": [
"distribution"
],
"keywords": [
"fetch",
"request",
"requests",
"http",
"https",
"fetching",
"get",
"url",
"curl",
"wget",
"net",
"network",
"ajax",
"api",
"rest",
"xhr",
"browser",
"got",
"axios",
"node-fetch"
],
"devDependencies": {
"@sindresorhus/tsconfig": "^2.0.0",
"@type-challenges/utils": "^0.1.1",
"@types/body-parser": "^1.19.1",
"@types/busboy": "^0.3.1",
"@types/express": "^4.17.13",
"@types/node-fetch": "^2.5.10",
"@types/pify": "^5.0.1",
"abort-controller": "^3.0.0",
"ava": "4.0.0-alpha.2",
"body-parser": "^1.19.0",
"busboy": "^0.3.1",
"del-cli": "^4.0.1",
"delay": "^5.0.0",
"express": "^4.17.1",
"form-data": "^4.0.0",
"node-fetch": "^2.6.1",
"pify": "^5.0.0",
"playwright-chromium": "^1.19.2",
"raw-body": "^2.5.1",
"ts-node": "^10.6.0",
"typescript": "~4.6.2",
"xo": "^0.48.0"
},
"sideEffects": false,
"xo": {
"envs": [
"browser"
],
"globals": [
"globalThis"
],
"rules": {
"unicorn/filename-case": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/naming-convention": "off"
}
},
"ava": {
"require": [
"./test/_require.ts"
],
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
]
},
"nyc": {
"reporter": [
"text",
"html",
"lcov"
],
"extension": [
".ts"
],
"exclude": [
"**/test/**"
]
}
}

640
node_modules/ky/readme.md generated vendored Normal file
View File

@@ -0,0 +1,640 @@
<div align="center">
<br>
<div>
<img width="600" height="600" src="media/logo.svg" alt="ky">
</div>
<p align="center">Huge thanks to <a href="https://lunanode.com"><img src="https://sindresorhus.com/assets/thanks/lunanode-logo.svg" width="170"></a> for sponsoring me!</p>
<br>
<br>
<br>
<br>
</div>
> 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)
[![Coverage Status](https://codecov.io/gh/sindresorhus/ky/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/ky)
[![](https://badgen.net/bundlephobia/minzip/ky)](https://bundlephobia.com/result?p=ky)
Ky targets [modern browsers](#browser-support) and [Deno](https://github.com/denoland/deno). For older browsers, you will need to transpile and use a [`fetch` polyfill](https://github.com/github/fetch) and [`globalThis` polyfill](https://github.com/es-shims/globalThis). For Node.js, check out [Got](https://github.com/sindresorhus/got). For isomorphic needs (like SSR), check out [`ky-universal`](https://github.com/sindresorhus/ky-universal).
It's just a tiny file with no dependencies.
## Benefits over plain `fetch`
- Simpler API
- Method shortcuts (`ky.post()`)
- Treats non-2xx status codes as errors (after redirects)
- Retries failed requests
- JSON option
- Timeout support
- URL prefix option
- Instances with custom defaults
- Hooks
## Install
```
$ npm install ky
```
###### Download
- [Normal](https://cdn.jsdelivr.net/npm/ky/index.js)
- [Minified](https://cdn.jsdelivr.net/npm/ky/index.min.js)
###### CDN
- [jsdelivr](https://www.jsdelivr.com/package/npm/ky)
- [unpkg](https://unpkg.com/ky)
## Usage
```js
import ky from 'ky';
const json = await ky.post('https://example.com', {json: {foo: true}}).json();
console.log(json);
//=> `{data: '🦄'}`
```
With plain `fetch`, it would be:
```js
class HTTPError extends Error {}
const response = await fetch('https://example.com', {
method: 'POST',
body: JSON.stringify({foo: true}),
headers: {
'content-type': 'application/json'
}
});
if (!response.ok) {
throw new HTTPError(`Fetch error: ${response.statusText}`);
}
const json = await response.json();
console.log(json);
//=> `{data: '🦄'}`
```
If you are using [Deno](https://github.com/denoland/deno), import Ky from a URL. For example, using a CDN:
```js
import ky from 'https://cdn.skypack.dev/ky?dts';
```
## API
### ky(input, options?)
The `input` and `options` are the same as [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch), with some exceptions:
- The `credentials` option is `same-origin` by default, which is the default in the spec too, but not all browsers have caught up yet.
- Adds some more options. See below.
Returns a [`Response` object](https://developer.mozilla.org/en-US/docs/Web/API/Response) with [`Body` methods](https://developer.mozilla.org/en-US/docs/Web/API/Body#Methods) added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if the response status is `204` instead of throwing a parse error due to an empty body.
### ky.get(input, options?)
### ky.post(input, options?)
### ky.put(input, options?)
### ky.patch(input, options?)
### ky.head(input, options?)
### ky.delete(input, options?)
Sets `options.method` to the method name and makes a request.
When using a `Request` instance as `input`, any URL altering options (such as `prefixUrl`) will be ignored.
#### options
Type: `object`
##### method
Type: `string`\
Default: `'get'`
HTTP method used to make the request.
Internally, the standard methods (`GET`, `POST`, `PUT`, `PATCH`, `HEAD` and `DELETE`) are uppercased in order to avoid server errors due to case sensitivity.
##### json
Type: `object` and any other value accepted by [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
Shortcut for sending JSON. Use this instead of the `body` option. Accepts any plain object or value, which will be `JSON.stringify()`'d and sent in the body with the correct header set.
##### searchParams
Type: `string | object<string, string | number | boolean> | Array<Array<string | number | boolean>> | URLSearchParams`\
Default: `''`
Search parameters to include in the request URL. Setting this will override all existing search parameters in the input URL.
Accepts any value supported by [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams).
##### prefixUrl
Type: `string | URL`
A prefix to prepend to the `input` URL when making the request. It can be any valid URL, either relative or absolute. A trailing slash `/` is optional and will be added automatically, if needed, when it is joined with `input`. Only takes effect when `input` is a string. The `input` argument cannot start with a slash `/` when using this option.
Useful when used with [`ky.extend()`](#kyextenddefaultoptions) to create niche-specific Ky-instances.
```js
import ky from 'ky';
// On https://example.com
const response = await ky('unicorn', {prefixUrl: '/api'});
//=> 'https://example.com/api/unicorn'
const response2 = await ky('unicorn', {prefixUrl: 'https://cats.com'});
//=> 'https://cats.com/unicorn'
```
Notes:
- After `prefixUrl` and `input` are joined, the result is resolved against the [base URL](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI) of the page (if any).
- Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion about how the `input` URL is handled, given that `input` will not follow the normal URL resolution rules when `prefixUrl` is being used, which changes the meaning of a leading slash.
##### retry
Type: `object | number`\
Default:
- `limit`: `2`
- `methods`: `get` `put` `head` `delete` `options` `trace`
- `statusCodes`: [`408`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) [`413`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413) [`429`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) [`500`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) [`502`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) [`503`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) [`504`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504)
- `maxRetryAfter`: `undefined`
An object representing `limit`, `methods`, `statusCodes` and `maxRetryAfter` fields for maximum retry count, allowed methods, allowed status codes and maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time.
If `retry` is a number, it will be used as `limit` and other defaults will remain in place.
If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`. If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
Delays between retries is calculated with the function `0.3 * (2 ** (retry - 1)) * 1000`, where `retry` is the attempt number (starts from 1).
Retries are not triggered following a [timeout](#timeout).
```js
import ky from 'ky';
const json = await ky('https://example.com', {
retry: {
limit: 10,
methods: ['get'],
statusCodes: [413]
}
}).json();
```
##### timeout
Type: `number | false`\
Default: `10000`
Timeout in milliseconds for getting a response, including any retries. Can not be greater than 2147483647.
If set to `false`, there will be no timeout.
##### hooks
Type: `object<string, Function[]>`\
Default: `{beforeRequest: [], beforeRetry: [], afterResponse: []}`
Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.
###### hooks.beforeRequest
Type: `Function[]`\
Default: `[]`
This hook enables you to modify the request right before it is sent. Ky will make no further changes to the request after this. The hook function receives `request` and `options` as arguments. You could, for example, modify the `request.headers` here.
The hook can return a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) to replace the outgoing request, or return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) to completely avoid making an HTTP request. This can be used to mock a request, check an internal cache, etc. An **important** consideration when returning a request or response from this hook is that any remaining `beforeRequest` hooks will be skipped, so you may want to only return them from the last hook.
```js
import ky from 'ky';
const api = ky.extend({
hooks: {
beforeRequest: [
request => {
request.headers.set('X-Requested-With', 'ky');
}
]
}
});
const response = await api.get('https://example.com/api/users');
```
###### hooks.beforeRetry
Type: `Function[]`\
Default: `[]`
This hook enables you to modify the request right before retry. Ky will make no further changes to the request after this. The hook function receives an object with the normalized request and options, an error instance, and the retry count. You could, for example, modify `request.headers` here.
If the request received a response, the error will be of type `HTTPError` and the `Response` object will be available at `error.response`. Be aware that some types of errors, such as network errors, inherently mean that a response was not received. In that case, the error will not be an instance of `HTTPError`.
You can prevent Ky from retrying the request by throwing an error. Ky will not handle it in any way and the error will be propagated to the request initiator. The rest of the `beforeRetry` hooks will not be called in this case. Alternatively, you can return the [`ky.stop`](#kystop) symbol to do the same thing but without propagating an error (this has some limitations, see `ky.stop` docs for details).
```js
import ky from 'ky';
const response = await ky('https://example.com', {
hooks: {
beforeRetry: [
async ({request, options, error, retryCount}) => {
const token = await ky('https://example.com/refresh-token');
request.headers.set('Authorization', `token ${token}`);
}
]
}
});
```
###### hooks.beforeError
Type: `Function[]`\
Default: `[]`
This hook enables you to modify the `HTTPError` right before it is thrown. The hook function receives a `HTTPError` as an argument and should return an instance of `HTTPError`.
```js
import ky from 'ky';
await ky('https://example.com', {
hooks: {
beforeError: [
error => {
const {response} = error;
if (response && response.body) {
error.name = 'GitHubError';
error.message = `${response.body.message} (${response.statusCode})`;
}
return error;
}
]
}
});
```
###### hooks.afterResponse
Type: `Function[]`\
Default: `[]`
This hook enables you to read and optionally modify the response. The hook function receives normalized request, options, and a clone of the response as arguments. The return value of the hook function will be used by Ky as the response object if it's an instance of [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
```js
import ky from 'ky';
const response = await ky('https://example.com', {
hooks: {
afterResponse: [
(_request, _options, response) => {
// You could do something with the response, for example, logging.
log(response);
// Or return a `Response` instance to overwrite the response.
return new Response('A different response', {status: 200});
},
// Or retry with a fresh token on a 403 error
async (request, options, response) => {
if (response.status === 403) {
// Get a fresh token
const token = await ky('https://example.com/token').text();
// Retry with the token
request.headers.set('Authorization', `token ${token}`);
return ky(request);
}
}
]
}
});
```
##### throwHttpErrors
Type: `boolean`\
Default: `true`
Throw an `HTTPError` when, after following redirects, the response has a non-2xx status code. To also throw for redirects instead of following them, set the [`redirect`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) option to `'manual'`.
Setting this to `false` may be useful if you are checking for resource availability and are expecting error responses.
Note: If `false`, error responses are considered successful and the request will not be retried.
##### onDownloadProgress
Type: `Function`
Download progress event handler.
The function receives a `progress` and `chunk` argument:
- The `progress` object contains the following elements: `percent`, `transferredBytes` and `totalBytes`. If it's not possible to retrieve the body size, `totalBytes` will be `0`.
- The `chunk` argument is an instance of `Uint8Array`. It's empty for the first call.
```js
import ky from 'ky';
const response = await ky('https://example.com', {
onDownloadProgress: (progress, chunk) => {
// Example output:
// `0% - 0 of 1271 bytes`
// `100% - 1271 of 1271 bytes`
console.log(`${progress.percent * 100}% - ${progress.transferredBytes} of ${progress.totalBytes} bytes`);
}
});
```
##### parseJson
Type: `Function`\
Default: `JSON.parse()`
User-defined JSON-parsing function.
Use-cases:
1. Parse JSON via the [`bourne` package](https://github.com/hapijs/bourne) to protect from prototype pollution.
2. Parse JSON with [`reviver` option of `JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
```js
import ky from 'ky';
import bourne from '@hapijs/bourne';
const json = await ky('https://example.com', {
parseJson: text => bourne(text)
}).json();
```
##### fetch
Type: `Function`\
Default: `fetch`
User-defined `fetch` function.
Has to be fully compatible with the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) standard.
Use-cases:
1. Use custom `fetch` implementations like [`isomorphic-unfetch`](https://www.npmjs.com/package/isomorphic-unfetch).
2. Use the `fetch` wrapper function provided by some frameworks that use server-side rendering (SSR).
```js
import ky from 'ky';
import fetch from 'isomorphic-unfetch';
const json = await ky('https://example.com', {fetch}).json();
```
### ky.extend(defaultOptions)
Create a new `ky` instance with some defaults overridden with your own.
In contrast to `ky.create()`, `ky.extend()` inherits defaults from its parent.
You can pass headers as a `Headers` instance or a plain object.
You can remove a header with `.extend()` by passing the header with an `undefined` value.
Passing `undefined` as a string removes the header only if it comes from a `Headers` instance.
```js
import ky from 'ky';
const url = 'https://sindresorhus.com';
const original = ky.create({
headers: {
rainbow: 'rainbow',
unicorn: 'unicorn'
}
});
const extended = original.extend({
headers: {
rainbow: undefined
}
});
const response = await extended(url).json();
console.log('rainbow' in response);
//=> false
console.log('unicorn' in response);
//=> true
```
### ky.create(defaultOptions)
Create a new Ky instance with complete new defaults.
```js
import ky from 'ky';
// On https://my-site.com
const api = ky.create({prefixUrl: 'https://example.com/api'});
const response = await api.get('users/123');
//=> 'https://example.com/api/users/123'
const response = await api.get('/status', {prefixUrl: ''});
//=> 'https://my-site.com/status'
```
#### defaultOptions
Type: `object`
### ky.stop
A `Symbol` that can be returned by a `beforeRetry` hook to stop the retry. This will also short circuit the remaining `beforeRetry` hooks.
Note: Returning this symbol makes Ky abort and return with an `undefined` response. Be sure to check for a response before accessing any properties on it or use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining). It is also incompatible with body methods, such as `.json()` or `.text()`, because there is no response to parse. In general, we recommend throwing an error instead of returning this symbol, as that will cause Ky to abort and then throw, which avoids these limitations.
A valid use-case for `ky.stop` is to prevent retries when making requests for side effects, where the returned data is not important. For example, logging client activity to the server.
```js
import ky from 'ky';
const options = {
hooks: {
beforeRetry: [
async ({request, options, error, retryCount}) => {
const shouldStopRetry = await ky('https://example.com/api');
if (shouldStopRetry) {
return ky.stop;
}
}
]
}
};
// Note that response will be `undefined` in case `ky.stop` is returned.
const response = await ky.post('https://example.com', options);
// Using `.text()` or other body methods is not supported.
const text = await ky('https://example.com', options).text();
```
### HTTPError
Exposed for `instanceof` checks. The error has a `response` property with the [`Response` object](https://developer.mozilla.org/en-US/docs/Web/API/Response), `request` property with the [`Request` object](https://developer.mozilla.org/en-US/docs/Web/API/Request), and `options` property with normalized options (either passed to `ky` when creating an instance with `ky.create()` or directly when performing the request).
### TimeoutError
The error thrown when the request times out. It has a `request` property with the [`Request` object](https://developer.mozilla.org/en-US/docs/Web/API/Request).
## Tips
### Sending form data
Sending form data in Ky is identical to `fetch`. Just pass a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) instance to the `body` option. The `Content-Type` header will be automatically set to `multipart/form-data`.
```js
import ky from 'ky';
// `multipart/form-data`
const formData = new FormData();
formData.append('food', 'fries');
formData.append('drink', 'icetea');
const response = await ky.post(url, {body: formData});
```
If you want to send the data in `application/x-www-form-urlencoded` format, you will need to encode the data with [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
```js
import ky from 'ky';
// `application/x-www-form-urlencoded`
const searchParams = new URLSearchParams();
searchParams.set('food', 'fries');
searchParams.set('drink', 'icetea');
const response = await ky.post(url, {body: searchParams});
```
### Setting a custom `Content-Type`
Ky automatically sets an appropriate [`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) header for each request based on the data in the request body. However, some APIs require custom, non-standard content types, such as `application/x-amz-json-1.1`. Using the `headers` option, you can manually override the content type.
```js
import ky from 'ky';
const json = await ky.post('https://example.com', {
headers: {
'content-type': 'application/json'
}
json: {
foo: true
},
}).json();
console.log(json);
//=> `{data: '🦄'}`
```
### Cancellation
Fetch (and hence Ky) has built-in support for request cancellation through the [`AbortController` API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). [Read more.](https://developers.google.com/web/updates/2017/09/abortable-fetch)
Example:
```js
import ky from 'ky';
const controller = new AbortController();
const {signal} = controller;
setTimeout(() => {
controller.abort();
}, 5000);
try {
console.log(await ky(url, {signal}).text());
} catch (error) {
if (error.name === 'AbortError') {
console.log('Fetch aborted');
} else {
console.error('Fetch error:', error);
}
}
```
## FAQ
#### How do I use this in Node.js?
Check out [`ky-universal`](https://github.com/sindresorhus/ky-universal#faq).
#### How do I use this with a web app (React, Vue.js, etc.) that uses server-side rendering (SSR)?
Check out [`ky-universal`](https://github.com/sindresorhus/ky-universal#faq).
#### How do I test a browser library that uses this?
Either use a test runner that can run in the browser, like Mocha, or use [AVA](https://avajs.dev) with `ky-universal`. [Read more.](https://github.com/sindresorhus/ky-universal#faq)
#### How do I use this without a bundler like Webpack?
Make sure your code is running as a JavaScript module (ESM), for example by using a `<script type="module">` tag in your HTML document. Then Ky can be imported directly by that module without a bundler or other tools.
```html
<script type="module">
import ky from 'https://unpkg.com/ky/distribution/index.js';
const json = await ky('https://jsonplaceholder.typicode.com/todos/1').json();
console.log(json.title);
//=> 'delectus aut autem
</script>
```
#### How is it different from [`got`](https://github.com/sindresorhus/got)
See my answer [here](https://twitter.com/sindresorhus/status/1037406558945042432). Got is maintained by the same people as Ky.
#### How is it different from [`axios`](https://github.com/axios/axios)?
See my answer [here](https://twitter.com/sindresorhus/status/1037763588826398720).
#### How is it different from [`r2`](https://github.com/mikeal/r2)?
See my answer in [#10](https://github.com/sindresorhus/ky/issues/10).
#### What does `ky` mean?
It's just a random short npm package name I managed to get. It does, however, have a meaning in Japanese:
> A form of text-able slang, KY is an abbreviation for 空気読めない (kuuki yomenai), which literally translates into “cannot read the air.” It's a phrase applied to someone who misses the implied meaning.
## Browser support
The latest version of Chrome, Firefox, and Safari.
## Node.js support
Polyfill the needed browser globals or just use [`ky-universal`](https://github.com/sindresorhus/ky-universal).
## Related
- [ky-universal](https://github.com/sindresorhus/ky-universal) - Use Ky in both Node.js and browsers
- [got](https://github.com/sindresorhus/got) - Simplified HTTP requests for Node.js
- [ky-hooks-change-case](https://github.com/alice-health/ky-hooks-change-case) - Ky hooks to modify cases on requests and responses of objects
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Szymon Marczak](https://github.com/szmarczak)
- [Seth Holladay](https://github.com/sholladay)