Skip to content

Commit

Permalink
fix: registry
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Oct 15, 2024
1 parent 43b7949 commit f849531
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,28 @@ export class Registry {
get<T>(token: InjectionToken<T>): Registration<T> | undefined {
return (
internals.get(token)
|| this.map.get(token)
|| this.parent?.map.get(token)
|| this.getRecursive(token)
);
}

private getRecursive<T>(token: InjectionToken<T>): Registration<T> | undefined {
return (
this.map.get(token)
|| this.parent?.getRecursive(token)
);
}

has(token: InjectionToken): boolean {
return Boolean(
internals.has(token)
|| this.map.has(token)
|| this.parent?.map.has(token),
|| this.hasRecursive(token),
);
}

private hasRecursive(token: InjectionToken): boolean | undefined {
return (
this.map.has(token)
|| this.parent?.hasRecursive(token)
);
}

Expand Down

0 comments on commit f849531

Please sign in to comment.