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

@rstackio/services

v0.1.0

Published

> Minimal TypeScript toolkit for async data fetching — > typed errors, chainable transforms, zero-config mocking.

Readme

Services

Minimal TypeScript toolkit for async data fetching — typed errors, chainable transforms, zero-config mocking.

npm CI license TypeScript


💡 Philosophy

Most async data layers grow into a tangle of try/catch blocks, ad-hoc mocks, and one-off error handling scattered across components. Services is built to fix that at the source — the main goal is to make async data work feel smooth and predictable, so developers spend less time on plumbing and more time building features.

A few guiding principles:

  • Errors are values, not exceptions. [error, data] tuples make error handling explicit and type-safe — no surprises, no forgotten catch blocks.
  • Define once, run everywhere. Transforms, error handlers, and mocks are declared on the provider, not at every call site. Change behavior in one place.
  • Mocking should cost nothing. Tests and dev mode use real mock files — no framework magic, no vi.mock gymnastics. Toggle from the console, swap per test with .andMock().
  • No hidden abstractions. The provider is just a function. await getUser(id) — it does exactly what you'd expect.
  • Colocation over convention. Each feature owns its api, mock, normalize, and provider files. The data layer lives next to the feature that uses it.

✨ Features

  • 🛡️ [error, data] tuplescreateSafeProvider never throws; errors are typed values
  • 🔗 Chainable API.andMock() .andThen() .andCatch() .andFinally() compose once, apply on every call
  • 🧪 Zero-config testing — mocks activate automatically in NODE_ENV=test; swap them per test with .andMock()
  • 🎭 Dev mocking — toggle mocks from the browser console without touching source code
  • Abort supportAbortSignal flows through providers and delay() helpers

📦 Modules

| Module | Purpose | Docs | |--------|---------|------| | data-provider | Wrap async functions in a chainable, mockable, type-safe API | API · Usage | | mock | Toggle mock mode, simulate latency, SSR-compatible state | API · Usage | | safe | Wrap any function to return [error, data] instead of throwing | API | | logger | Structured console logger, silent in production | API · Usage |


🗂️ File structure

Each feature module owns its data layer in a data-provider/ folder:

src/
  modules/
    user/
      models/
        user.ts         ← types and validation schema
      data-provider/
        api.ts          ← real async function
        mock.ts         ← mock using delay()
        normalize.ts    ← pure function to transform API response
        provider.ts     ← createProvider(api).andMock(mock).andThen(normalize)
        index.ts        ← export * from './provider'

Consume anywhere in the module:

import * as Dp from './data-provider';

const [error, user] = await Dp.getUser(id);

🚀 Installation

npm install @rstackio/services
# or
pnpm add @rstackio/services
# or
yarn add @rstackio/services

Requires TypeScript 5.0+ with strict: true.


🛠️ Development

pnpm install
pnpm test          # run tests
pnpm test:watch    # watch mode
pnpm build         # build dist

👥 Contributors

Amazing people who made their contributions. Feel free to contribute!


License: MIT