From 02d5fb07f6dd2b8bfa157cc438f8f3d9625c1630 Mon Sep 17 00:00:00 2001 From: dirkluijk Date: Tue, 17 Sep 2024 16:42:12 +0200 Subject: [PATCH] fix: export injectAsync and AsyncFactoryProvider --- package.json | 2 +- src/examples.test.ts | 30 +++++++++++++----------------- src/index.ts | 3 ++- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index fda4163..b297f8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dirkluijk/needle-di", - "version": "0.0.1", + "version": "0.0.2", "description": "A simple TypeScript library for dependency injection", "keywords": ["dependency injection", "di", "dependency", "injection", "typescript", "type-safe"], "homepage": "https://github.com/dirkluijk/needle-di", diff --git a/src/examples.test.ts b/src/examples.test.ts index cd1227f..526cfd4 100644 --- a/src/examples.test.ts +++ b/src/examples.test.ts @@ -1,26 +1,22 @@ -import { bootstrap, Container, inject, injectable } from './index.js'; -import { describe, expect, it } from 'vitest'; +import { bootstrap, Container, inject, injectable } from "./index.js"; +import { describe, expect, it } from "vitest"; @injectable() // eslint-disable-next-line @typescript-eslint/no-extraneous-class -class FooService { -} +class FooService {} @injectable() class BarService { - constructor( - private fooService: FooService = inject(FooService), - ) { - } + constructor(private fooService: FooService = inject(FooService)) {} } -describe('Examples', () => { - it('Bootstrap', () => { - // to create the DI container: - const container = new Container(); - const barService = container.get(BarService); +describe("Examples", () => { + it("Bootstrap", () => { + // to create the DI container: + const container = new Container(); + const barService = container.get(BarService); - expect(barService).toBeInstanceOf(BarService); - expect(bootstrap(BarService)).toBeInstanceOf(BarService); - }); -}); \ No newline at end of file + expect(barService).toBeInstanceOf(BarService); + expect(bootstrap(BarService)).toBeInstanceOf(BarService); + }); +}); diff --git a/src/index.ts b/src/index.ts index 9feec31..0eaf86f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export { inject, Container, bootstrap } from "./container.js"; +export { inject, Container, bootstrap, injectAsync } from "./container.js"; export { injectable } from "./decorators.js"; export type { FactoryProvider, @@ -7,6 +7,7 @@ export type { ConstructorProvider, ClassProvider, ValueProvider, + AsyncFactoryProvider, } from "./providers.js"; export { InjectionToken } from "./tokens.js"; export type { Token } from "./tokens.js";