Commit 0546785c authored by nanahira's avatar nanahira

fix

parent c7e40fb4
......@@ -2,12 +2,22 @@ import 'reflect-metadata';
import { ArrayValue, GenericMap, Key, MapValue, StringDict } from './def';
export class Reflector<M extends StringDict, AM extends StringDict> {
private isClass(target: any) {
if (typeof target !== 'function') {
return false;
}
// eslint-disable-next-line @typescript-eslint/ban-types
return (target as Function).toString().startsWith('class');
}
get<K extends Key<GenericMap<M, AM>>>(
metadataKey: K,
instance: any,
key?: string | symbol,
): MapValue<M, AM, K> {
const instanceClass = instance.constructor;
const instanceClass = this.isClass(instance)
? instance
: instance.constructor;
if (key) {
return Reflect.getMetadata(metadataKey, instanceClass, key);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment