New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@basic-math/divide

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@basic-math/divide

Type-safe division operation with SafeNumber validation and zero-division protection

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@basic-math/divide

Type-safe division operation with SafeNumber validation and division-by-zero protection.

Installation

npm install @basic-math/divide @basic-math/core

Usage

import { divide } from '@basic-math/divide';

const result = divide(20, 4); // 5
const decimal = divide(10, 3); // 3.333...
const negative = divide(-15, 3); // -5

// Division by zero throws an error
try {
  divide(10, 0); // Throws error
} catch (error) {
  console.error('Cannot divide by zero');
}

Features

  • Type-safe division using SafeNumber
  • Runtime validation
  • Division-by-zero protection
  • Handles positive, negative, and decimal numbers
  • Zero dependencies (except @basic-math/core)

API

divide(a: number, b: number): number

Divides the first number by the second with validation.

Parameters:

  • a - Dividend (number to be divided)
  • b - Divisor (number to divide by)

Returns: Quotient of a divided by b

Throws:

  • TypeViolationError or NumericInvariantError if inputs are invalid
  • Error if divisor is zero

License

MIT

Keywords

math

FAQs

Package last updated on 06 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts