all files / lib/ OverflowHashCodeBig.js

91.3% Statements 42/46
71.43% Branches 10/14
100% Functions 9/9
97.67% Lines 42/43
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78  18× 18× 18× 18× 18× 18× 18×               24×           12×           10×           12× 12× 78×   12×     294× 294× 360×   294× 360× 360× 12× 42×   348× 48× 240×   300×       300×     294×    
"use strict";
var OverflowBig_1 = require("./OverflowBig");
var OverflowHashCodeBig = (function () {
    function OverflowHashCodeBig(_seed, _PRIME, _byteLength) {
        Iif (_seed === void 0) { _seed = 1; }
        Iif (_PRIME === void 0) { _PRIME = 31; }
        Iif (_byteLength === void 0) { _byteLength = 64; }
        this._seed = _seed;
        this._PRIME = _PRIME;
        this._byteLength = _byteLength;
        this.overflow = new OverflowBig_1.OverflowBig(_seed, _byteLength);
    }
    Object.defineProperty(OverflowHashCodeBig.prototype, "seed", {
        get: function () {
            return String(this._seed);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(OverflowHashCodeBig.prototype, "prime", {
        get: function () {
            return this._PRIME;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(OverflowHashCodeBig.prototype, "byteLength", {
        get: function () {
            return this._byteLength;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(OverflowHashCodeBig.prototype, "value", {
        get: function () {
            return this.overflow.value;
        },
        enumerable: true,
        configurable: true
    });
    OverflowHashCodeBig.prototype.valueOf = function () {
        return this.overflow.value;
    };
    OverflowHashCodeBig.prototype.of = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        return new OverflowHashCodeBig(hash.apply(void 0, [this.overflow, this.prime].concat(args)).value, this.prime, this.byteLength);
    };
    return OverflowHashCodeBig;
}());
exports.OverflowHashCodeBig = OverflowHashCodeBig;
function hash(overflow, prime) {
    var args = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        args[_i - 2] = 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++)
                overflow = hash(overflow, prime, a[i]);
        }
        else if (typeof a === "string") {
            for (var i = 0; i < a.length; i++)
                overflow = hash(overflow, prime, a.charCodeAt(i));
        }
        else Iif (typeof a === "object" || typeof a === "function") {
            overflow = hash(overflow, prime, String(a));
        }
        else {
            overflow = overflow.times(prime).plus(a);
        }
    }
    return overflow;
}
//# sourceMappingURL=OverflowHashCodeBig.js.map