Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
MathTools - is a javascript/node.js module providing some advanced mathematics functionalities
======= MathTools - is a javascript/node.js module providing some advanced mathematics functionalities.
npm install math-tools
For the browser, you can install with bower:
bower install math-tools
nodejs
var mathTools = require('math-tools');
browser
<script src="math-tools.js"></script>
A standard import of var mathTools = require('math-tools')
is assumed in all of the code examples. The import results in an object having the following public properties:
isNumber
- a function that checks if the given value is a number.isArray
- a function that checks if the given value is an array.isObject
- a function that checks if the given value is an object.isInteger
- a function that checks if the given number is an integer.isPrime
- determine whether a number n is prime.sum
- determine the sum of a set of numbers.subtraction
- subtracts elements from one another in array.product
- determine the product of a set of numbers.avg
- calculate the average value of a set of numbers in array.factorial
- determine the factorial (n!) of a number n.fibonacci
- a function that generates the fibonacci numbers up to a number n.gcd
- determine the greastest common divisor amongst two integers.lcm
- determine the least common multiple amongst two integers.standardDeviation
- determine the standard deviation for a set of values.adaptiveSimpsonQuadrature
- calculate integral of a function from a to b using adaptive simpson quadrature.trapezoidal
- calculate integral of a function from a to b using trapezoidal rule.Examples
isPrime: Determine whether a number n is prime.
console.log(mathTools.isPrime(16)); // false
console.log(mathTools.isPrime(17)); // true
sum: Determine the sum of a set of numbers.
var s1 = mathTools.sum([1,2,3]);
var s2 = mathTools.sum([{a: 1},{b: 2},{a: 3}], 'a');
console.log(s1); // 6
console.log(s2); // 4
subtraction: Subtracts elements from one another in array.
var s1 = mathTools.subtraction([1,2,3]);
var s2 = mathTools.subtraction([{a: 1},{b: 2},{a: 3}], 'a');
console.log(s1); // -4
console.log(s2); // -2
product: Determine the product of a set of numbers.
var p1 = mathTools.product([1,2,3]);
var p2 = mathTools.product([{a: 1},{b: 2},{a: 3}], 'a');
console.log(p1); // 6
console.log(p2); // 3
avg: Calculate the average value of a set of numbers in array.
console.log(mathTools.avg([1,2,3,4,5])); // 3
factorial: Determine the factorial (n!) of a number n.
console.log(mathTools.factorial(5)); // 120
fibonacci: Generates n fibonacci numbers.
console.log(mathTools.fibonacci(5)); // [0, 1, 1, 2, 3]
console.log(mathTools.fibonacci(12)); // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
gcd: Calculate the greastest common divisor amongst two integers.
console.log(mathTools.gcd(6,9)); // 3
lcm: Calculate the least common multiple amongst two integers.
console.log(mathTools.gcd([6,9])); // 18
standardDeviation: Determine the standard deviation for a set of values.
console.log(mathTools.standardDeviation([2,3,4,5])); // 1.118033988749895
adaptiveSimpson: Calculate integral of a function from a to b using adaptive simpson quadrature.
var myFunc = function(x) {
return 2 * x + 1;
};
console.log(adaptiveQuadrature(myFunc, 1, 2)); // 4
trapezoidal: Calculate integral of a function from a to b using Trapezoidal rule with n subintervals. By default, the value of subintervals is 200.
var myFunc = function(x) {
return 2 * x + 1;
};
console.log(trapezoidRule(myFunc, 1, 2, 200)); // 4
FAQs
MathTools - is a javascript/node.js module providing some advanced mathematics functionalities
The npm package math-tools receives a total of 134 weekly downloads. As such, math-tools popularity was classified as not popular.
We found that math-tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.