1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-14 03:30:18 +00:00
musix-oss/node_modules/snekfetch/test/interop.js
MatteZ02 5eb0264906 fix
2019-05-30 12:06:47 +03:00

23 lines
581 B
JavaScript

function makeProxy(fetch) {
return new Proxy(fetch, {
get(target, prop) {
const p = target[prop];
if (typeof p === 'function') {
return (url, options = {}) =>
p.call(target, url, Object.assign(options, { version: global.HTTP_VERSION }));
}
return p;
},
});
}
exports.Snekfetch = makeProxy(require('../'));
try {
exports.SnekfetchSync = makeProxy(require('../sync'));
} catch (err) {} // eslint-disable-line no-empty
exports.TestRoot = global.HTTP_VERSION === 2 ?
'https://nghttp2.org/httpbin' :
'https://httpbin.org';