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

@nowarajs/singleton-manager

v1.4.2

Published

Singleton Manager is a package that provides a simple way to manage singletons in your application. It allows you to create, retrieve, and manage singletons with ease and type safety.

Readme

🎯 NowaraJS - Singleton Manager

Managing singletons in TypeScript shouldn't require boilerplate everywhere. I built this package to have a single, centralized registry for all my singleton instances, no more scattered getInstance() patterns or global variables.

Why this package?

The goal is simple: One registry to rule them all.

Instead of implementing the singleton pattern in every class, you register instances once and retrieve them anywhere. Type-safe, predictable, and easy to test.

📌 Table of Contents

✨ Features

  • 🔒 Type-Safe: Full TypeScript support with generics, no any casting.
  • 🎯 Centralized: One place to manage all your singletons.
  • Lightweight: Minimal overhead, zero dependencies.

🔧 Installation

bun add @nowarajs/singleton-manager @nowarajs/error

⚙️ Usage

Registering Singletons

Register your instances once at startup. They'll be available everywhere.

import { SingletonManager } from '@nowarajs/singleton-manager';

class DatabaseConnection {
	private _isConnected = false;

	public constructor() {
		console.log('Database connection created');
		this._isConnected = true;
	}

	public query(sql: string): string[] {
		return ['result1', 'result2'];
	}
}

class ApiClient {
	public constructor(
		private readonly _baseUrl: string,
		private readonly _apiKey: string
	) {}

	public get baseUrl(): string {
		return this._baseUrl;
	}
}

// Register with any constructor signature
SingletonManager.register('DatabaseConnection', new DatabaseConnection());
SingletonManager.register('ApiClient', new ApiClient('https://api.example.com', 'key'));

Retrieving Instances

Same instance, every time. TypeScript knows the type.

const db1 = SingletonManager.get<DatabaseConnection>('DatabaseConnection');
const db2 = SingletonManager.get<DatabaseConnection>('DatabaseConnection');

console.log(db1 === db2); // true — same reference

db1.query('SELECT * FROM users'); // ✅ Type-safe

Checking & Unregistering

if (SingletonManager.has('ApiClient')) {
	const client = SingletonManager.get<ApiClient>('ApiClient');
	console.log(client.baseUrl);
}

// Need to swap an instance? Unregister first.
SingletonManager.unregister('DatabaseConnection');
SingletonManager.register('DatabaseConnection', new DatabaseConnection());

📚 API Reference

Full docs: nowarajs.github.io/singleton-manager

⚖️ License

MIT — Feel free to use it.

📧 Contact