
Research
/Security News
jscrambler npm Package Compromised in Supply Chain Attack
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.
Common Math Functions
npm i sp-math //or yarn add sp-math
<script src="https://unpkg.com/sp-math/dist/index.min.js"></script>
<script>
</script>
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)
abs(-10);
// return 10
ceil(val)
ceil(1.25);
// return 2
cos(val)
cos(60);
// return 0.5000000000000001
sin(val)
sin(30);
// return 0.49999999999999994
tan(val)
sin(45);
// return 0.9999999999999999
acos(val)
acos(0.5);
// return 60.00000000000001
asin(val)
asin(0.5);
// return 30.000000000000004
atan(val)
atan(1);
// return 45
degreeToRotate(val)
degreeToRotate(180);
// return 3.141592653589793 Math.PI
rotateToDegree(val)
rotateToDegree(Math.PI);
// return 180
distance(p1, p2)
distance([1, 1], [2, 2]);
// return 1.41
floor(val)
floor(1.25);
// return 1
pow(x, y, isDeep = false)
pow(2, 5);
// return 32
pow(-2, 5);
// return -32
pow(4, 0.5, true);
// return [2, -2]
round(val)
round(2.53)
// return 3
round(2.15);
// return 2
sqrt(val)
sqrt(4)
// return 2
sqrt(4, true);
// return [2, -2]
devideFloat(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})
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'
FAQs
Common Math Functions
The npm package sp-math receives a total of 7 weekly downloads. As such, sp-math popularity was classified as not popular.
We found that sp-math demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.

Research
/Security News
A malicious .NET package is typosquatting the Braintree SDK to steal live payment card data, merchant API keys, and host secrets from production apps.

Security News
/Research
Compromised Injective SDK npm version 1.20.21 exfiltrates wallet private keys and mnemonics through fake telemetry functionality.