Reflect 元数据
小于 1 分钟
Reflect
元数据
模块
esnext.reflect.define-metadata
esnext.reflect.delete-metadata
esnext.reflect.get-metadata
esnext.reflect.get-metadata-keys
esnext.reflect.get-own-metadata
esnext.reflect.get-own-metadata-keys
esnext.reflect.has-metadata
esnext.reflect.has-own-metadata
esnext.reflect.metadata
类型
namespace Reflect {
function defineMetadata(
metadataKey: any,
metadataValue: any,
target: Object,
propertyKey?: PropertyKey
): void;
function getMetadata(
metadataKey: any,
target: Object,
propertyKey?: PropertyKey
): any;
function getOwnMetadata(
metadataKey: any,
target: Object,
propertyKey?: PropertyKey
): any;
function hasMetadata(
metadataKey: any,
target: Object,
propertyKey?: PropertyKey
): boolean;
function hasOwnMetadata(
metadataKey: any,
target: Object,
propertyKey?: PropertyKey
): boolean;
function deleteMetadata(
metadataKey: any,
target: Object,
propertyKey?: PropertyKey
): boolean;
function getMetadataKeys(
target: Object,
propertyKey?: PropertyKey
): Array<any>;
function getOwnMetadataKeys(
target: Object,
propertyKey?: PropertyKey
): Array<any>;
function metadata(
metadataKey: any,
metadataValue: any
): (target: Object, targetKey: string | symbol) => void;
}
入口点
core-js/proposals/reflect-metadata
core-js(-pure)/full/reflect/define-metadata
core-js(-pure)/full/reflect/delete-metadata
core-js(-pure)/full/reflect/get-metadata
core-js(-pure)/full/reflect/get-metadata-keys
core-js(-pure)/full/reflect/get-own-metadata
core-js(-pure)/full/reflect/get-own-metadata-keys
core-js(-pure)/full/reflect/has-metadata
core-js(-pure)/full/reflect/has-own-metadata
core-js(-pure)/full/reflect/metadata
示例
示例:
let object = {};
Reflect.defineMetadata("foo", "bar", object);
Reflect.ownKeys(object); // => []
Reflect.getOwnMetadataKeys(object); // => ['foo']
Reflect.getOwnMetadata("foo", object); // => 'bar'