Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bindHttpMethod.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _http = _interopRequireDefault(require("http"));
  7. var _https = _interopRequireDefault(require("https"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. // eslint-disable-next-line flowtype/no-weak-types
  10. const bindHttpMethod = (originalMethod, agent, forceGlobalAgent) => {
  11. // eslint-disable-next-line unicorn/prevent-abbreviations
  12. return (...args) => {
  13. let url;
  14. let options;
  15. let callback;
  16. if (typeof args[0] === 'string' || args[0] instanceof URL) {
  17. url = args[0];
  18. if (typeof args[1] === 'function') {
  19. options = {};
  20. callback = args[1];
  21. } else {
  22. options = { ...args[1]
  23. };
  24. callback = args[2];
  25. }
  26. } else {
  27. options = { ...args[0]
  28. };
  29. callback = args[1];
  30. }
  31. if (forceGlobalAgent) {
  32. options.agent = agent;
  33. } else {
  34. if (!options.agent) {
  35. options.agent = agent;
  36. }
  37. if (options.agent === _http.default.globalAgent || options.agent === _https.default.globalAgent) {
  38. options.agent = agent;
  39. }
  40. }
  41. if (url) {
  42. // $FlowFixMe
  43. return originalMethod(url, options, callback);
  44. } else {
  45. return originalMethod(options, callback);
  46. }
  47. };
  48. };
  49. var _default = bindHttpMethod;
  50. exports.default = _default;
  51. //# sourceMappingURL=bindHttpMethod.js.map