defineProperty.js 344 B

123456789101112131415
  1. import toPropertyKey from "./toPropertyKey.js";
  2. export default function _defineProperty(obj, key, value) {
  3. key = toPropertyKey(key);
  4. if (key in obj) {
  5. Object.defineProperty(obj, key, {
  6. value: value,
  7. enumerable: true,
  8. configurable: true,
  9. writable: true
  10. });
  11. } else {
  12. obj[key] = value;
  13. }
  14. return obj;
  15. }