es7.reflect.has-metadata.js 677 B

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