You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1.0 KiB
25 lines
1.0 KiB
3 years ago
|
var $ = require('../internals/export');
|
||
|
var ReflectMetadataModule = require('../internals/reflect-metadata');
|
||
|
var anObject = require('../internals/an-object');
|
||
|
var getPrototypeOf = require('../internals/object-get-prototype-of');
|
||
|
|
||
|
var ordinaryHasOwnMetadata = ReflectMetadataModule.has;
|
||
|
var ordinaryGetOwnMetadata = ReflectMetadataModule.get;
|
||
|
var toMetadataKey = ReflectMetadataModule.toKey;
|
||
|
|
||
|
var ordinaryGetMetadata = function (MetadataKey, O, P) {
|
||
|
var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
|
||
|
if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P);
|
||
|
var parent = getPrototypeOf(O);
|
||
|
return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
|
||
|
};
|
||
|
|
||
|
// `Reflect.getMetadata` method
|
||
|
// https://github.com/rbuckton/reflect-metadata
|
||
|
$({ target: 'Reflect', stat: true }, {
|
||
|
getMetadata: function getMetadata(metadataKey, target /* , targetKey */) {
|
||
|
var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);
|
||
|
return ordinaryGetMetadata(metadataKey, anObject(target), targetKey);
|
||
|
}
|
||
|
});
|