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

@dougongjs/core

v0.8.3

Published

Capability composition and structured lifetime kernel for JavaScript/TypeScript.

Readme

@dougongjs/core

简体中文 · English


简体中文

Dougong 的能力组合与结构化生命周期内核。

npm install @dougongjs/core

六个原子

  • Service —— 稳定的一对一能力。依赖通过 requires 显式声明,Instance 生命周期内不变;提供者变化会重建消费者,不使用 live Proxy。
  • ExtensionPoint —— 可动态增删的开放贡献集合。Core 只保存原始贡献;排序、领域 key、覆盖和 pipeline 是高层组合策略。
  • Event —— 不保留状态的瞬时事实。只有一种分发语义:并发广播并等待全部监听器。
  • Lifetime —— 监听、贡献、任务、子生命周期与清理的结构化所有权。终态资源自动从父级摘除。
  • Plugin —— 一次 setup 产生一组能力。
  • Host / ChangeSet —— 事务化的安装图;失败回滚,无法可靠回滚时 fail closed。
import { createHost, definePlugin, service } from "@dougongjs/core"

const DATABASE = service<Database>("app/database")

const database = definePlugin({
  name: "app.database",
  provides: { db: DATABASE },
  async setup(ctx) {
    const client = await connect()
    ctx.cleanup(() => client.close())
    return { db: client }
  },
})

const host = createHost({ name: "api" })
host.install(database)
await host.start()

不使用 Service Locator、环境作用域、原型链注入或 Proxy。唯一包依赖 @standard-schema/spec 只提供类型契约,不进入运行时 bundle。

环境要求

Node.js ≥ 22;浏览器 / WebView 基线为 Chrome / Edge 119、Firefox 121、Safari 17.4,并提供 Promise.withResolvers()。显式 .dispose() 在全部基线上可用;using / await using 还要求运行时原生提供或应用预先 polyfill Symbol.dispose / Symbol.asyncDispose。Dougong 不修改全局对象。TypeScript 消费者需要 "lib": ["ES2024", "DOM", "DOM.Iterable", "ESNext.Disposable"]。


English

The capability composition and structured lifetime kernel of Dougong.

npm install @dougongjs/core

Six atoms

  • Service — a stable one-to-one capability. Dependencies are declared explicitly through requires and stay fixed for the Instance lifetime; a provider change rebuilds consumers rather than using a live proxy.
  • ExtensionPoint — an open contribution set that adds and removes live. Core keeps only raw contributions; ordering, domain keys, override and pipelines are higher-level composition policy.
  • Event — a transient fact retaining no state, with one dispatch semantic: broadcast concurrently and await every listener.
  • Lifetime — structured ownership of listeners, contributions, tasks, child lifetimes and cleanups. Terminal resources detach from their parent automatically.
  • Plugin — one setup producing a set of capabilities.
  • Host / ChangeSet — a transactional installation graph; a failure rolls back, and fails closed when it cannot roll back reliably.
import { createHost, definePlugin, service } from "@dougongjs/core"

const DATABASE = service<Database>("app/database")

const database = definePlugin({
  name: "app.database",
  provides: { db: DATABASE },
  async setup(ctx) {
    const client = await connect()
    ctx.cleanup(() => client.close())
    return { db: client }
  },
})

const host = createHost({ name: "api" })
host.install(database)
await host.start()

No service locator, ambient scope, prototype-chain injection or proxy. The only package dependency, @standard-schema/spec, supplies types and does not enter the runtime bundle.

Requirements

Node.js ≥ 22; Chrome / Edge 119, Firefox 121 or Safari 17.4 for browsers and WebViews, with Promise.withResolvers(). Explicit .dispose() works throughout; using / await using additionally require native or application-polyfilled Symbol.dispose / Symbol.asyncDispose. Dougong does not mutate globals. TypeScript consumers need "lib": ["ES2024", "DOM", "DOM.Iterable", "ESNext.Disposable"].


  • 文档站 / Documentation: https://tangerg.github.io/dougong/
  • 仓库 / Repository: https://github.com/Tangerg/dougong

早期 0.x 开发阶段,当前不承诺向后兼容。 Early 0.x development; no backward-compatibility promises yet.

MIT