# async-didi

> Async Dependency Injection for JavaScript

Latest version **1.0.0** (published 2025-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-didi
pnpm add async-didi
yarn add async-didi
bun add async-didi
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2025-12-16 |
| First published | 2019-07-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 20.12 |
| Dependencies | 1 |
| Unpacked size | 27.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nico Rehwaldt |
| Maintainers | nikku |
| Keywords | di, didi, inversion of control, dependency, injection, injector |

## Links

- npm: https://www.npmjs.com/package/async-didi
- Repository: https://github.com/nikku/async-didi
- Homepage: https://github.com/nikku/async-didi#readme
- Issues: https://github.com/nikku/async-didi/issues
- npm.io page: https://npm.io/package/async-didi

## Dependencies (1)

- [didi](https://npm.io/package/didi.md) ^11.0.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2025-12-16
- 0.3.1 — 2021-11-04
- 0.3.0 — 2021-11-04
- 0.2.1 — 2019-07-21
- 0.2.0 — 2019-07-20
- 0.1.1 — 2019-07-19
- 0.1.0 — 2019-07-19

## README

# `async-didi`

[![Build Status](https://github.com/nikku/async-didi/workflows/CI/badge.svg)](https://github.com/nikku/async-didi/actions?query=workflow%3ACI)

An async version of [`didi`][didi], the tiny [inversion of control](https://en.wikipedia.org/wiki/Inversion_of_control) container for JavaScript.


## Example

```js
import {
  AsyncInjector
} from 'async-didi';

function Car(engine) {
  this.start = function() {
    return engine.start();
  };
}

async function createEngine(power) {
  return {
    async start() {
      console.log('Starting engine with ' + power + 'hp');
    }
  };
}

const injector = new AsyncInjector([
  {
    'car': ['type', Car],
    'engine': ['factory', createEngine],
    'power': ['value', 1184]
  }
]);

await injector.invoke(async function(car) {
  await car.start();
});
```

For more examples, check out [the tests](https://github.com/nikku/async-didi/blob/main/test/async-injector.spec.js).


## Usage

Refer to [`didi` documentation](https://github.com/nikku/didi?tab=readme-ov-file#usage) and enjoy the ability to define `async` factory functions and module initializers.

See also [comparison](#comparison-to-didi).


## Comparison to [`didi`][didi]

* Same core features
* Exposes an `AsyncInjector`
* Injector API functions `get`, `invoke` and `instantiate` are async
* Factory functions may be async
* No support for child injectors and scopes


## License

MIT


[didi]: https://github.com/nikku/didi

---
_Source: https://npm.io/package/async-didi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
