0.0.1 • Published 7 months ago

@chahut/service v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

@chahut/service

This library provides tooling for grouping functions into services easily, with dependency injection as the core principle. It allows you to construct isolated chunks of code with minimal syntax.

Installation

bun install @chahut/service

Usage

import { Service } from "@chahut/service";

// Define a service with dependencies
const math = new Service().dependencies<{ a: number; b: number }>();

// Define a function that uses the dependencies
math.function("add", ({ a, b }: { a: number; b: number }) => {
  return a + b;
});

// Call the function with the dependencies
const result = math.call("add", { a: 1, b: 2 });

console.log(result); // Output: 3

Commands

Using bun as the preferred runtime:

  • bun run lint: Runs the biome linter to check and fix code style issues in the src directory.
  • bun run docs: Generates documentation using TypeDoc.
  • bun run test: Runs tests using Bun's built-in test runner.
  • bun run build: Builds the project using bun build and outputs the result to the build directory.

Project Direction

This project aims to provide a simple and intuitive way to manage dependencies and create reusable services. It leverages TypeScript's type system to ensure type safety and provides a flexible way to define and use dependencies.

0.0.1

7 months ago

0.0.0-c

7 months ago