github.com/jfrog/frogbot@v1.1.1-0.20231221090046-821a26f50338/action/node_modules/@octokit/request/dist-src/with-defaults.js (about) 1 import fetchWrapper from "./fetch-wrapper"; 2 export default function withDefaults(oldEndpoint, newDefaults) { 3 const endpoint = oldEndpoint.defaults(newDefaults); 4 const newApi = function (route, parameters) { 5 const endpointOptions = endpoint.merge(route, parameters); 6 if (!endpointOptions.request || !endpointOptions.request.hook) { 7 return fetchWrapper(endpoint.parse(endpointOptions)); 8 } 9 const request = (route, parameters) => { 10 return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters))); 11 }; 12 Object.assign(request, { 13 endpoint, 14 defaults: withDefaults.bind(null, endpoint), 15 }); 16 return endpointOptions.request.hook(request, endpointOptions); 17 }; 18 return Object.assign(newApi, { 19 endpoint, 20 defaults: withDefaults.bind(null, endpoint), 21 }); 22 }