@needle-di/core 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +91 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Needle DI 💉
2
+
3
+ > A lightweight, type-safe Dependency Injection (DI) library for JavaScript and TypeScript projects.
4
+
5
+ [![NPM version](http://img.shields.io/npm/v/@needle-di/core.svg)](https://www.npmjs.com/package/@needle-di/core)
6
+ [![JSR version](http://img.shields.io/jsr/v/@needle-di/core.svg)](https://jsr.io/@needle-di/core)
7
+ [![NPM downloads](https://img.shields.io/npm/dm/@needle-di/core)](https://www.npmjs.com/package/@needle-di/core)
8
+ [![Build status](https://img.shields.io/github/actions/workflow/status/needle-di/needle-di/ci.yml?branch=main&style=flat)](https://github.com/needle-di/needle-di/actions/workflows/ci.yml)
9
+ [![Coverage](https://gist.githubusercontent.com/dirkluijk/db6fbd0d0d4c138655a89386c5bdbe41/raw/badge.svg)](https://github.com/needle-di/needle-di/actions/workflows/ci.yml)
10
+
11
+ Needle DI is a lightweight, TypeScript-first library for dependency injection (DI). It is designed to be both easy to use and highly efficient.
12
+
13
+ ### Key Features
14
+
15
+ - Stand-alone: No additional dependencies required
16
+ - Intended for both JavaScript-only and TypeScript projects
17
+ - Supports [tree-shakeable injection tokens](https://needle-di.io/advanced/tree-shaking.html): optimize your builds for production.
18
+ - Inspired by [Angular](https://angular.dev/) and [InversifyJS](https://github.com/inversify/InversifyJS), familiar to developers coming from these frameworks.
19
+ - Uses native [ECMAScript decorators](https://github.com/tc39/proposal-decorators) (currently stage 3)
20
+ - No need for `experimentalDecorators` and `emitDecoratorMetadata`
21
+ - No reflection libraries needed, like `reflect-metadata` or other reflection mechanisms.
22
+
23
+ ## Basic example
24
+
25
+ Here’s a simple example using constructor injection to inject one service into another.
26
+
27
+ ```typescript
28
+ import { injectable, inject } from "@needle-di/core";
29
+
30
+ @injectable()
31
+ class FooService {}
32
+
33
+ @injectable()
34
+ class BarService {
35
+ constructor(private fooService = inject(FooService)) {}
36
+ // ^? Type will be inferred as `FooService`
37
+ }
38
+ ```
39
+
40
+ The `@injectable` decorator eliminates the need to manually register services. To construct the `BarService`, create a
41
+ dependency injection container, and use the `container.get()` method:
42
+
43
+ ```typescript
44
+ import { Container } from "@needle-di/core";
45
+
46
+ const container = new Container();
47
+ const barService = container.get(BarService);
48
+ // ^? Type will be inferred as `BarService`
49
+ ```
50
+
51
+ Check out the [docs](https://needle-di.io/concepts/binding.html) to learn more!
52
+
53
+ ## Installation
54
+
55
+ ```
56
+ npm install --save @needle-di/core
57
+ ```
58
+
59
+ Needle DI also works with [Deno](https://deno.com/) and is published to [JSR](https://jsr.io/@needle-di/core) as well:
60
+
61
+ ```bash
62
+ deno add jsr:@needle-di/core
63
+ ```
64
+
65
+ ## Docs
66
+
67
+ Check out our docs on [https://needle-di.io](https://needle-di.io/concepts/binding.html).
68
+
69
+ ## License
70
+
71
+ License under the MIT License (MIT)
72
+
73
+ Copyright (c) 2024 - 2025 Dirk Luijk
74
+
75
+ Permission is hereby granted, free of charge, to any person obtaining a copy
76
+ of this software and associated documentation files (the "Software"), to deal
77
+ in the Software without restriction, including without limitation the rights
78
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
79
+ copies of the Software, and to permit persons to whom the Software is
80
+ furnished to do so, subject to the following conditions:
81
+
82
+ The above copyright notice and this permission notice shall be included in all
83
+ copies or substantial portions of the Software.
84
+
85
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
86
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
87
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
88
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
89
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
90
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
91
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-di/core",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "A simple TypeScript library for dependency injection",
5
5
  "license": "MIT",
6
6
  "keywords": [