all files / lib/ OverflowInt.js

100% Statements 39/39
80% Branches 8/10
100% Functions 9/9
100% Lines 36/36
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                151× 151× 151×   51×   57× 57× 57× 1681×   57×     219× 218× 217×      
"use strict";
var OverflowInt = (function () {
    function OverflowInt(_value, MIN_SAFE_VALUE, MAX_SAFE_VALUE) {
        if (_value === void 0) { _value = 0; }
        Eif (MIN_SAFE_VALUE === void 0) { MIN_SAFE_VALUE = -2147483648; }
        Eif (MAX_SAFE_VALUE === void 0) { MAX_SAFE_VALUE = 2147483647; }
        this._value = _value;
        this.MIN_SAFE_VALUE = MIN_SAFE_VALUE;
        this.MAX_SAFE_VALUE = MAX_SAFE_VALUE;
        this._value = this.valCheck(this._value);
    }
    Object.defineProperty(OverflowInt.prototype, "value", {
        get: function () {
            return this._value;
        },
        enumerable: true,
        configurable: true
    });
    OverflowInt.prototype.valueOf = function () {
        return this._value;
    };
    OverflowInt.prototype.plus = function (v) {
        v = this.valCheck(v);
        this._value = (this._value + v) | 0;
        return this;
    };
    OverflowInt.prototype.minus = function (v) {
        return this.plus(v * -1);
    };
    OverflowInt.prototype.times = function (v) {
        v = this.valCheck(v);
        var v2 = this._value;
        for (var i = 1; i < v; i++) {
            this._value = (this._value + v2) | 0;
        }
        return this;
    };
    OverflowInt.prototype.divide = function (v) {
        this._value = (this._value / this.valCheck(v)) | 0;
        return this;
    };
    OverflowInt.prototype.valCheck = function (v) {
        if (v > this.MAX_SAFE_VALUE)
            throw new RangeError("The given integer is greater than the MAX_SAFE_VALUE.");
        if (v < this.MIN_SAFE_VALUE)
            throw new RangeError("The given integer is less than the MIN_SAFE_VALUE.");
        return v | 0;
    };
    return OverflowInt;
}());
exports.OverflowInt = OverflowInt;
//# sourceMappingURL=OverflowInt.js.map