diff options
Diffstat (limited to 'node_modules/snekfetch/test/interop.js')
| -rw-r--r-- | node_modules/snekfetch/test/interop.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/node_modules/snekfetch/test/interop.js b/node_modules/snekfetch/test/interop.js new file mode 100644 index 0000000..d63ff10 --- /dev/null +++ b/node_modules/snekfetch/test/interop.js @@ -0,0 +1,22 @@ +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'; + |