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

@streetjs/container

v1.0.0

Published

StreetJS dependency injection container: a singleton IoC registry with constructor-injection resolution, circular-dependency detection, and an @Injectable decorator. Backed by reflect-metadata.

Readme

@streetjs/container

The StreetJS dependency injection container: a process-wide singleton IoC registry that resolves constructor-injected dependency trees, detects circular dependencies, and exposes an @Injectable() class decorator. ESM, strict-TypeScript, backed by reflect-metadata.

This is the standalone home of the container that also backs the streetjs framework. The framework re-exports this package, so there is a single source of truth.

Install

npm install @streetjs/container reflect-metadata

Import reflect-metadata once at your application entry point, and enable decorator metadata in your tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Usage

import 'reflect-metadata';
import { Injectable, container } from '@streetjs/container';

@Injectable()
class Database {
  query(sql: string) { /* ... */ }
}

@Injectable()
class UserService {
  constructor(private readonly db: Database) {}
}

// Database is constructed once and injected as a singleton.
const users = container.resolve(UserService);

API

@Injectable()

Class decorator that marks a class as participating in DI. Applying it also triggers TypeScript's design:paramtypes metadata emission, which the container reads to discover constructor dependencies.

container / Container

A single shared Container instance is exported as container (Container.getInstance() returns the same singleton).

| Method | Description | | ------ | ----------- | | resolve(token) | Return the singleton for token, constructing it and its dependency tree on first use. | | register(token, instance) | Register a pre-built instance so resolve(token) returns it. | | has(token) | true if the token has been resolved or registered. | | reset() | Clear all instances — primarily for tests. |

Circular-dependency detection

If resolution re-enters a token already on the resolution stack, resolve throws with the full chain (A -> B -> A) instead of overflowing the stack.

Unresolvable dependencies

A constructor parameter typed as an interface, a primitive, or an un-@Injectable value erases to Object/undefined in emitted metadata. The container throws a clear error naming the resolution chain and suggesting you enable emitDecoratorMetadata and decorate the dependency.

Example

A complete runnable example lives in src/examples/integration.ts:

npm run example -w packages/container

License

MIT — see LICENSE.