PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/babel-polyfill/node_modules/core-js/library/modules/es6.reflect.set.js

https://bitbucket.org/worklabschd/bingle_customer2
JavaScript | 33 lines | 30 code | 2 blank | 1 comment | 10 complexity | 9c62c32677ff88b06492428dfbc39448 MD5 | raw file
 1// 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
 2var dP = require('./_object-dp');
 3var gOPD = require('./_object-gopd');
 4var getPrototypeOf = require('./_object-gpo');
 5var has = require('./_has');
 6var $export = require('./_export');
 7var createDesc = require('./_property-desc');
 8var anObject = require('./_an-object');
 9var isObject = require('./_is-object');
10
11function set(target, propertyKey, V /* , receiver */) {
12  var receiver = arguments.length < 4 ? target : arguments[3];
13  var ownDesc = gOPD.f(anObject(target), propertyKey);
14  var existingDescriptor, proto;
15  if (!ownDesc) {
16    if (isObject(proto = getPrototypeOf(target))) {
17      return set(proto, propertyKey, V, receiver);
18    }
19    ownDesc = createDesc(0);
20  }
21  if (has(ownDesc, 'value')) {
22    if (ownDesc.writable === false || !isObject(receiver)) return false;
23    if (existingDescriptor = gOPD.f(receiver, propertyKey)) {
24      if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
25      existingDescriptor.value = V;
26      dP.f(receiver, propertyKey, existingDescriptor);
27    } else dP.f(receiver, propertyKey, createDesc(0, V));
28    return true;
29  }
30  return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
31}
32
33$export($export.S, 'Reflect', { set: set });