UNPKG

@noxfly/noxus

Version:

Simulate lightweight HTTP-like requests between renderer and main process in Electron applications with MessagePort, with structured and modular design.

25 lines (21 loc) 793 B
/** * @copyright 2025 NoxFly * @license MIT * @author NoxFly */ import 'reflect-metadata'; export const INJECT_METADATA_KEY = 'custom:inject'; /** * Decorator to manually inject a dependency. * Useful for handling circular dependencies with `forwardRef` or injecting specific tokens. * * @param token The token or forward reference to inject. */ export function Inject(token: any): ParameterDecorator { return (target, propertyKey, parameterIndex) => { // target is the constructor for constructor parameters const existingParameters = Reflect.getOwnMetadata(INJECT_METADATA_KEY, target) || []; existingParameters[parameterIndex] = token; Reflect.defineMetadata(INJECT_METADATA_KEY, existingParameters, target); }; }