# basic-ioc

> javascript inversion of control container

Latest version **0.0.2** (published 2016-04-09) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install basic-ioc
pnpm add basic-ioc
yarn add basic-ioc
bun add basic-ioc
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-04-09 |
| First published | 2016-04-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | dayne m kilheffer |
| Maintainers | daynek |

## Links

- npm: https://www.npmjs.com/package/basic-ioc
- Repository: https://github.com/daynekilheffer/basic-ioc.js
- Homepage: https://github.com/daynekilheffer/basic-ioc.js#readme
- Issues: https://github.com/daynekilheffer/basic-ioc.js/issues
- npm.io page: https://npm.io/package/basic-ioc

## Dependencies (1)

- [arrify](https://npm.io/package/arrify.md) 1.0.1

## Recent versions

- 0.0.2 (latest) — 2016-04-09
- 0.0.1 — 2016-04-09

## README

# Basic inversion of control
IoC is all about control, and `basic-ioc` attempts to give _all_ of that control to the user.

## usage
At the lowest level, `basic-ioc` is just a wrapper around `require()`

Here is an example configuration:

`some-app.js`
```javascript
const ioc = require('basic-ioc');
const path = require('path');

let container = ioc.initialize(path.resolve(__dirname, 'config.json'));
let myComponent = container.get('yourComponentId');
// do something magical with your component
```
`config.json`
```json
{
  "components": [
    {
      "id": "yourComponentId",
      "source": "./your-component.js"
    }
  ]
}
```

But this is just a contrived example.  Most likely you want dependency injection.  The following is more than likely what you are looking for.

`config.json`
```json
{
  "components": [
    {
      "id": "yourDependency",
      "source": "./your-dependency.js"
    },
    {
      "id": "yourComponentId",
      "source": "./your-component.js",
      "properties": [
        {
          "name": "myDependency",
          "ref": "your-dependency.js"
        }
      ]
    }
  ]
}
```

In this case, `your-component.js` declares a method on the exported object which is provided with the object exported via `your-dependency.js` during initialization.

### About this project
I needed an IoC container and I felt that many of the ones available on npm were very specific about how you build your code.  I wanted to avoid that.

I also come from the Java community and thus, based the initial design of this module off of Spring.

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