0.0.1 • Published 7 months ago
@chahut/service v0.0.1
@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/serviceUsage
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: 3Commands
Using bun as the preferred runtime:
bun run lint: Runs the biome linter to check and fix code style issues in thesrcdirectory.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 usingbun buildand outputs the result to thebuilddirectory.
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.