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.
@daeinc/math
Advanced tools
npm i @daeinc/math
then,
import { modF, ... } from "@daeinc/math"
const clamp: (val: number, min: number, max: number) => number;
Clamp values between min and max (=constrain)
const constrain: (val: number, min: number, max: number) => number;
Alias for clamp()
const dist: (x1: number, y1: number, x2: number, y2: number) => number;
Compute distance between two points
const distSq: (x1: number, y1: number, x2: number, y2: number) => number;
Compute squared distance between two points. There's another version in @daeinc/geom
that takes Pt: number[]
type as arguments.
const floorF: (n: number, digit: number) => number;
Floor a float value to the specified digit.
const map: (
val: number,
s: number,
e: number,
ns: number,
ne: number
) => number;
Map a value from one range to another.
const mix: (a: number, b: number, t: number) => number;
Linear interpolation (=lerp)
const lerp: (a: number, b: number, t: number) => number;
Alias for mix()
const mod: (n: number, max: number) => number;
Modular operation
const modF: (n: number, max: number, precision?: number) => number;
Modulo(%) operation for float numbers up to precision digit.
const modIncl: (n: number, max: number) => number;
Inclusive modulo operation. modIncl(1, 3)
will include 3
. It can handle negative number and returns positive value
const polarToCartesian: (radius: number, angle: number) => number[];
Converts polar coodrinate to cartesian coordinate. To use a different center point than the default [0, 0]
, do something like this:
result.map((v, i) => v + center[i]);
const reflect: (num: number, axis: number) => number;
Rreflect a scalar value along axis. If you want to reflect a point in 2d space, you can use reflectPoint()
from @daeinc/geom
.
const roundF: (n: number, digit: number) => number;
Round a float value. Good for drawing shapes to include the maximum value (round up)
const snapBy: (n: number, inc: number) => number;
Snap value to increment using Math.round()
.
const snapToArray: (n: number, snapArr: number[]) => number;
Snap to a closest value in an array.
MIT
FAQs
Math utilities
The npm package @daeinc/math receives a total of 105 weekly downloads. As such, @daeinc/math popularity was classified as not popular.
We found that @daeinc/math demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.