all files / lib/ OverflowHashCode.js

97.14% Statements 34/35
93.75% Branches 15/16
100% Functions 5/5
96.88% Lines 31/32
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                98× 98× 120×   98× 120× 120× 14×   116× 16× 80×   100×       100× 100×     98×      
"use strict";
var OverflowInt_1 = require("./OverflowInt");
var OverflowLong_1 = require("./OverflowLong");
var OverflowHashCode = (function () {
    function OverflowHashCode(seed, PRIME, isInt) {
        if (seed === void 0) { seed = 1; }
        if (PRIME === void 0) { PRIME = 31; }
        if (isInt === void 0) { isInt = true; }
        this.PRIME = PRIME;
        this.overflow = isInt ? new OverflowInt_1.OverflowInt(seed) : new OverflowLong_1.OverflowLong(seed);
    }
    Object.defineProperty(OverflowHashCode.prototype, "value", {
        get: function () {
            return this.overflow.value;
        },
        enumerable: true,
        configurable: true
    });
    OverflowHashCode.prototype.valueOf = function () {
        return this.overflow.value;
    };
    OverflowHashCode.prototype.of = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i - 0] = arguments[_i];
        }
        for (var j = 0; j < args.length; j++) {
            var a = args[j];
            if (Array.isArray(a)) {
                for (var i = 0; i < a.length; i++)
                    this.of(a[i]);
            }
            else if (typeof a === "string") {
                for (var i = 0; i < a.length; i++)
                    this.of(a.charCodeAt(i));
            }
            else Iif (typeof a === "object" || typeof a === "function") {
                this.of(String(a));
            }
            else {
                this.overflow.times(this.PRIME);
                this.overflow.plus(+a);
            }
        }
        return this;
    };
    return OverflowHashCode;
}());
exports.OverflowHashCode = OverflowHashCode;
//# sourceMappingURL=OverflowHashCode.js.map