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

iocello

v2.0.0

Published

Inversion of Control

Downloads

242

Readme

iocello

Lightweight IoC / DI container with decorator-based service registration, lazy loading, domains, and graph introspection.

Requirements

  • TypeScript 5+ (standard decorator pipeline).
  • corello 1.x.
  • @abraham/reflection.

TypeScript Config (Stage 3 decorators)

Use the standard decorator pipeline. Do not enable legacy decorator mode.

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "useDefineForClassFields": true,
    "moduleResolution": "bundler",
    "isolatedModules": true,
    "strict": true
  }
}

Important:

  • Keep experimentalDecorators unset/false (legacy mode).
  • Keep emitDecoratorMetadata unset/false unless your own app explicitly needs it.

Quick Start

import { ioc, Service, Inject, Singleton } from 'iocello'

@Service({ tag: 'Pet' })
class Pet {
  constructor(public name = 'Milo') {}
  dispose() {}
}

@Singleton
@Service({ tag: 'Person' })
class Person {
  @Inject({ tag: 'Pet' }) pet!: Pet
  dispose() {}
}

ioc.add(Pet)
ioc.add(Person)

const person = await ioc.construct<Person>('Person')
console.log(person.pet.name) // Milo

Core Concepts

  • tag: unique service identifier (example: Person).
  • domain: hierarchical scope (0 is base). Lookup falls back downward (current -> ... -> 0).
  • app context: optional namespace for independent registries.
  • lazy service: service loaded only when first needed.

API Guide

Registration

  • ioc.add(ServiceClass)
    • Registers an eagerly-available class decorated with @Service.
  • ioc.addLazy(meta, loader)
    • Registers a lazy service.
    • meta: { tag, domain?, declaredDeps?, enforce?, ctorArgs? }
    • loader: async function returning module that exports the class (default export recommended).

Construction

  • await ioc.construct<T>(tag, domain?, ...ctorArgs)
    • Main async resolver.
    • Loads lazy services on demand.
    • Applies runtime ctor args for this construction call.
  • ioc.tryConstructSync<T>(tag, domain?, ...ctorArgs)
    • Sync fast path.
    • Returns instance when class is already available synchronously, otherwise undefined.

Graph / Preload / Manifest

  • await ioc.buildGraph({ tag, domain?, ctorArgs?, enforce? })

    • Returns the transitive dependency tree from a root service.
    • Includes resolved domain for every edge.
    • Marks cycles via cycle: true.
    • Useful for diagnostics and dependency visualization.
  • await ioc.bootstrap<T>({ tag, domain?, ctorArgs?, enforce? })

    • Builds dependency graph, then warms/constructs reachable nodes.
    • Finally returns the requested root instance (construct result).
    • Useful to avoid runtime lazy waterfalls before route/app startup.
  • await ioc.manifest(tag, domain?)

    • Returns only direct dependencies (shallow list).
    • Fast for prefetch hints, CI checks, and bundle planning.

Context and Domain Controls

  • ioc.instance.setContainerDomain(domain)
    • Sets active default domain for lookups.
  • ioc.instance.setAppContext(appName)
    • Switches active app context namespace.

Decorators

  • @Service({ tag, domain?, enforce?, ctorArgs? })
    • Marks class as IoC service and stores metadata.
  • @Inject({ tag?, domain?, ctorArgs? }, executor?)
    • Property injection entry.
    • If tag is omitted, it falls back to property name.
    • Custom executor can override how dependency is resolved.
  • @Singleton
    • Ensures a single class instance per decorated class constructor.

Notes and Best Practices

  • Register all core services before first construct/bootstrap call.
  • With @Inject, pass tag explicitly when property name differs from service tag.
  • Use manifest for fast direct deps, buildGraph for full dependency analysis.
  • In frontend apps (React/Vue), perform registration during app initialization.

Sample Vite project

PREVIOUS VERSION Sample Vue + Vite usage