This repository has been archived on 2023-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
current-kwh-cost/node_modules/axios/lib/adapters/index.js

34 lines
728 B
JavaScript
Raw Normal View History

2022-11-17 16:42:35 +00:00
import utils from '../utils.js';
import httpAdapter from './http.js';
import xhrAdapter from './xhr.js';
const adapters = {
http: httpAdapter,
xhr: xhrAdapter
}
export default {
getAdapter: (nameOrAdapter) => {
if(utils.isString(nameOrAdapter)){
const adapter = adapters[nameOrAdapter];
if (!nameOrAdapter) {
throw Error(
utils.hasOwnProp(nameOrAdapter) ?
`Adapter '${nameOrAdapter}' is not available in the build` :
`Can not resolve adapter '${nameOrAdapter}'`
);
}
return adapter
}
if (!utils.isFunction(nameOrAdapter)) {
throw new TypeError('adapter is not a function');
}
return nameOrAdapter;
},
adapters
}