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

@edo-w/tiny

v0.3.1

Published

Tiny is a typescript dependency injection library for building maintainable applications.

Readme

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///////////////////////////
///////// \///// \/// \\/// \/// \\/// \///////// \///// \/// \\///
\\\/// \\\\\/// \\///// /// \\/// /// \\\\\/// \\\\\///\\\/// \\\\\
\\\/// \\\\\/// \\///////// \\\///// \\\ \\\\\/// \\///////// \\\//
\\\/// \\\\\/// \\/// ///// \\\\/// \\\\\\\/// \\/// ///// \\\\///\
\\\/// \\\\///// \/// \\/// \\\\/// \\\\// \\\\///// \///\\///// \/
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///////////////////////////
\\\/// \\\\\/// \\///////// \\\///// \\\ \\\\\/// \\///////// \\\//

@edo-w/tiny

Tiny is a lightweight dependency injection container for TypeScript.

Features

  • Typed registration keys (createKey<T>()) for non-class dependencies
  • Lazy component resolution with createLazyKey(...)
  • Class, factory, and instance registrations
  • Lifetimes: transient, scoped, and singleton
  • Scoped containers with parent lookup (createScope())
  • Registration modules (TinyModule) for reusable setup
  • Property injection helper (inject) for class initializers
  • Convenience lifetime helpers in both Tiny and TinyModule

Getting Started

Install

pnpm add @edo-w/tiny

Create the container

import { Tiny } from '@edo-w/tiny';

const tiny = new Tiny();

Add registrations

import { Tiny, createKey } from '@edo-w/tiny';

class Logger {
	log(message: string): string {
		return `LOG: ${message}`;
	}
}

class UserRepository {
	findName(): string {
		return 'tiny-user';
	}
}

class UserService {
	constructor(
		public repo: UserRepository,
		public logger: Logger,
	) {}

	getDisplayName(): string {
		return this.logger.log(this.repo.findName());
	}
}

const ConfigKey = createKey<{ env: string }>('config');
const tiny = new Tiny();

tiny.addInstance(ConfigKey, { env: 'dev' });
tiny.addClass(Logger, []);
tiny.addClass(UserRepository, []);
tiny.addClass(UserService, [UserRepository, Logger]);

Class registrations now use a deps array.

  • Use [] for classes with no constructor dependencies
  • Use [DepA, DepB] in constructor order when dependencies exist
  • Use a lazy key when a constructor dependency should resolve to Lazy<T> instead of T

Resolve vs Register keys

Tiny uses two key concepts:

  • ComponentKey<T>: keys you can register with addInstance, addFactory, and builder aliases
  • ResolveKey<T>: keys you can resolve with get, getSafe, and inject

In practice:

  • class constructors and createKey<T>() values can be registered and resolved
  • createLazyKey(...) values are resolve-only keys that produce Lazy<T> wrappers on demand

Resolve services from the container

const service = tiny.get(UserService);
const config = tiny.get(ConfigKey);

console.log(service.getDisplayName());
console.log(config.env);

Resolve a lazy dependency

import { createLazyKey, Tiny, type Lazy } from '@edo-w/tiny';

class UserRepo {
	findName(): string {
		return 'tiny-user';
	}
}

class UserService {
	constructor(public repo: Lazy<UserRepo>) {}
}

const tiny = new Tiny();
const lazyRepoKey = createLazyKey(UserRepo);

tiny.addClass(UserRepo, []);
tiny.addClass(UserService, [lazyRepoKey]);

const service = tiny.get(UserService);
console.log(service.repo.get().findName());

createLazyKey(...) does not register a component. It tells Tiny to return a lightweight wrapper whose get() resolves the underlying component when needed.

Use the inject helper in a property initializer

import { Tiny, inject } from '@edo-w/tiny';

class Logger {
	log(message: string): string {
		return `LOG: ${message}`;
	}
}

class Handler {
	logger = inject(Logger);

	handle(): string {
		return this.logger.log('handled');
	}
}

const tiny = new Tiny();
tiny.addClass(Logger, []);
tiny.addClass(Handler, []);

const handler = tiny.get(Handler);
console.log(handler.handle());

You can also inject a lazy dependency into a property:

import { createLazyKey, inject, Tiny, type Lazy } from '@edo-w/tiny';

class UserRepo {
	findName(): string {
		return 'tiny-user';
	}
}

const lazyRepoKey = createLazyKey(UserRepo);

class Handler {
	repo = inject(lazyRepoKey);

	handle(): string {
		return this.repo.get().findName();
	}
}

const tiny = new Tiny();
tiny.addClass(UserRepo, []);
tiny.addClass(Handler, []);

const handler = tiny.get(Handler);
console.log(handler.handle());

[!NOTE] inject resolves from the current container resolution context, so create instances through tiny.get(...) instead of new.

Lifetime Helper Methods

Tiny provides direct helper methods for common lifetimes:

tiny.addSingletonClass(Logger, []);
tiny.addScopedClass(UserRepo, []);
tiny.addSingletonFactory(ConfigKey, () => ({ env: 'prod' }));
tiny.addScopedFactory(UserService, (t) => {
	const repo = t.get(UserRepo);
	const logger = t.get(Logger);

	return new UserService(repo, logger);
});

TinyModule supports the same helper methods:

import { Tiny, TinyModule } from '@edo-w/tiny';

const tm = new TinyModule();
tm.addSingletonClass(Logger, []);
tm.addScopedClass(UserRepo, []);
tm.addSingletonFactory(ConfigKey, () => ({ env: 'prod' }));
tm.addScopedFactory(UserService, (t) => {
	const repo = t.get(UserRepo);
	const logger = t.get(Logger);
	
	return new UserService(repo, logger);
});

const tiny = new Tiny();
tiny.addModule(tm);