New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@daeinc/math

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daeinc/math - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

89

dist/index.d.ts
declare const PI: number;
declare const TWO_PI: number;
/**
* clamp values between min and max (=constrain)
* Clamp values between min and max (= `constrain`)
* @param val

@@ -25,3 +25,4 @@ * @param min

/**
* returns squared distance
* Get squared distance between two points
*
* @param x1

@@ -41,3 +42,3 @@ * @param y1

/**
* drop decimals after digit. good for array index (floor)
* Drop decimals after digit. Good for array index (floor)
* @param n float number

@@ -49,8 +50,9 @@ * @param digit how many decimal digits to keep

/**
* Map value from the original range to a new range
*
* @param val
* @param s
* @param e
* @param ns
* @param ne
* @param val - value to transform
* @param s - start value of original range
* @param e - end value of original range
* @param ns - start value of new range
* @param ne - end value of new range
* @returns

@@ -60,6 +62,7 @@ */

/**
* linear interpolation (=lerp)
* @param a start value
* @param b stop value
* @param t amount 0..1
* Linear interpolation (= `lerp`)
*
* @param a - start value
* @param b - stop value
* @param t - amount `0..1`
* @returns

@@ -69,7 +72,12 @@ */

/**
* alias for mix()
* Alias for mix()
*/
declare const lerp: (a: number, b: number, t: number) => number;
/**
* NOTE: it may not be accurate with non-integer numbers.
* Can handle negative number and returns positive value
* Use `modF()` for non-integer values.
*
* @example
* mod(-1, 3) // returns 2
*
* @param n

@@ -81,3 +89,7 @@ * @param max

/**
* modulo(%) for float numbers up to precision digit.
* Modulo(%) for float numbers up to precision digit.
*
* @example
* modF(1.2, 1, 6); // returns 0.2
*
* @param n original number

@@ -90,4 +102,9 @@ * @param max modulo

/**
* inclusive modulo. modIncl(1, 3) will include 3.
* can handle negative number and returns positive value
* Inclusive modulo. modIncl(1, 3) will include 3. This only works with positive `n`.
* Can handle negative number and returns positive value
*
* @example
* modIncl(3, 3) // returns 3
* modIncl(-3, 3) // returns 0
*
* @param n number to update

@@ -99,5 +116,6 @@ * @param max number to divide with

/**
* converts polar coordinate to cartesian. to update center, result.map((v,i)=> v + center[i])
* Converts polar coordinate to cartesian. to update center, result.map((v,i)=> v + center[i])
*
* @param radius
* @param angle in radians
* @param angle - in radians
* @returns

@@ -107,5 +125,9 @@ */

/**
* reflect a scalar value along axis. good for creating reflected version.
* @param num number to flip
* @param axis value to reflect against
* Reflect a scalar value along axis. good for creating reflected version.
*
* @example
* reflect(3.2, 0); // -3.2
*
* @param num - number to flip
* @param axis - value to reflect against
* @returns

@@ -115,3 +137,4 @@ */

/**
* good for drawing shapes to include the maximum value (round up)
* Good for drawing shapes to include the maximum value (round up)
*
* @param n float number

@@ -123,5 +146,6 @@ * @param digit how many float digits to keep

/**
* snap value to increment
* @param n original number
* @param inc increment to snap to.
* Snap value to increment
*
* @param n - original number
* @param inc - increment to snap to.
* @returns

@@ -132,6 +156,11 @@ *

/**
* snap to a value in array. whatever is closest to.
* @param n original number
* @param snapArr values to snap to
* @returns {number | undefined}
* Snap to a value in array. whatever is closest to.
*
* @example
* snapToArray(3, [1.4, 1.5, 4.08]) // 4.08
* snapToArray(-100, [-10, 2, 40]) // -10
*
* @param n - original number
* @param snapArr - values to snap to
* @returns
*/

@@ -138,0 +167,0 @@ declare const snapToArray: (n: number, snapArr: number[]) => number;

@@ -62,3 +62,3 @@ // index.ts

}
throw new Error("snapToArray(): did not meet any condition");
throw new Error("could not snap to any value");
};

@@ -65,0 +65,0 @@

{
"name": "@daeinc/math",
"version": "0.6.0",
"version": "0.6.1",
"description": "Math utilities",

@@ -22,4 +22,6 @@ "type": "module",

"devDependencies": {
"tsup": "^6.6.3",
"vitest": "^0.28.5"
"tsup": "^8.0.2",
"typescript": "^5.3.3",
"vite": "^5.1.4",
"vitest": "^1.3.1"
},

@@ -26,0 +28,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc