npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

require-math

v3.3.1

Published

This package helps with basic mathematic calculations and computations. Including geometric and 2D-shape formulas.

Downloads

101

Readme

require-math

require-math is an extension of JavaScript's built-in Math Object. It allows you to work with geometric formulas, 2D-shape formulas, and basic math calculations. Try it out with Node.js npm: https://www.npmjs.com/package/require-math github: https://github.com/jesushilarioh/require-math

Install

npm i require-math

Start

// Load all categories 
const require_math = require("require-math");

// Load methods for basic-math
const basic_math    = require("require-math/basic-math");

// Load methods for formulas
const math_formulas = require("require-math/formulas");

// Load methods for 2D-shapes
const shapes_2D     = require("require-math/2D-shapes");

Methods

basic-math

.Add()

require_math.Add(1, 2); // 3

.Add_All()

require_math.Add_All(3, 3, 3); // 9

// Or arguments as an array
var add_array = [3, 3, 3];
require_math.Add_All.apply(null, add_array); // 9

.Divide()

require_math.Divide(1, 2);  // 0.5

.Modulus()

require_math.Modulus(1, 2); // 1

.Multiply()

require_math.Multiply(1, 2);  // 2

.Subtract()

require_math.Subtract(1, 2);  // -1

.Subtract_All()

require_math.Subtract_All(30, 50, 200); // 120
// Or arguments as an array
var arr = [30, 50, 200];
require_math.Subtract_All.apply(null, arr); // 120

formulas

.Area = {}

.Annulus: {average_radius_width_defined, inner_outer_radius_defined}

.average_radius_width_defined(average radius, width)
require_math.Area.Annulus.average_radius_width_defined(45, 5); // 1413.7166941154069
.inner_outer_radius_defined(inner radius, outer radius)
require_math.Area.Annulus.inner_outer_radius_defined(34, 6); // -3518.583772020568

.Circle(radius)

require_math.Area.Circle(25); // 1963.4954084936207

.Ellipse(semimajor axis 1, semimajor axis 2)

require_math.Area.Ellipse(2, 5);  // 31.41592653589793

.Equilateral_Triangle(side)

require_math.Area.Equilateral_Triangle(5); // 10.825317547305483

.Parallelogram(base, height)

require_math.Area.Parallelogram(2, 5); // 10

.Rectangle(length, width)

require_math.Area.Rectangle(2, 5); // 10

.Regular_Polygon: {number_of_sides_and_side_length_defined, number_of_sides_defined}

.number_of_sides_and_side_length_defined(number of sides, side length)
require_math.Area.Regular_Polygon.number_of_sides_and_side_length_defined(3, 4); // 6.928203230275511
.number_of_sides_defined(number of sides, circumradius)
require_math.Area.Regular_Polygon.number_of_sides_defined(6, 5)); // 64.9519052838329

.Sector_Of_Circle(angle in radians, radius)

require_math.Area.Sector_Of_Circle(55, 20);    // 11000

.Square(side)

require_math.Area.Square(25);  // 625

.Trapezoid(base 1, base 2, height)

require_math.Area.Trapezoid(2, 5, 3);  // 10.5

.Triangle(base, height)

require_math.Area.Triangle(2, 5); //5

.Volume = {}

.Cube(side)

require_math.Volume.Cube(3);  // 27

.Cylinder(radius, height)

require_math.Volume.Cylinder(3, 4);  // 113.09733552923255

.Pyramid(base, height)

require_math.Volume.Pyramid(3, 4); // 4

.Rectangular_Prism(length, width, height)

require_math.Volume.Rectangular_Prism(3, 4, 5);  // 60

.Sphere(radius)

require_math.Volume.Sphere(2); // 33.510321638291124

2D-shapes

.Annulus = {}

.Area: {average_radius_width_defined, inner_outer_radius_defined}

.average_radius_width_defined(average radius, width)
require_math.Annulus.Area.average_radius_width_defined(45, 5); // 1413.7166941154069
.inner_outer_radius_defined(inner radius, outer radius)
require_math.Annulus.Area.inner_outer_radius_defined(34, 6); // -3518.583772020568

.Average_Radius(inner radius, outer radius)

require_math.Annulus.Average_Radius(5, 6); // 5.5

.Width(inner radius, outer radius)

require_math.Annulus.Width(25, 4); // -21

.Circle = {}

.Area(radius)

require_math.Circle.Area(3);    // 28.274333882308138

.Circumference: {diameter_defined, radius_defined}

.diameter_defined(diameter)
require_math.Circle.Circumference.diameter_defined(68);    // 213.62830044410595
.radius_defined(radius)
require_math.Circle.Circumference.radius_defined(67);  // 420.97341558103227

.Diameter(radius)

require_math.Circle.Diameter(29);  // 58

.Ellipse = {}

.Area(semimajor axis, semiminor axis)

require_math.Ellipse.Area(5, 6);   // 94.24777960769379

.Circumference(semimajor axis, semiminor axis)

require_math.Ellipse.Circumference(2, 35); // 142.54116485619627

.Equilateral_Triangle = {}

.Area(side)

require_math.Equilateral_Triangle.Area(25);    // 270.6329386826371

.Height(side)

require_math.Equilateral_Triangle.Height(25);  // 21.650635094610966

.Parallelogram = {}

.Area(base, height)

require_math.Parallelogram.Area(5, 6); // 30

.Perimeter(side, base)

require_math.Parallelogram.Perimeter(2, 6); // 16