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

injeca

v0.1.8

Published

Pure functional programming based dependency injection library inspired by go.uber.org/fig and go.uber.org/dig.

Readme

Injeca

Pure functional programming (means no class and extra wrappers and containers) based dependency injection with application lifecycle management.

Heavily inspired by uber/fig and uber/dig in Golang ecosystem.

npm version npm downloads bundle JSDocs License

Installation

npm install injeca
pnpm add injeca
bun add injeca
ni injeca
yarn add injeca

Agent Skills

Install the injeca skill to your AI coding agent:

npx skills add moeru-ai/injeca

Basic usage

injeca ships with a global singleton container exposed as injeca. You can register providers, declare their dependencies, and run invocations once everything is ready.

import { createServer } from 'node:http'

import { injeca, lifecycle } from 'injeca'

// Providers return a value once and are cached inside the container.
const config = injeca.provide('config', () => ({ port: 3000 }))

const server = injeca.provide({
  dependsOn: { config, lifecycle },
  async build({ dependsOn }) {
    const { config, lifecycle } = dependsOn
    const app = createServer()

    lifecycle.appHooks.onStart(() => app.listen(config.port))
    lifecycle.appHooks.onStop(() => app.close())

    return app
  },
})

injeca.invoke({
  dependsOn: { server },
  async callback({ server }) {
    // eslint-disable-next-line no-console
    console.log('HTTP server ready:', await server.address())
  },
})

await injeca.start()

process.once('SIGINT', async () => {
  await injeca.stop()
})

[!WARNING]

injeca implements singleton / cached dependencies by default

This means every value returned by build will be stored and build will only got called once.

If build returns a function, that function is cached (not the result of calling it). This is useful for lazy dependencies, "getters", or wrappers for singleton, but it also means any side effects inside the returned function will run on every call.

If you want the returned function to be reusable (e.g. a single window), create the reusable closure once inside build, and return a wrapper that calls it:

const settingsWindow = injeca.provide('windows:settings', {
  dependsOn: { widgetsManager },
  build: ({ dependsOn }) => {
    const getWindow = setupReusableSettingsWindow(dependsOn) // created once
    return async () => await getWindow() // can be called many times
  },
})

Avoid recreating the reusable function inside the returned function, otherwise each call starts from a fresh cache and can create duplicate resources.

Manual containers

If you need multiple containers (for tests or per-request scopes), create them explicitly and pass the container reference into provide, invoke, start, and stop.

import { createContainer, invoke, provide, start, stop } from 'injeca'

const container = createContainer()

const token = provide(container, 'token', () => crypto.randomUUID())

invoke(container, {
  dependsOn: { token },
  // eslint-disable-next-line no-console
  callback: ({ token }) => console.log('token', token),
})

await start(container)
await stop(container)

License

MIT