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

sp-math

v1.0.5

Published

Common Math Functions

Downloads

2

Readme

sp-math

Common Math Functions

Install

  npm i sp-math //or yarn add sp-math

CDN

  <script src="https://unpkg.com/sp-math/dist/index.min.js"></script>
  <script>

  </script>

Usage

  const {
    abs,
    acos,
    asin,
    atan,
    ceil,
    degreeToRotate,
    devideFloat,
    isFloat,
    rotateToDegree,
    cos,
    distance,
    floor,
    comma,
    rotateByDegree,
    pow,
    round,
    sin,
    sqrt,
    tan
  } = require("sp-math")
  • abs(val)

    • {Number} val
      abs(-10);
      // return 10
  • ceil(val)

    • {Number} val
      ceil(1.25);
      // return 2
  • cos(val)

    • {Number} val
      cos(60);
      // return 0.5000000000000001
  • sin(val)

    • {Number} val
      sin(30);
      // return 0.49999999999999994
  • tan(val)

    • {Number} val
      sin(45);
      // return 0.9999999999999999
  • acos(val)

    • {Number} val
      acos(0.5);
      // return 60.00000000000001
  • asin(val)

    • {Number} val
      asin(0.5);
      // return 30.000000000000004
  • atan(val)

    • {Number} val
      atan(1);
      // return 45
  • degreeToRotate(val)

    • {Number} val
      degreeToRotate(180);
      // return 3.141592653589793 Math.PI
  • rotateToDegree(val)

    • {Number} val
      rotateToDegree(Math.PI);
      // return 180
  • distance(p1, p2)

    • {Array} p1 = [0, 0]
    • {Array} p2 = [0, 0]
      distance([1, 1], [2, 2]);
      // return 1.41
  • floor(val)

    • {Number} val
      floor(1.25);
      // return 1
  • pow(x, y, isDeep = false)

    • {Number} x
    • {Number} y
    • {Boolean} isDeep
      pow(2, 5);
      // return 32
      pow(-2, 5);
      // return -32
      pow(4, 0.5, true);
      // return [2, -2]
  • round(val)

    • {Number} val
      round(2.53)
      // return 3
      round(2.15);
      // return 2
  • sqrt(val)

    • {Number} val
    • {Boolean} isDeep
      sqrt(4)
      // return 2
      sqrt(4, true);
      // return [2, -2]
  • devideFloat(val)

    • {Number} val
      devideFloat(4)
      // return [ 4, 1 ] 4/1 = 4
      devideFloat(1.8);
      // return [ 9, 5 ] 9/5 = 1.8
  • comma(val, obj = {fixed:2, hasComma = false})

    • {Number} val
    • {Object} obj
    • {Number} obj.fixed
    • {Boolean} obj.hasComma
      comma('12345.33',{
        fixed: 3
      });
      // return '12345.330'
      comma('12345.33',{
        fixed: 3,
        hasComma: true
      });
      // return '12,345.330'
      comma('12,345.330',{
        fixed: 4,
        hasComma: false
      });
      // return '12345.3300'