Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mumath

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mumath - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

50

index.js

@@ -7,16 +7,42 @@ /**

module.exports = {
betwee: between,
isBetween: isBetween,
toPrecision: toPrecision,
getPrecision: getPrecision
between: decorate(between),
isBetween: decorate(isBetween),
toPrecision: decorate(toPrecision),
getPrecision: decorate(getPrecision)
};
/**
* Get fn wrapped with array attrs recognition
*
* @return {Function} Target method recognizing arrays
*/
function decorate(fn){
return function(a){
if (a instanceof Array) {
var result = [], args = arguments, slice;
for (var i = 0; i < a.length; i++){
slice = [];
for (var j = 0, l = args.length; j < l; j++){
val = args[j] instanceof Array ? args[j][i] : args[j];
val = val || 0;
slice.push(val);
}
result.push(fn.apply(this, slice));
}
return result;
} else {
return fn.apply(this, arguments);
}
};
}
/**
* Clamper
* Clamper.
* Detects proper clamp min/max.
*
* @param {number} a Current value to cut off
* @param {number} min Left limit
* @param {number} max Right limit
* @param {number} min One side limit
* @param {number} max Other side limit
*

@@ -27,3 +53,3 @@ * @return {number} Clamped value

function between(a, min, max){
return max > min ? Math.max(Math.min(a,max),min) : Math.max(Math.min(a,min),max)
return max > min ? Math.max(Math.min(a,max),min) : Math.max(Math.min(a,min),max);
}

@@ -57,8 +83,8 @@

* @example
* round(213.34, 1) == 213
* round(213.34, .1) == 213.3
* round(213.34, 10) == 210
* toPrecision(213.34, 1) == 213
* toPrecision(213.34, .1) == 213.3
* toPrecision(213.34, 10) == 210
*/
function round(value, step) {
function toPrecision(value, step) {
step = parseFloat(step);

@@ -65,0 +91,0 @@ if (step === 0) return value;

{
"name": "mumath",
"version": "0.0.1",
"version": "0.1.0",
"description": "Micro math methods: isBetween, between, getPrecition, toPrecision",

@@ -5,0 +5,0 @@ "main": "index.js",

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