es7.reflect.get-metadata.js 761 B

1234567891011121314151617
  1. var metadata = require('./_metadata');
  2. var anObject = require('./_an-object');
  3. var getPrototypeOf = require('./_object-gpo');
  4. var ordinaryHasOwnMetadata = metadata.has;
  5. var ordinaryGetOwnMetadata = metadata.get;
  6. var toMetaKey = metadata.key;
  7. var ordinaryGetMetadata = function (MetadataKey, O, P) {
  8. var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
  9. if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P);
  10. var parent = getPrototypeOf(O);
  11. return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
  12. };
  13. metadata.exp({ getMetadata: function getMetadata(metadataKey, target /* , targetKey */) {
  14. return ordinaryGetMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  15. } });