Comparing version 2.3.0 to 3.0.0
@@ -12,4 +12,4 @@ /** | ||
module.exports = require('./wrap')(function(a, min, max){ | ||
module.exports = function(a, min, max){ | ||
return max > min ? Math.max(Math.min(a,max),min) : Math.max(Math.min(a,min),max); | ||
}); | ||
}; |
40
index.js
/** | ||
* Composed set of all math utils | ||
* Composed set of all math utils, wrapped | ||
* | ||
* @module mumath | ||
*/ | ||
const wrap = require('./wrap'); | ||
module.exports = { | ||
clamp: require('./clamp'), | ||
within: require('./within'), | ||
round: require('./round'), | ||
precision: require('./precision'), | ||
mod: require('./mod'), | ||
add: require('./add'), | ||
sub: require('./sub'), | ||
min: require('./min'), | ||
max: require('./max'), | ||
div: require('./div'), | ||
lg: require('./lg'), | ||
log: require('./log'), | ||
mult: require('./mult'), | ||
floor: require('./floor'), | ||
ceil: require('./ceil'), | ||
len: require('./len'), | ||
closest: require('./closest'), | ||
order: require('./order'), | ||
mix: require('./mix'), | ||
gt: require('./gt'), | ||
gte: require('./gte'), | ||
lt: require('./lt'), | ||
lte: require('./lte'), | ||
eq: require('./eq'), | ||
ne: require('./ne') | ||
clamp: wrap(require('./clamp')), | ||
within: wrap(require('./within')), | ||
round: wrap(require('./round')), | ||
precision: wrap(require('./precision')), | ||
mod: wrap(require('./mod')), | ||
lg: wrap(require('./lg')), | ||
len: wrap(require('./len')), | ||
closest: wrap(require('./closest')), | ||
order: wrap(require('./order')), | ||
lerp: wrap(require('./lerp')) | ||
}; |
@@ -8,4 +8,4 @@ /** | ||
module.exports = require('./wrap')(function (a, b) { | ||
module.exports = function (a, b) { | ||
return Math.sqrt(a*a + b*b); | ||
}); | ||
}; |
@@ -6,4 +6,4 @@ /** | ||
*/ | ||
module.exports = require('./wrap')(function (a) { | ||
module.exports = function (a) { | ||
return Math.log(a) / Math.log(10); | ||
}); | ||
}; |
@@ -9,3 +9,3 @@ /** | ||
module.exports = require('./wrap')(function (value, left, right) { | ||
module.exports = function (value, left, right) { | ||
//detect single-arg case, like mod-loop or fmod | ||
@@ -31,2 +31,2 @@ if (right === undefined) { | ||
return value; | ||
}); | ||
}; |
/** | ||
* @module mumath/order | ||
*/ | ||
module.exports = require('./wrap')(function (n) { | ||
module.exports = function (n) { | ||
n = Math.abs(n); | ||
var order = Math.floor(Math.log(n) / Math.LN10 + 0.000000001); | ||
return Math.pow(10,order); | ||
}); | ||
}; |
{ | ||
"name": "mumath", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"description": "Practical math utils for components", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,3 +14,3 @@ /** | ||
module.exports = require('./wrap')(function(n){ | ||
module.exports = function(n){ | ||
var s = n + '', | ||
@@ -20,2 +20,2 @@ d = s.indexOf('.') + 1; | ||
return !d ? 0 : s.length - d; | ||
}); | ||
}; |
@@ -34,3 +34,3 @@ # μMath [![Build Status](https://travis-ci.org/dfcreative/mumath.svg?branch=master)](https://travis-ci.org/dfcreative/mumath) [![Code Climate](https://codeclimate.com/github/dfcreative/mumath/badges/gpa.svg)](https://codeclimate.com/github/dfcreative/mumath) <a href="UNLICENSE"><img src="http://upload.wikimedia.org/wikipedia/commons/6/62/PD-icon.svg" width="20"/></a> | ||
### `mix(x, y, ratio)` | ||
### `lerp(x, y, ratio)` | ||
@@ -58,25 +58,1 @@ Return value interpolated between x and y. | ||
`order(123) → 100; order(-0.0003) → 0.0001;` | ||
### `mult(a, b, ...)` | ||
### `div(a, b, ...)` | ||
### `sub(a, b, ...)` | ||
### `add(a, b, ...)` | ||
### `mod(a, b, ...)` | ||
### `min(a, b, ...)` | ||
### `max(a, b, ...)` | ||
### `floor(a, b, ...)` | ||
### `ceil(a, b, ...)` | ||
### `log(a)` | ||
### `lg(a)` | ||
Simple wrappers for arythmetical functions. | ||
### `gt(a,b)` | ||
### `gte(a,b)` | ||
### `lt(a,b)` | ||
### `lte(a,b)` | ||
### `eq(a,b)` | ||
### `ne(a,b)` | ||
Simple conditional functions. |
@@ -16,3 +16,3 @@ /** | ||
module.exports = require('./wrap')(function(value, step) { | ||
module.exports = function(value, step) { | ||
if (step === 0) return value; | ||
@@ -23,2 +23,2 @@ if (!step) return Math.round(value); | ||
return parseFloat(value.toFixed(precision(step))); | ||
}); | ||
}; |
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
module.exports = require('./wrap')(function(a, left, right){ | ||
module.exports = function(a, left, right){ | ||
if (left > right) { | ||
@@ -19,2 +19,2 @@ var tmp = left; | ||
return false; | ||
}); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6331
14
185
57