UNPKG

1.08 kBJavaScriptView Raw
1/*! MIT License © Sindre Sorhus */
2import { Ky } from './core/Ky.js';
3import { requestMethods, stop } from './core/constants.js';
4import { validateAndMerge } from './utils/merge.js';
5const createInstance = (defaults) => {
6 // eslint-disable-next-line @typescript-eslint/promise-function-async
7 const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
8 for (const method of requestMethods) {
9 // @ts-expect-error not sure how to properly type this!
10 // eslint-disable-next-line @typescript-eslint/promise-function-async
11 ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
12 }
13 ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
14 ky.extend = (newDefaults) => createInstance(validateAndMerge(defaults, newDefaults));
15 ky.stop = stop;
16 return ky;
17};
18const ky = createInstance();
19export default ky;
20export { HTTPError } from './errors/HTTPError.js';
21export { TimeoutError } from './errors/TimeoutError.js';
22//# sourceMappingURL=index.js.map
\No newline at end of file