es7.reflect.get-metadata-keys.js 783 B

12345678910111213141516171819
  1. var Set = require('./es6.set');
  2. var from = require('./_array-from-iterable');
  3. var metadata = require('./_metadata');
  4. var anObject = require('./_an-object');
  5. var getPrototypeOf = require('./_object-gpo');
  6. var ordinaryOwnMetadataKeys = metadata.keys;
  7. var toMetaKey = metadata.key;
  8. var ordinaryMetadataKeys = function (O, P) {
  9. var oKeys = ordinaryOwnMetadataKeys(O, P);
  10. var parent = getPrototypeOf(O);
  11. if (parent === null) return oKeys;
  12. var pKeys = ordinaryMetadataKeys(parent, P);
  13. return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;
  14. };
  15. metadata.exp({ getMetadataKeys: function getMetadataKeys(target /* , targetKey */) {
  16. return ordinaryMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
  17. } });