@splitsoftware/splitio-commons
Version:
Split JavaScript SDK common components
47 lines (46 loc) • 1.7 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.x86Fmix = exports.x86Rotl = exports.x86Multiply = exports.UTF16ToUTF8 = void 0;
var utfx_1 = require("./utfx");
function UTF16ToUTF8(key) {
var sd;
(0, utfx_1.encodeUTF16toUTF8)((0, utfx_1.stringSource)(key), sd = (0, utfx_1.stringDestination)());
return sd();
}
exports.UTF16ToUTF8 = UTF16ToUTF8;
/*!
* +----------------------------------------------------------------------------------+
* | murmurHash3.js v3.0.0 (http://github.com/karanlyons/murmurHash3.js) |
* | A TypeScript/JavaScript implementation of MurmurHash3's hashing algorithms. |
* |----------------------------------------------------------------------------------|
* | Copyright (c) 2012-2020 Karan Lyons. Freely distributable under the MIT license. |
* +----------------------------------------------------------------------------------+
*/
function x86Multiply(m, n) {
//
// Given two 32bit ints, returns the two multiplied together as a
// 32bit int.
//
return ((m & 0xffff) * n) + ((((m >>> 16) * n) & 0xffff) << 16);
}
exports.x86Multiply = x86Multiply;
function x86Rotl(m, n) {
//
// Given a 32bit int and an int representing a number of bit positions,
// returns the 32bit int rotated left by that number of positions.
//
return (m << n) | (m >>> (32 - n));
}
exports.x86Rotl = x86Rotl;
function x86Fmix(h) {
//
// Given a block, returns murmurHash3's final x86 mix of that block.
//
h ^= h >>> 16;
h = x86Multiply(h, 0x85ebca6b);
h ^= h >>> 13;
h = x86Multiply(h, 0xc2b2ae35);
h ^= h >>> 16;
return h;
}
exports.x86Fmix = x86Fmix;
;