numba
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Numba

Numba is a class that provides a simple and convenient way to perform various mathematical operations on numbers. The class is designed to be used in chains, allowing for easy and concise mathematical expressions.

Installation

To install Numba, run the following command in your terminal:

npm install numba

API

  • pow(x: number): Returns the power of the number.
  • powNorm(x: num, ceiling: num): Returns the power of the number, normalized to 0..1.
  • powSign(x: num): Returns the sign of the power of the number.
  • abs: Returns the absolute value of the number.
  • sign: Returns the sign of the number.
  • log(base = Math.E): Returns the logarithm of the number.
  • sin: Returns the sine of the number.
  • cos: Returns the cosine of the number.
  • hyperSin: Returns the hyperbolic sine of the number.
  • aHyperSin: Returns the inverse hyperbolic sine of the number.
  • floor: Returns the floor of the number.
  • floorLeftover: Returns the floor leftover of the number.
  • ceil: Returns the ceiling of the number.
  • round: Returns the rounded value of the number.
  • rough(precision = 3): Returns the rough value of the number.
  • add(x: num): Returns the sum of the number and x.
  • sub(x: num): Returns the difference between the number and x.
  • mul(x: num): Returns the product of the number and x.
  • div(x: num): Returns the division between the number and x.
  • freq2bark: Converts frequency to bark.
  • bark2freq: Converts bark to frequency.
  • note2freq: Converts note to frequency.
  • freq2note: Converts frequency to note.
  • magnitudeSq(other: num): Returns the magnitude squared of the number and other.
  • magnitude(other: num): Returns the magnitude of the number and other.
  • exp: Returns the exponential of the number.
  • mix(a: num, b: num): Returns a mix of a and b with the number as a factor.
  • clamp(a: num, b: num): Returns the number clamped between a and b.
  • unMix(a: num, b: num): Returns the un-mixed value of the number.
  • remix(fromStart: num, fromEnd: num, toStart: num, toEnd: num): Returns the remixed value of the number.
  • isInteger: Returns whether the number is an integer.
  • isPowOf2: Returns whether the number is a power of 2.
  • powOf2Above: Returns the nearest power of 2 above the number.
  • powOf2Below: Returns the nearest power of 2 below the number.
  • toFixedExp(digits = 2): Returns the number in fixed exponential form.

Usage

To use Numba, simply import the class into your project and start chaining mathematical operations:

// do this only once in the entire project:
Numba.includeMe();


// now you can use Numba in your code, with nice chaining:

const result = num
  .pow(2)
  .round()
  .toFixedExp();

console.log(result); // 100

Readme

Keywords

none

Package Sidebar

Install

npm i numba

Weekly Downloads

4

Version

0.0.2

License

MIT

Unpacked Size

17.9 kB

Total Files

7

Last publish

Collaborators

  • shalmu