interopRequireWildcard.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import _typeof from "@babel/runtime-corejs3/helpers/typeof";
  2. import _WeakMap from "@babel/runtime-corejs3/core-js/weak-map";
  3. import _Object$defineProperty from "@babel/runtime-corejs3/core-js/object/define-property";
  4. import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptor";
  5. function _getRequireWildcardCache(nodeInterop) {
  6. if (typeof _WeakMap !== "function") return null;
  7. var cacheBabelInterop = new _WeakMap();
  8. var cacheNodeInterop = new _WeakMap();
  9. return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
  10. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  11. })(nodeInterop);
  12. }
  13. export default function _interopRequireWildcard(obj, nodeInterop) {
  14. if (!nodeInterop && obj && obj.__esModule) {
  15. return obj;
  16. }
  17. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  18. return {
  19. "default": obj
  20. };
  21. }
  22. var cache = _getRequireWildcardCache(nodeInterop);
  23. if (cache && cache.has(obj)) {
  24. return cache.get(obj);
  25. }
  26. var newObj = {};
  27. var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor;
  28. for (var key in obj) {
  29. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  30. var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  31. if (desc && (desc.get || desc.set)) {
  32. _Object$defineProperty(newObj, key, desc);
  33. } else {
  34. newObj[key] = obj[key];
  35. }
  36. }
  37. }
  38. newObj["default"] = obj;
  39. if (cache) {
  40. cache.set(obj, newObj);
  41. }
  42. return newObj;
  43. }