# inject3

> Inject a dependency

Latest version **1.1.1** (published 2022-05-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install inject3
pnpm add inject3
yarn add inject3
bun add inject3
```

## Health

**Score 30/100 (F)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-05-06 |
| First published | 2018-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | iamthes |
| Keywords | injector, inject, dependency, dependency-injection, service-locator |

## Links

- npm: https://www.npmjs.com/package/inject3
- Repository: https://github.com/unlight/inject3
- Homepage: https://github.com/unlight/inject3#readme
- Issues: https://github.com/unlight/inject3/issues
- npm.io page: https://npm.io/package/inject3

## Recent versions

- 1.1.1 (latest) — 2022-05-06
- 1.1.0 — 2022-05-06
- 1.0.0 — 2018-12-02

## README

# inject3

Inject a dependency (service locator pattern).

## Install

```sh
npm install --save-dev inject3
```

## Usage

```ts
// app.ts
import { inject } from 'inject3';
const fs = inject('fs', () => require('fs'));
fs.readFileSync('data.json');

// app.spec.ts
import { injector } from 'inject3';
injector.mock('fs', () => ({
  readFileSync: () => 'result of call of fs.readFileSync()',
}));
```

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