Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tom-sherman/diddly
ƛ💉 Pure functional dependency injection for TypeScript
https://github.com/tom-sherman/diddly
Last synced: 14 days 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 (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-28T10:32:48.000Z (over 3 years ago)
- Last Synced: 2023-12-27T19:04:13.151Z (12 months ago)
- Language: TypeScript
- Homepage:
- Size: 509 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
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"
```