Skip to content

Commit

Permalink
feat(util): add isInjectable util function (#41)
Browse files Browse the repository at this point in the history
* feat(util): add isInjectable util function

* fix(util): use hasOwnMetadata instead
  • Loading branch information
noahziheng authored Jul 29, 2022
1 parent 09e2d96 commit 4a982f5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReflectMetadataType } from './types';
import { CLASS_TAG } from './constant';
import { CLASS_CONSTRUCTOR, CLASS_TAG } from './constant';
const functionPrototype = Object.getPrototypeOf(Function);

export function getMetadata(
Expand Down Expand Up @@ -83,6 +83,10 @@ export function addTag(tag: string, target: any) {
tags.push(tag);
}

export function isInjectable(target: any) {
return Reflect.hasOwnMetadata(CLASS_CONSTRUCTOR, target);
}

export function isClass(clazz: any) {
if (typeof clazz !== 'function') {
return false;
Expand Down

0 comments on commit 4a982f5

Please sign in to comment.