Skip to content

Commit 3a46571

Browse files
committed
better readme
1 parent 28f6470 commit 3a46571

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ A dead-simple, modern, and lightweight (~4kb) Dependency Injection library for T
88

99
### **Why another DI framework?**
1010

11-
Many existing DI libraries for TypeScript rely on the older "experimental" decorators and reflection libraries like reflect-metadata. This approach forces you to enable emitDecoratorMetadata in your tsconfig.json, which depends on TypeScript's type-information—information that is erased at compile time.
11+
Stimshot was inspired from InversifyJS, Tsyringe, InjectionJS (outsize the context of Angular). These libraries have some fundamental issues when used with modern TypeScript.
1212

13-
This can lead to a fragile, guess-work setup.
13+
Many existing DI libraries for TypeScript rely on the older experimental decorators and reflection libraries like `reflect-metadata`. This approach forces you to enable `emitDecoratorMetadata` in your `tsconfig.json`, which depends on TypeScript's type-information—information that is erased at compile time.
1414

15-
stimshot was built with a different philosophy:
15+
Often this leads to runtime errors, especially when using the new [`import type` syntax](https://www.google.com/search?q=typescript+import+type+syntax). Most DI libraries were not designed with this in mind, and as a result, they fail to resolve dependencies correctly and lead to runtime issues.
1616

17-
* **Explicit & Guess-less:** No magic strings, no fragile type-reflection. You explicitly ask for what you need.
17+
Stimshot was built with a different philosophy:
18+
19+
* **Explicit & Guess-less:** No magic strings, no fragile type-reflection. You explicitly ask for what you need. What you see is what you get.
1820
* **Weightless:** The entire library is one small file with no dependencies.
1921
* **Modern:** Built for modern TypeScript (5.0+) using standard Stage 3 Decorators.
2022
* **Simple APIs:** The API surface is tiny, intuitive, and easy to understand.
2123

22-
This library **does not** use or require reflect-metadata or experimentalDecorators like other DI libraries.
24+
This library **does not** use or require `reflect-metadata` or `experimentalDecorators` or `emitDecoratorMetadata` like other DI libraries.
2325

2426
### **Why Use Dependency Injection?**
2527

@@ -124,17 +126,17 @@ You can also replace with a simple object (`useValue`) or a function (`useFactor
124126

125127
#### **Decorators**
126128

127-
* **@shared()**: Class decorator. Registers the class as a "singleton." A single instance will be created on the first resolve and shared for all subsequent calls.
128-
* **@fresh()**: Class decorator. Registers the class as a "prototype." A new instance will be created *every time* it is resolved.
129+
* **`@shared()`**: Class decorator. Registers the class as a "singleton." A single instance will be created on the first resolve and shared for all subsequent calls (This is what you usually want).
130+
* **`@fresh()`**: Class decorator. Registers the class as a "prototype." A new instance will be created *every time* it is resolved.
129131

130132
#### **Functions**
131133

132-
* **resolve(Token)**: Resolves a dependency from the container. Token is the class constructor (e.g., resolve(Database)).
133-
* **replace(Token, options)**: Used for testing. Replaces the registered Token with a mock implementation.
134+
* **`resolve(Token)`**: Resolves a dependency from the container. Token is the class constructor (e.g., resolve(Database)).
135+
* **`replace(Token, options)`**: Used for testing. Replaces the registered Token with a mock implementation.
134136
* options.useClass: Replaces with another registered class.
135137
* options.useValue: Replaces with a specific value (e.g., a mock object).
136138
* options.useFactory: Replaces with a function that returns the instance.
137-
* **reset()**: Used for testing. Resets the entire container, clearing all shared instances and removing all replacements, restoring the original configuration.
139+
* **`reset()`**: Used for testing. Resets the entire container, clearing all shared instances and removing all replacements, restoring the original configuration.
138140

139141
# License
140142

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stimshot",
33
"version": "0.0.0",
4-
"description": "A dead-simple, modern, and lightweight Dependency Injection library for TypeScript",
4+
"description": "A dead-simple, modern, and lightweight (~4kb) Dependency Injection library for TypeScript",
55
"type": "module",
66
"license": "MIT",
77
"homepage": "https://github.com/vajahath/stimshot#readme",
@@ -29,7 +29,8 @@
2929
"test": "vitest run",
3030
"typecheck": "tsc --noEmit",
3131
"lint": "biome check --write",
32-
"lint:ci": "biome ci"
32+
"lint:ci": "biome ci",
33+
"prepublishOnly": "npm run build && npm run typecheck && npm run lint:ci && npm run test"
3334
},
3435
"devDependencies": {
3536
"@biomejs/biome": "^2.3.3",

0 commit comments

Comments
 (0)