Skip to content

Commit

Permalink
refactor: use array for dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Oct 11, 2024
1 parent 3b3f8df commit cdb4c2e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function Inject<Values extends unknown[]>(...injections: Injections<Value
export function Deferred<Values extends unknown[]>(...injections: Injections<Values>): ClassFieldDecorator<Values[number]> {
return (_value, context) => {
const metadata = metadataRegistry.ensure(context.metadata)
metadata.dependencies.add({
metadata.dependencies.push({
injections,
setValue: context.access.set,
})
Expand Down
5 changes: 2 additions & 3 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type {Constructor, InjectionToken} from './token'
export interface InjectionMetadata<This extends object = any> {
scope?: InjectionScope
tokens: InjectionToken<This>[]
// TODO: use array
dependencies: Set<InjectionDependency<This>>
dependencies: InjectionDependency<This>[]
}

export interface InjectionDependency<This extends object, Value = any> {
Expand All @@ -24,7 +23,7 @@ class InjectionMetadataRegistry {
ensure<T extends object>(key: DecoratorMetadata): InjectionMetadata<T> {
let metadata = this.map.get(key)
if (!metadata) {
metadata = {tokens: [], dependencies: new Set()}
metadata = {tokens: [], dependencies: []}
this.map.set(key, metadata)
}
return metadata
Expand Down

0 comments on commit cdb4c2e

Please sign in to comment.