Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/alosaur/src/injection/reflect.ts>Reflect.getOwnMetadata

Alosaur - Deno web framework with many decorators
Very Popular
Go to Latest
function Reflect.getOwnMetadata
import { Reflect } from "https://deno.land/x/alosaur@v0.35.0/src/injection/reflect.ts";
const { getOwnMetadata } = Reflect;

Gets the metadata value for the provided metadata key on the target object.

Examples

class Example { }

// constructor result = Reflect.getOwnMetadata("custom:annotation", Example);

Parameters

metadataKey: any

A key used to store and retrieve metadata.

target: any

The target object on which the metadata is defined.

Returns

any

The metadata value for the metadata key if found; otherwise, undefined.

Gets the metadata value for the provided metadata key on the target object.

Examples

class Example { // property declarations are not part of ES6, though they are valid in TypeScript: // static staticProperty; // property;

static staticMethod(p) { } method(p) { } }

// property (on constructor)
result = Reflect.getOwnMetadata("custom:annotation", Example, "staticProperty");

// property (on prototype)
result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "property");

// method (on constructor)
result = Reflect.getOwnMetadata("custom:annotation", Example, "staticMethod");

// method (on prototype)
result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "method");

Parameters

metadataKey: any

A key used to store and retrieve metadata.

target: any

The target object on which the metadata is defined.

propertyKey: string | symbol

The property key for the target.

Returns

any

The metadata value for the metadata key if found; otherwise, undefined.