@compute.ts/number
Version:
Provide number operators for the computeTS package
1 lines • 6.73 kB
JavaScript
;function divide(r,e){if(void 0===r)throw Error("The numerator value is undefined");if(null===r)throw Error("The numerator value is null");if(isNaN(r))throw Error("The numerator value is not a numeric");if(void 0===e)throw Error("The denominator value is undefined");if(null===e)throw Error("The denominator value is null");if(isNaN(e))throw Error("The denominator value is not a numeric");if(0===e)throw Error("The denominator is 0");return r/e}function equal(r,e){if(void 0===r)throw Error("The left value is undefined");if(null===r)throw Error("The left value is null");if(isNaN(r))throw Error("The left value is not a numeric");if(void 0===e)throw Error("The right value is undefined");if(null===e)throw Error("The right value is null");if(isNaN(e))throw Error("The right value is not a numeric");return r===e}function gt(r,e){if(void 0===r)throw Error("The left value is undefined");if(null===r)throw Error("The left value is null");if(isNaN(r))throw Error("The left value is not a numeric");if(void 0===e)throw Error("The right value is undefined");if(null===e)throw Error("The right value is null");if(isNaN(e))throw Error("The right value is not a numeric");return e<r}function gteq(r,e){if(void 0===r)throw Error("The left value is undefined");if(null===r)throw Error("The left value is null");if(isNaN(r))throw Error("The left value is not a numeric");if(void 0===e)throw Error("The right value is undefined");if(null===e)throw Error("The right value is null");if(isNaN(e))throw Error("The right value is not a numeric");return e<=r}function isEven(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");return r%2==0}function isOdd(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");return r%2!=0}function isPrime(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");if(r<=1)return!1;if(r<=3)return!0;if(r%2==0||r%3==0)return!1;for(var e=5;e*e<=r;e+=6)if(r%e==0||r%(e+2)==0)return!1;return!0}function isNegative(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");return r<0}function isPositive(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");return 0<r}function isZero(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");return 0===r}function lt(r,e){if(void 0===r)throw Error("The left value is undefined");if(null===r)throw Error("The left value is null");if(isNaN(r))throw Error("The left value is not a numeric");if(void 0===e)throw Error("The right value is undefined");if(null===e)throw Error("The right value is null");if(isNaN(e))throw Error("The right value is not a numeric");return r<e}function lteq(r,e){if(void 0===r)throw Error("The left value is undefined");if(null===r)throw Error("The left value is null");if(isNaN(r))throw Error("The left value is not a numeric");if(void 0===e)throw Error("The right value is undefined");if(null===e)throw Error("The right value is null");if(isNaN(e))throw Error("The right value is not a numeric");return r<=e}function minus(r,e){if(void 0===r)throw Error("The left value is undefined");if(null===r)throw Error("The left value is null");if(isNaN(r))throw Error("The left value is not a numeric");if(void 0===e)throw Error("The right value is undefined");if(null===e)throw Error("The right value is null");if(isNaN(e))throw Error("The right value is not a numeric");return r-e}function modulo(r,e){if(void 0===r)throw Error("The numerator value is undefined");if(null===r)throw Error("The numerator value is null");if(isNaN(r))throw Error("The numerator value is not a numeric");if(void 0===e)throw Error("The denominator value is undefined");if(null===e)throw Error("The denominator value is null");if(isNaN(e))throw Error("The denominator value is not a numeric");if(0===e)throw Error("The denominator is 0");return r%e}function neq(r,e){if(void 0===r)throw Error("The left value is undefined");if(null===r)throw Error("The left value is null");if(isNaN(r))throw Error("The left value is not a numeric");if(void 0===e)throw Error("The right value is undefined");if(null===e)throw Error("The right value is null");if(isNaN(e))throw Error("The right value is not a numeric");return r!==e}function number(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");return r}function opposite(r){if(void 0===r)throw Error("The value is undefined");if(null===r)throw Error("The value is null");if(isNaN(r))throw Error("The value is not a numeric");return-r}function randomNumber(r,e){if(void 0===r)throw Error("The min is undefined");if(null===r)throw Error("The min is null");if(isNaN(r))throw Error("The min is not a numeric");if(void 0===e)throw Error("The max is undefined");if(null===e)throw Error("The max is null");if(isNaN(e))throw Error("The max is not a numeric");if(e<r)throw Error("The max value is less than the min value");e-=r;return r+Math.random()*e}function sum(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];for(var i=0,o=0;o<r.length;o++){var t=r[o];if(void 0===t)throw Error("The "+o+"eme value is undefined");if(null===t)throw Error("The "+o+"eme value is null");i+=t}return i}function times(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];for(var i=1,o=0;o<r.length;o++){var t=r[o];if(void 0===t)throw Error("The "+o+"eme value is undefined");if(null===t)throw Error("The "+o+"eme value is null");i*=t}return i}Object.defineProperty(exports,"__esModule",{value:!0}),exports.times=exports.sum=exports.randomNumber=exports.opposite=exports.number=exports.neq=exports.modulo=exports.minus=exports.lteq=exports.lt=exports.isZero=exports.isPositive=exports.isNegative=exports.isPrime=exports.isOdd=exports.isEven=exports.gteq=exports.gt=exports.equal=exports.divide=void 0,exports.divide=divide,exports.equal=equal,exports.gt=gt,exports.gteq=gteq,exports.isEven=isEven,exports.isOdd=isOdd,exports.isPrime=isPrime,exports.isNegative=isNegative,exports.isPositive=isPositive,exports.isZero=isZero,exports.lt=lt,exports.lteq=lteq,exports.minus=minus,exports.modulo=modulo,exports.neq=neq,exports.number=number,exports.opposite=opposite,exports.randomNumber=randomNumber,exports.sum=sum,exports.times=times;