d dependencies v0.1.0
Docs menu
Guides Introduction

Introduction

@fuiste/dependencies is a small TypeScript library for wiring programs with typed service tags, immutable contexts, and composable dependency recipes.

It is inspired by Effect’s Layer, but it keeps the local surface area narrow:

Context

An immutable map of services addressed by typed tags.

Dependency

A recipe that builds one or more services from declared requirements.

Scope

A finalizer stack for resources that need deterministic release.

Result

A tiny success-or-failure value for build and use outcomes.

The point is not to make TypeScript pretend it has a runtime module system. The point is to make application construction explicit, typed, replaceable, and hostile to spooky mutable globals.

import { Context, Dependency, Result, compose, use } from '@fuiste/dependencies'

const Config = Context.Tag<{ appName: string }>('docs/config')
const Greeter = Context.Tag<{ greet: () => string }>('docs/greeter')

const config = Dependency.succeed(Config, { appName: 'Dependencies' })
const greeter = Dependency.sync(Greeter, [Config], (context) => ({
  greet: () => `hello from ${Context.get(context, Config).appName}`,
}))

const result = await use(compose(config, greeter), (context) => {
  return Context.get(context, Greeter).greet()
})

if (Result.isOk(result)) {
  console.log(result.value)
}

What This Library Optimizes For

  • Service wiring that is explicit at the value level.
  • Type inference for provided and required services.
  • Test substitution without mutating global containers.
  • Scoped resources that release in last-in-first-out order.
  • Small primitives that compose without a framework-shaped invoice.

Install

pnpm add @fuiste/dependencies

Use npm, yarn, or bun if that is your chosen package manager weather.