npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zirion/ioc

v2.0.0

Published

IoC implementation using dependency injection

Readme

@zirion/ioc

npm version codecov

An IoC (Inversion of Control) implementation using dependency injection for Node.js.

Table of Contents

Installation

You can install the package using npm or yarn:

npm install @zirion/ioc

or

yarn add @zirion/ioc

Features

  • Lightweight
  • Multi-platform
  • Supports constructor method injection
  • Singleton and request lifetimes
  • Dependency resolution
  • Contexts for request-scoped providers
  • Code is free from dependencies

Roadmap:

  • More ways to inject: in properties, method args
  • More lifetimes - transient
  • Circular dependencies check
  • Isolated dependency groups
  • Lazy initialization configuration (Currently all registered providers are lazy initable)
  • More lifecycle hooks
  • Decorators Stage-3 support
  • Tests
  • In-code documentation
  • More code examples in repository

Usage

Basic Usage

Firstly we have to create container instance. It our first point where starting on

import { Container } from '@zirion/ioc';

const container = new Container();

container.add('my_key', {
  value: {
    data: 'My first injectable object!',
  },
}).finalize();

const obj = container.get('my_key');

// My first injectable object!
console.log(obj.data);

Let's take a look at how to use it in the simplest way:

import { Container } from '@zirion/ioc';

const container = new Container();

class ThemService {
  // ...
}

class MyService {
  constructor(themService: ThemService) {
    // Yaay! We got injected
  }

  // ...
}

// There added new services into main container
// Note: By default providers are added as singleton
container
  // Providers order is important!
  .add(ThemService)
  .add(MyService, {inject: [ThemService]})
  // End builder with calling this function to run our hooks
  .finalize()

// Now we can use our instance. It's lazy - only be initied when we got them
const myService = container.get(MyService)

Examples

Context scoped provider case:

import { Container, InjectScope } from '@zirion/ioc';

const container = new Container();

class MyService {
  constructor(context) {
    // In request-scoped providers context got auto-injected as latest parameter in constructor
  }
}

container
  .add(MyService, { scope: InjectScope.REQUEST })
  .finalize()

const myContext = {
  reqId: 1,
  foo: 'bar',
}

// To use request-scoped instance it's required to pass a context in second argument
const myService = container.get(MyService, myContext);

Also, there are some rules:

  • Request-scoped instance CAN'T be injected into singletone-scoped one

Contributing

Contributions are welcome! Please read the contribution guidelines first.

License

This project is licensed under the MIT License.