UNPKG

abi.js

Version:

[![typescript-icon]][typescript-link] [![license-icon]][license-link] [![status-icon]][status-link] [![ci-icon]][ci-link] [![twitter-icon]][twitter-link]

58 lines (57 loc) 2.36 kB
import 'reflect-metadata'; export declare function reflect<T extends Function | object>(value: T, objectThis?: object): ReflectionObject | ReflectionFunction; export declare class ReflectionError extends Error { } export declare abstract class Reflection<T> { readonly value: T; constructor(value: T); toString(): string; } export declare class ReflectionObject extends Reflection<object> { protected objectThis?: object | undefined; constructor(value: object, objectThis?: object | undefined); toString(): string; } export declare class ReflectionFunction extends Reflection<Function> { #private; protected objectThis?: object | undefined; protected is_arrow: boolean; protected name: string; readonly parameters: ReflectionParameter<any>[]; constructor(value: Function, objectThis?: object | undefined); getParameter<T>(name: string): ReflectionParameter<T> | undefined; hasParameter(name: string): boolean; } export declare class ReflectionParameter<T> extends Reflection<T> { readonly func: ReflectionFunction; readonly name: string; readonly index: number; constructor(func: ReflectionFunction, name: string, index: number, value: T); getFunction(): ReflectionFunction; hasDefaultValue(): boolean; getDefaultValue(): ReflectionParameterValue<T>; } export declare class ReflectionValue<T> extends Reflection<T> { get type(): string; } export declare class ReflectionParameterValue<T> extends ReflectionValue<T> { protected param: ReflectionParameter<T>; constructor(param: ReflectionParameter<T>, value: T); getParameter(): ReflectionParameter<T>; } export declare class ReflectionReturnValue<T> extends ReflectionValue<T> { protected func: ReflectionFunction; constructor(func: ReflectionFunction, value: T); getFunction(): ReflectionFunction; } export type Context = Record<string, any>; export declare class Container { protected context: Context; constructor(context: Context); call<T>(callback: Function, context?: Context): T; getArgs(callback: Function, context?: Context): any[]; get<T extends unknown | undefined>(id: string, defaultValue?: T, context?: Context): T; make<T>(value: T, context?: Context): T; mergeContext(context: Context): Context; } export default function (context: Context): Container;