🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

math-sum

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

math-sum

Sum numbers

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
1
Created
Source

math-sum

Sum numbers

Install

npm install math-sum

Usage

import sum from 'math-sum';

sum(5, 5);
//=> 10

sum([1, 2, 3, 4]);
//=> 10

BigInt

import sum from 'math-sum';

sum.bigInt(5, 5);
//=> 10n

sum.bigInt([1, 2, 3, 4]);
//=> 10n

sum.bigInt(1, 2n, 3);
//=> 6n

const largeNumber = 9_007_199_254_740_993n; // Number.MAX_SAFE_INTEGER + 2
sum.bigInt(largeNumber, largeNumber);
//=> 18_014_398_509_481_986n

The sum.bigInt() method accepts both regular numbers and BigInts and always returns a BigInt. Regular numbers are converted to BigInts automatically. This is useful when you need to sum numbers that exceed JavaScript's safe integer range.

[!NOTE] The method throws a RangeError if any value is a non-integer number (e.g., 3.14).

  • math-average - Get the average of numbers
  • math-clamp - Clamp a number

Keywords

math

FAQs

Package last updated on 18 Sep 2025

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