esnext.reflect.has-metadata.js 1006 B

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