hu
Version:
Functional utility helper library
96 lines • 2.65 kB
JavaScript
{
var _ns_ = {
id: 'hu.lib.macros',
doc: void 0
};
var hu_lib_function = require('./function');
var curry = hu_lib_function.curry;
var compose = hu_lib_function.compose;
var hu_lib_type = require('./type');
var isString = hu_lib_type.isString;
var isArray = hu_lib_type.isArray;
var isNumber = hu_lib_type.isNumber;
var isUndef = hu_lib_type.isUndef;
var isObject = hu_lib_type.isObject;
}
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
{
var _ns_ = {
id: 'hu.lib.number',
doc: void 0
};
var hu_lib_type = require('./type');
var isNumber = hu_lib_type.isNumber;
}
var max = exports.max = Math.max;
var min = exports.min = Math.min;
var abs = exports.abs = Math.abs;
var round = exports.round = Math.round;
var random = exports.random = Math.random;
var floor = exports.floor = Math.floor;
var sin = exports.sin = Math.sin;
var tan = exports.tan = Math.tan;
var cos = exports.cos = Math.cos;
var asin = exports.asin = Math.asin;
var atan = exports.atan = Math.atan;
var atan2 = exports.atan2 = Math.atan2;
var ceil = exports.ceil = Math.ceil;
var exp = exports.exp = Math.exp;
var sqrt = exports.sqrt = Math.sqrt;
var PI = exports.PI = Math.PI;
var odd = exports.odd = function odd(n) {
return n % 2 > 0 || n % 2 < 0;
};
var isOdd = exports.isOdd = odd;
var even = exports.even = function even(n) {
return n % 2 === 0;
};
var isEven = exports.isEven = even;
var lower = exports.lower = function lower() {
var args = Array.prototype.slice.call(arguments, 0);
return curry(function (x, y) {
return x < y;
}).apply(void 0, args);
};
var isLower = exports.isLower = lower;
var higher = exports.higher = function higher() {
var args = Array.prototype.slice.call(arguments, 0);
return curry(function (x, y) {
return x > y;
}).apply(void 0, args);
};
var isHigher = exports.isHigher = higher;
var inc = exports.inc = function inc(x) {
return x + 1;
};
var dec = exports.dec = function dec(x) {
return x - 1;
};
var signum = exports.signum = function signum(x) {
return x === 0 ? 0 : x < 0 ? -1 : x > 0 ? 1 : void 0;
};
var isNegative = exports.isNegative = function isNegative(x) {
return x < 0;
};
var negate = exports.negate = function negate(x) {
return abs(x) * (signum(x) >= 0 ? -1 : 1);
};
var recip = exports.recip = function recip(x) {
return 1 / x;
};
var div = exports.div = function div() {
var args = Array.prototype.slice.call(arguments, 0);
return curry(function (x, y) {
return floor(x / y);
}).apply(void 0, args);
};