Projekt

Obecné

Profil

Stáhnout (830 Bajtů) Statistiky
| Větev: | Revize:
1
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
2
  var desc = {};
3
  Object.keys(descriptor).forEach(function (key) {
4
    desc[key] = descriptor[key];
5
  });
6
  desc.enumerable = !!desc.enumerable;
7
  desc.configurable = !!desc.configurable;
8

    
9
  if ('value' in desc || desc.initializer) {
10
    desc.writable = true;
11
  }
12

    
13
  desc = decorators.slice().reverse().reduce(function (desc, decorator) {
14
    return decorator(target, property, desc) || desc;
15
  }, desc);
16

    
17
  if (context && desc.initializer !== void 0) {
18
    desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
19
    desc.initializer = undefined;
20
  }
21

    
22
  if (desc.initializer === void 0) {
23
    Object.defineProperty(target, property, desc);
24
    desc = null;
25
  }
26

    
27
  return desc;
28
}
29

    
30
module.exports = _applyDecoratedDescriptor;
(3-3/80)