New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@typemon/reflection

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typemon/reflection

Reflection for TypeScript

latest
Source
npmnpm
Version
4.1.0
Version published
Maintainers
1
Created
Source

Reflection - version license typescript-version

  • Parameter metadata management
  • Inheritance support
  • Easy integration with decorators

Installation

$ npm install @typemon/reflection reflect-metadata

TypeScript

{
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
}

Reflect Metadata

  • Import only once at application entry point.
import 'reflect-metadata';

Usage

Reflection

Reflection.hasOwnMetadata(metadataKey, target, propertyKey?): boolean;
Reflection.hasNotOwnMetadata(metadataKey, target, propertyKey?): boolean;
Reflection.hasMetadata(metadataKey, target, propertyKey?): boolean;
Reflection.hasMetadata(metadataKey, target, propertyKey?): boolean;
Reflection.getOwnMetadata(metadataKey, target, propertyKey?): any;
Reflection.getMetadata(metadataKey, target, propertyKey?): any;
Reflection.setMetadata(metadataKey, metadataValue, target, propertyKey?): void;
Reflection.deleteMetadata(metadataKey, target, propertyKey?): void;
Reflection.decorate(decorators, {
    target,
    propertyKey?,
    parameterIndex?
}): void;
Reflection.DefineMetadata(metadataKey, metadataValue): ClassDecorator & PropertyDecorator & MethodDecorator;

Metadata

Metadata.of({
    target,
    propertyKey?,
    parameterIndex?
}): Metadata;
Metadata.hasOwn(metadataKey, {
    target,
    propertyKey?,
    parameterIndex?
}): boolean;
Metadata.hasNotOwn(metadataKey, {
    target,
    propertyKey?,
    parameterIndex?
}): boolean;
Metadata.has(metadataKey, {
    target,
    propertyKey?,
    parameterIndex?
}): boolean;
Metadata.hasNot(metadataKey, {
    target,
    propertyKey?,
    parameterIndex?
}): boolean;
Metadata.getOwn(metadataKey, {
    target,
    propertyKey?,
    parameterIndex?
}): any;
Metadata.get(metadataKey, {
    target,
    propertyKey?,
    parameterIndex?
}): any;
Metadata.set(metadataKey, metadataValue, {
    target,
    propertyKey?,
    parameterIndex?
}): void;
Metadata.delete(metadataKey, {
    target,
    propertyKey?,
    parameterIndex?
}): void;

Metadata Decorator

You can easily set metadata using the Metadata.Define decorator.

@Metadata.Define(metadataKey, metadataValue)
class Target {
    @Metadata.Define(metadataKey, metadataValue)
    public static staticProperty: unknown;

    @Metadata.Define(metadataKey, metadataValue)
    public static staticMethod(
        @Metadata.Define(metadataKey, metadataValue)
        staticMethodParameter: unknown
    ): void { }

    @Metadata.Define(metadataKey, metadataValue)
    public instanceProperty: unknown;

    public constructor(
        @Metadata.Define(metadataKey, metadataValue)
        constructorParameter: unknown
    ) { }

    @Metadata.Define(metadataKey, metadataValue)
    public instanceMethod(
        @Metadata.Define(metadataKey, metadataValue)
        instanceMethodParameter: unknown
    ): void { }
}

You can create and use custom decorators as needed.

function CustomDecorator(): Metadata.Decorator {
    return Metadata.Decorator.create((metadata: Metadata): void => {
        . . .
    });
}

Keywords

monster-space-network

FAQs

Package last updated on 18 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts