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.

52 lines
1.1 KiB

4 years ago
  1. import _typeof from "../../helpers/esm/typeof";
  2. function _getRequireWildcardCache() {
  3. if (typeof WeakMap !== "function") return null;
  4. var cache = new WeakMap();
  5. _getRequireWildcardCache = function _getRequireWildcardCache() {
  6. return cache;
  7. };
  8. return cache;
  9. }
  10. export default function _interopRequireWildcard(obj) {
  11. if (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();
  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 (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. }