New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

basic-ioc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-ioc

javascript inversion of control container

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

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

{
  "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

{
  "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.

FAQs

Package last updated on 09 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc