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

@michaelganchas/ts-inject

v1.0.3

Published

A lightweight TypeScript dependency injection library

Readme

ts-inject

npm version License: MIT

A lightweight, type-safe dependency injection library for TypeScript.

ts-inject simplifies dependency management in TypeScript applications by providing a straightforward and efficient way to inject dependencies, enhancing modularity and testability.

✨ Features

  • Type-Safe: Leverages TypeScript's type system for compile-time safety.
  • Lightweight: Minimal overhead with a focus on simplicity.
  • Flexible: Supports various injection patterns to suit different needs.
  • Test-Friendly: Facilitates easy mocking and testing of dependencies.

📦 Installation

npm install @michaelganchas/ts-inject
# or
yarn add @michaelganchas/ts-inject

📌 Where to Use

You can use ts-inject in any TypeScript-based project where clean architecture, testability, and modularity matter. Some common use cases include:

  • Modular backend applications (e.g. Node.js with Express or Koa)
  • Domain-driven design (DDD) implementations
  • Microservices and serverless functions
  • CLIs and tooling built with TypeScript
  • Unit testing with easily mockable dependencies
  • Frontend apps (e.g. React, React Native or Vue with TypeScript) that follow service-based architecture

If you're tired of manually wiring dependencies or passing instances all over your codebase, ts-inject offers a clean, intuitive alternative.

🔍 Examples

  • Using the container to register and obtain dependencies:

    • First we define our implementation
    [src/services/events/eventsService.ts]
      
    const send = () => {...}
    
    export const eventsService = {
        send,
    };
    
    export type EventsService = typeof eventsService;
    • Then, we set up a key for that implementation
    [src/services/events/types.ts]
      
    export const EventsServiceKey: PropertyKey = 'EVENTS_SERVICE';
    • We hook everything up together
    [src/services/events/index.ts]
      
    container.register<EventsService>(EventsServiceKey, () => eventsService);
    • Then we're just missing two things:
      • A place to import/load all the registrations
      [src/core/di/diSetup.ts]
            
      import '/src/services/events/index';
      ...
      • And lastly, to run it in our App's entry point as one of the first imports
      [src/index.ts]
            
      import 'src/core/di/diSetup';
      ...
  • Auto wire dependencies automatically:

    • Check the examples/ folder for how to use for either Class injections, or functional ones.

📚 API Reference

Check the types.ts file under src/ as it contains all the explanations inside their definitions.