mongez-reinforcements-numbers

Provide TypeScript number utilities for rounding, clamping, safe arithmetic, and formatting.

3|2|Updated Dec 20, 2021
One-click install
npx skills add https://github.com/hassanzohdy/reinforcements --skill mongez-reinforcements-numbers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongez-reinforcements-numbers
Source: https://github.com/hassanzohdy/reinforcements/tree/main/skills/numbers
Command: npx skills add https://github.com/hassanzohdy/reinforcements --skill mongez-reinforcements-numbers

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide a compact suite of numeric helpers that simplify rounding, clamping, safe arithmetic, and formatting in TypeScript projects, reducing boilerplate and errors.

Core Features & Use Cases

  • Rounding utilities with configurable precision (round, floor, ceil, toFixed).
  • Range helpers (clamp, inRange, lerp) for safe numeric operations.
  • Safe arithmetic (safeDivide, percentage, parseNumber) with graceful fallbacks.
  • Formatting (formatBytes, formatNumber, formatDuration) for user-friendly displays.
  • Use cases include data normalization, UI value presentation, and robust financial calculations.

Quick Start

Import the numeric helpers from @mongez/reinforcements and start applying rounding, clamping, and formatting in your TypeScript project.

Frequently Asked Questions about mongez-reinforcements-numbers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I perform safe arithmetic and prevent division by zero errors in TypeScript?

Safe arithmetic in TypeScript prevents undefined results by using utilities like safeDivide and parseNumber to apply graceful fallbacks, ensuring calculations return predictable numeric values instead of throwing runtime errors.

What is the best way to round numbers with configurable precision in a TypeScript project?

Rounding numbers with configurable precision is best handled by utilities that support round, floor, and ceil operations alongside toFixed equivalents, allowing exact decimal control for data normalization and UI value presentation.

How do I format bytes, numbers, and durations for user-friendly UI displays?

Formatting bytes, numbers, and durations for UI displays is achieved through dedicated helpers like formatBytes, formatNumber, and formatDuration, which convert raw numeric values into readable strings for end users.

Does this number utility library have any runtime dependencies?

This number utility library has zero runtime dependencies, functioning as a modular and dependency-free implementation that integrates directly into TypeScript projects without introducing external package overhead.

How do I clamp values and check numeric ranges for safe data normalization?

Clamping values and checking numeric ranges for data normalization is done using range helpers like clamp, inRange, and lerp, which safely constrain numbers within specified minimum and maximum boundaries.

Can I calculate percentages with graceful fallbacks for robust financial calculations?

Calculating percentages with graceful fallbacks for robust financial calculations is supported by a dedicated percentage utility, which safely processes numeric inputs and returns predictable results across TypeScript applications.