
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
armath.js is a simple math library for performing basic Mathematical operations within JavaScript
arMath.js stands for Arithmetic Math.js, which is a simple library made in JavaScript to perform basic mathematical operations
First install the package:
npm i armath.js
Then require the package in your project file as belows
const arMath = require("armath.js");
arMath.js provides you with following capbilities -
Let me show you a few examples
Using arMath.add() function we will be adding 1 and 2, It will throw an error if the input provided isn't a number!
const arMath = require("armath.js");
const output = arMath.add(1,2);
console.log(output);
And in the console we can see the results as below
3.0
Like this you can use arMath.sub(), arMath.multiply(), arMath.divide() as your desired requirement
arMath.addArray() is the function we will require for adding the arrays
let me show you a simple example
const arMath = require("armath.js");
const numbers = [0,1,2,3,4,5,6,7,8,9,10]
console.log(arMath.addArray(numbers))
Output will be as below
55.0
Similarly we can use the other functions too - arMath.addArray(), arMath.subArray(), arMath.multiplyArray(), arMath.divideArray(), You just have to pass an array to the functions like the above scenario
To find the modulus of two numbers
use arMath.modulus(a, b) , where a & b are any two numbers
You have to pass in two parameters here, i.e, the dividend and the divisor
Let me show you the example:
const arMath = require("armath.js");
let output = arMath.modulus(2,4);
console.log(output);
Output will be as below
2
To find the modulus of an array of numbers use arMath.modulusArray(array, num), where num is any number and array should be proper array of numbers or else it will throw an error
Let me show you a basic example
const arMath = require("armath.js");
const array = [1,2,3,4,5]; // An array of numbers
const number = 2 // Any number of your choice
console.log(arMath.modulusArray(array, number));
Output
[ 1, 0, 1, 0, 1 ]
To check if its a prime or not you need to use the isPrime(num) function and pass in any number in place of num
Example
const arMath = require("armath.js");
console.log(arMath.isPrime(2));
Output will be
true
If we pass in any composite number, then output will be
false
To check if a number is positive or not, use isPositive(num) function and pass in a number
It will show true if its positive, zero in case of 0 and false in case of negative
Example
const arMath = require("armath.js");
console.log(arMath.isPositive(3));
Output
true
To find the square use arMath.square(num) & for square root use arMath.sqrt(num)
const arMath = require("armath.js");
const num1 = 5; // Any number of your choice
const num2 = 49;
console.log(arMath.square(num1)); // Output will be 25
console.log(arMath.sqrt(num2)); // Output will be 7
We can use similar approach for cube/cuberoot ,i.e, arMath.cube(a) & arMath.cbrt(a), where a is any number
To floor divide you need to use arMath.floorDivide()
Example
const arMath = require("armath.js");
console.log(arMath.floorDivide(2,4)); // Replace with any number of your choice
It will give you the result of floor division as the output ,i.e, 0
For any bugs/issues/feature requests feel free to open up an issue here at https://github.com/blazeinferno64/arMath.js
Thanks for reading :)
Have a great day ahead!
FAQs
armath.js is a simple math library for performing basic Mathematical operations within JavaScript
We found that armath.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.