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

brass-runtime

v1.12.0

Published

Effect runtime utilities for TypeScript

Readme

🛠️ brass-runtime — Mini ZIO-like runtime in TypeScript

A small experimental runtime inspired by ZIO 2, implemented in vanilla TypeScript and intentionally built without using Promise / async/await as the primary semantic primitive.

brass-runtime is the foundation: it provides an effect system, fibers, scheduler, scopes, and streams. Higher-level modules (HTTP, streaming utilities, integrations) are built on top of the runtime, not baked into it.

You can still interop with the outside world (timers, fetch, Node APIs) via explicit, cancellable bridges such as fromPromiseAbortable.


Philosophy

  • Effects are values — lazy, composable, referentially transparent
  • Async is explicit — no hidden Promise semantics
  • Concurrency is structured — fibers, scopes, finalizers
  • Side effects are interpreted — not executed eagerly
  • Higher-level APIs are libraries, not magic

If you like ZIO’s separation between zio-core, zio-streams, and zio-http, this project follows the same spirit.


Core concepts

  • Sync core effect: Effect<R, E, A> and Exit<E, A>
  • Algebraic async representation: Async<R, E, A>
  • Cooperative Scheduler (observable / testable)
  • Lightweight Fibers with interruption & finalizers
  • Structured Scopes for resource safety
  • ZStream-style streams with backpressure

Install

npm i brass-runtime

Quick start

Run an effect

import { succeed } from "brass-runtime";
import { Runtime, toPromise } from "brass-runtime/runtime";

const runtime = new Runtime({ env: {} });

const value = await toPromise(succeed(123), runtime.env);
console.log(value); // 123

Structured concurrency with Scope

import { withScope } from "brass-runtime/scope";
import { Runtime } from "brass-runtime/runtime";

const runtime = new Runtime({ env: {} });

withScope(runtime, (scope) => {
  const f = scope.fork(/* Async effect */);
  // later...
  scope.close(); // interrupts child fibers + runs finalizers
});

toPromise is just a convenience bridge for examples/DX. The runtime semantics remain explicit.


Modules built on top of brass-runtime

These are optional layers, implemented using the runtime primitives.

🌐 HTTP client (brass-http layer)

A ZIO-style HTTP client built on top of fibers and Async.

  • Lazy & cancelable HTTP requests
  • Explicit wire/content separation
  • Middleware-friendly (logging, retry, timeout, etc.)
  • Integrated with fiber interruption via AbortController

👉 Docs: HTTP module

Example:

import { httpClientStream } from "brass-runtime/http";
import { toPromise, Runtime } from "brass-runtime/runtime";

type Post = { id: number; title: string; body: string };

const runtime = new Runtime({ env: {} });

const client = httpClientStream({ baseUrl: "https://jsonplaceholder.typicode.com" });

const res = await toPromise(client.getJson<Post>("/posts/1"), runtime.env);
console.log(res.status, res.value.title);

🌊 Streams (ZStream-like)

Pull-based, resource-aware streams with backpressure.

  • ZStream<R, E, A>
  • Pull semantics
  • Bounded buffers
  • Deterministic resource cleanup

Examples:

  • src/examples/fromPromise.ts
  • src/examples/mergeStreamSync.ts

Docs


What’s new (recent changes)

  • Stream buffering with backpressure (buffer)
  • Abortable async integration (fromPromiseAbortable)
  • Fiber-safe toPromise for examples & DX
  • HTTP client module built on top of the runtime

Features (status)

Runtime (core)

  • [x] Sync core: Effect
  • [x] Async algebra: Async
  • [x] Cooperative Scheduler
  • [x] Fibers with interruption & finalizers
  • [x] Structured Scope
  • [x] Resource safety (acquireRelease)

Concurrency & Streams

  • [x] race, zipPar, collectAllPar
  • [x] ZStream-like core
  • [x] Bounded buffers & backpressure
  • [x] Stream merge / zip
  • [x] Hubs / Broadcast
  • [x] Pipelines (ZPipeline-style)

Libraries

  • [x] HTTP client
  • [ ] Retry / timeout middleware
  • [ ] Logging / metrics layers

Design notes

  • No hidden Promises: async is always modeled explicitly
  • Deterministic execution: scheduler is observable & testable
  • Resource safety is structural: scopes guarantee cleanup
  • Libraries compose via functions: middleware, not inheritance

Contributing

  • Runtime invariants matter — avoid sneaking Promises into semantics
  • Prefer libraries on top of the runtime over changes in the core
  • Small, focused PRs are welcome (your repo may enforce PR-only changes)

License

MIT License © 2025