classPrivateFieldSet.js 503 B

123456789101112131415161718192021
  1. function _classPrivateFieldSet(receiver, privateMap, value) {
  2. if (!privateMap.has(receiver)) {
  3. throw new TypeError("attempted to set private field on non-instance");
  4. }
  5. var descriptor = privateMap.get(receiver);
  6. if (descriptor.set) {
  7. descriptor.set.call(receiver, value);
  8. } else {
  9. if (!descriptor.writable) {
  10. throw new TypeError("attempted to set read only private field");
  11. }
  12. descriptor.value = value;
  13. }
  14. return value;
  15. }
  16. module.exports = _classPrivateFieldSet;