UNPKG

1.02 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 // eslint-disable-next-line @typescript-eslint/promise-function-async
10 ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
11 }
12 ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
13 ky.extend = (newDefaults) => createInstance(validateAndMerge(defaults, newDefaults));
14 ky.stop = stop;
15 return ky;
16};
17const ky = createInstance();
18export default ky;
19export { HTTPError } from './errors/HTTPError.js';
20export { TimeoutError } from './errors/TimeoutError.js';
21//# sourceMappingURL=index.js.map
\No newline at end of file