_interop_require_wildcard.js 1.4 KB

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