Socket
Socket
Sign inDemoInstall

@aldojs/container

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aldojs/container

Dead simple dependency container


Version published
Weekly downloads
4
increased by100%
Maintainers
1
Install size
6.13 kB
Created
Weekly downloads
 

Readme

Source

A framework-agnostic dependency container.

Install

$ npm add @aldojs/container

Usage

let { createContainer } = require('@aldojs/container')

let container = createContainer()

// add a `foo` factory
container.bind('foo', (c) => ({ foo: true }))

// later, create `foo` object
let obj = container.make('foo')

API

container.bound(name)

Check a bind is already defined.

container.bind(name, fn)

Add an new factory into the container.

container.singleton(name, fn)

Bind a singleton factory to make a singleton instances.

container.make(name, ...args)

Create and return the service instance, passing the additional arguments.

Factory function

Each function given to bind or singleton as second parameter should have the following signature

function Factory = (c: Container, ...args: any[]) => any;

Keywords

FAQs

Last updated on 12 Feb 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc