https://github.com/tom-sherman/diddly
ƛ💉 Pure functional dependency injection for TypeScript
https://github.com/tom-sherman/diddly
Last synced: 2 months ago
JSON representation
ƛ💉 Pure functional dependency injection for TypeScript
- Host: GitHub
- URL: https://github.com/tom-sherman/diddly
- Owner: tom-sherman
- License: mit
- Created: 2021-07-02T09:04:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-18T20:23:51.000Z (over 1 year ago)
- Last Synced: 2025-03-27T11:11:10.419Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 509 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# diddly
> Pure functional dependency injection for TypeScript
**NOTE: This library is very experimental.**
## Benefits
- 100% type safe
- Purely functional
- Immutable
- Circular dependencies are impossible## Example
```ts
import { createContainer } from 'diddly';function printNameAndAge(name: string, age: number) {
console.log(`${name} is aged ${age}`);
}
const container = createContainer()
.register('someAge', value(5))
.register('someName', value('Timmy'))
.register('fn', func(printNameAndAge, 'someName', 'someAge'));
const print = container.resolve('fn');
print(); // Prints "Timmy is aged 5"
```