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

@basic-math/monitor

v0.1.0

Published

Operation monitoring and logging with repository pattern for mathematical operations

Readme

@basic-math/monitor

Monitoring and logging package for basic-math library operations. Records, stores, and analyzes mathematical operation history.

Features

  • 📊 Record all mathematical operations (add, subtract, multiply, divide)
  • 🔍 Query operations by ID, type, or date range
  • 📈 Generate operation statistics
  • 🔌 Pluggable repository interface for different storage backends
  • 🎯 Console logging implementation included
  • 🎨 Decorator pattern for wrapping existing adapters

Installation

bun install

Architecture

This package follows Clean Architecture principles:

src/
├── domains/
│   ├── models/        # OperationRecord, OperationType
│   └── ports/         # OperationRepository interface
├── applications/      # MonitorService
└── infrastructures/   # ConsoleOperationRepository, Monitoring adapters

Usage

Basic Usage

import {
  MonitorService,
  ConsoleOperationRepository,
} from "@basic-math/monitor";

// Create repository and service
const repository = new ConsoleOperationRepository();
const monitor = new MonitorService(repository);

// Record operations
await monitor.recordOperation({
  operation: "add",
  operandA: 5,
  operandB: 3,
  result: 8,
});

// Get all operations
const operations = await monitor.getAllOperations();

// Get statistics
const stats = await monitor.getStatistics();
console.log(`Total operations: ${stats.total}`);
console.log(`Add operations: ${stats.byType.add}`);

Integration with Client Package

Use monitoring adapters to wrap existing adapters:

import { Client, NativeAddAdapter } from "@basic-math/client";
import {
  MonitorService,
  ConsoleOperationRepository,
  MonitoringAddAdapter,
} from "@basic-math/monitor";

// Setup monitoring
const repository = new ConsoleOperationRepository();
const monitor = new MonitorService(repository);

// Wrap adapter with monitoring
const baseAdapter = new NativeAddAdapter();
const monitoredAdapter = new MonitoringAddAdapter(baseAdapter, monitor);

// Use in client
const math = new Client({
  add: monitoredAdapter,
  subtract: "native",
});

math.add(5, 3); // Will be logged to console and recorded

Custom Repository Implementation

Implement the OperationRepository interface for custom storage:

import type { OperationRepository } from "@basic-math/monitor";

class DatabaseOperationRepository implements OperationRepository {
  async save(input: CreateOperationRecordInput): Promise<OperationRecord> {
    // Save to database
  }

  async findById(id: string): Promise<OperationRecord | null> {
    // Query from database
  }

  // Implement other methods...
}

const monitor = new MonitorService(new DatabaseOperationRepository());

API Reference

MonitorService

Main service for monitoring operations.

Methods

  • recordOperation(input) - Record a new operation
  • getOperationById(id) - Get operation by ID
  • getAllOperations() - Get all operations
  • getOperationsByType(type) - Get operations filtered by type
  • getOperationsByDateRange(start, end) - Get operations in date range
  • deleteOperation(id) - Delete operation by ID
  • clearAllOperations() - Delete all operations
  • getTotalCount() - Get total count
  • getCountByType(type) - Get count by type
  • getStatistics() - Get summary statistics

OperationRepository Interface

Repository interface for implementing custom storage backends.

Methods:

  • save(input) - Save operation record
  • findById(id) - Find by ID
  • findAll() - Find all records
  • findByType(operation) - Find by operation type
  • findByDateRange(start, end) - Find by date range
  • deleteById(id) - Delete by ID
  • deleteAll() - Delete all records
  • count() - Count all records
  • countByType(operation) - Count by type

Monitoring Adapters

Decorator adapters for wrapping existing adapters:

  • MonitoringAddAdapter
  • MonitoringSubtractAdapter
  • MonitoringMultiplyAdapter
  • MonitoringDivideAdapter

All monitoring adapters accept:

  1. Inner adapter to wrap
  2. MonitorService instance

Testing

bun test

Examples

See examples/ directory for more usage examples.

License

Private package (not published to npm)