interopRequireWildcard.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var _typeof = require("@babel/runtime/helpers/typeof")["default"];
  2. function _getRequireWildcardCache(nodeInterop) {
  3. if (typeof WeakMap !== "function") return null;
  4. var cacheBabelInterop = new WeakMap();
  5. var cacheNodeInterop = new WeakMap();
  6. return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
  7. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  8. })(nodeInterop);
  9. }
  10. function _interopRequireWildcard(obj, nodeInterop) {
  11. if (!nodeInterop && obj && obj.__esModule) {
  12. return obj;
  13. }
  14. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  15. return {
  16. "default": obj
  17. };
  18. }
  19. var cache = _getRequireWildcardCache(nodeInterop);
  20. if (cache && cache.has(obj)) {
  21. return cache.get(obj);
  22. }
  23. var newObj = {};
  24. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  25. for (var key in obj) {
  26. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  27. var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
  28. if (desc && (desc.get || desc.set)) {
  29. Object.defineProperty(newObj, key, desc);
  30. } else {
  31. newObj[key] = obj[key];
  32. }
  33. }
  34. }
  35. newObj["default"] = obj;
  36. if (cache) {
  37. cache.set(obj, newObj);
  38. }
  39. return newObj;
  40. }
  41. module.exports = _interopRequireWildcard, module.exports.__esModule = true, module.exports["default"] = module.exports;