1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-24 01:43:18 +00:00
musix-oss/node_modules/core-js/modules/esnext.reflect.get-metadata-keys.js

34 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-03-03 20:30:50 +00:00
var $ = require('../internals/export');
// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
var Set = require('../modules/es.set');
var ReflectMetadataModule = require('../internals/reflect-metadata');
var anObject = require('../internals/an-object');
var getPrototypeOf = require('../internals/object-get-prototype-of');
var iterate = require('../internals/iterate');
var ordinaryOwnMetadataKeys = ReflectMetadataModule.keys;
var toMetadataKey = ReflectMetadataModule.toKey;
var from = function (iter) {
var result = [];
iterate(iter, result.push, result);
return result;
};
var ordinaryMetadataKeys = function (O, P) {
var oKeys = ordinaryOwnMetadataKeys(O, P);
var parent = getPrototypeOf(O);
if (parent === null) return oKeys;
var pKeys = ordinaryMetadataKeys(parent, P);
return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;
};
// `Reflect.getMetadataKeys` method
// https://github.com/rbuckton/reflect-metadata
$({ target: 'Reflect', stat: true }, {
getMetadataKeys: function getMetadataKeys(target /* , targetKey */) {
var targetKey = arguments.length < 2 ? undefined : toMetadataKey(arguments[1]);
return ordinaryMetadataKeys(anObject(target), targetKey);
}
});