defineProperty.js 476 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var oDP = Object.defineProperty;
  3. try {
  4. oDP({}, 'a', { value: 1 });
  5. } catch (e) {
  6. // IE 8
  7. oDP = null;
  8. }
  9. module.exports = function defineProperty(O, P, Desc) {
  10. if (oDP) {
  11. return oDP(O, P, Desc);
  12. }
  13. if ((Desc.enumerable && Desc.configurable && Desc.writable) || !(P in O)) {
  14. O[P] = Desc.value; // eslint-disable-line no-param-reassign
  15. return O;
  16. }
  17. throw new SyntaxError('helper does not yet support this configuration');
  18. };
  19. module.exports.oDP = oDP;