Skip to main content
Module

x/momentum/di/shims/reflect.ts>Reflect.hasMetadata

Momentum is an open-source framework for building server-side Deno applications in TypeScript. It provides the paradigms and design patterns to guide developers to create robust, scalable, and enterprise-grade applications.
Latest
function Reflect.hasMetadata
import { Reflect } from "https://deno.land/x/momentum@v0.8.2/di/shims/reflect.ts";
const { hasMetadata } = Reflect;

Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.

Examples

class Example { }

// constructor result = Reflect.hasMetadata("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

boolean

true if the metadata key was defined on the target object or its prototype chain; otherwise, false.

Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.

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.hasMetadata("custom:annotation", Example, "staticProperty");

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

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

// method (on prototype)
result = Reflect.hasMetadata("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

boolean

true if the metadata key was defined on the target object or its prototype chain; otherwise, false.