Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
908 bytes
|
Line | |
---|
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;
|
---|
31 | module.exports["default"] = module.exports, module.exports.__esModule = true; |
---|
Note:
See
TracBrowser
for help on using the repository browser.