Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

Repository files navigation

A framework-agnostic dependency container.

Install

$ npm add @aldojs/container

Usage

let{ createContainer }=require('@aldojs/container')letcontainer=createContainer()// add a `foo` factorycontainer.bind('foo',(c)=>({foo: true}))// later, create `foo` objectletobj=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

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

About

Framework-agnostic dependency container

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages