defineEnumerableProperties.js 649 B

12345678910111213141516171819202122
  1. export default function _defineEnumerableProperties(obj, descs) {
  2. for (var key in descs) {
  3. var desc = descs[key];
  4. desc.configurable = desc.enumerable = true;
  5. if ("value" in desc) desc.writable = true;
  6. Object.defineProperty(obj, key, desc);
  7. }
  8. if (Object.getOwnPropertySymbols) {
  9. var objectSymbols = Object.getOwnPropertySymbols(descs);
  10. for (var i = 0; i < objectSymbols.length; i++) {
  11. var sym = objectSymbols[i];
  12. var desc = descs[sym];
  13. desc.configurable = desc.enumerable = true;
  14. if ("value" in desc) desc.writable = true;
  15. Object.defineProperty(obj, sym, desc);
  16. }
  17. }
  18. return obj;
  19. }