esnext.reflect.has-metadata.js 992 B

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