1 | var $ = require('../internals/export');
|
---|
2 | var ReflectMetadataModule = require('../internals/reflect-metadata');
|
---|
3 | var anObject = require('../internals/an-object');
|
---|
4 | var getPrototypeOf = require('../internals/object-get-prototype-of');
|
---|
5 |
|
---|
6 | var ordinaryHasOwnMetadata = ReflectMetadataModule.has;
|
---|
7 | var ordinaryGetOwnMetadata = ReflectMetadataModule.get;
|
---|
8 | var toMetadataKey = ReflectMetadataModule.toKey;
|
---|
9 |
|
---|
10 | var ordinaryGetMetadata = function (MetadataKey, O, P) {
|
---|
11 | var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
|
---|
12 | if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P);
|
---|
13 | var parent = getPrototypeOf(O);
|
---|
14 | return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
|
---|
15 | };
|
---|
16 |
|
---|
17 | // `Reflect.getMetadata` method
|
---|
18 | // https://github.com/rbuckton/reflect-metadata
|
---|
19 | $({ target: 'Reflect', stat: true }, {
|
---|
20 | getMetadata: function getMetadata(metadataKey, target /* , targetKey */) {
|
---|
21 | var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);
|
---|
22 | return ordinaryGetMetadata(metadataKey, anObject(target), targetKey);
|
---|
23 | }
|
---|
24 | });
|
---|