Sha256: 8f1b18f8f639a9f47a804e2e6eda53209910b244f6993dd552676aa27fd9ce7c
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 Bytes
Contents
# frozen_string_literal: true require "murmurhash3" module Absmartly # VariantAssigner class VariantAssigner def initialize(_unit) # this._unitHash = murmur3_32(stringToUint8Array(unit).buffer); end def assign(split, seed_hi, seed_lo) prob = probability(seed_hi, seed_lo) chooseVariant(split, prob) end # private # def chooseVariant(split, prob) # # end # # def probability(seedHi, seedLo) # const key = this._unitHash; # const buffer = new ArrayBuffer(12) # const view = new DataView(buffer) # view.setUint32(0, seedLo, true) # view.setUint32(4, seedHi, true) # view.setUint32(8, key, true) # # murmur3_32(buffer) * (1.0 / 0xffffffff) # end end end # DataView.new(new_bytes_buffer, src_offset, new_bytes.length)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
absmartly-sdk-1.1.1 | lib/absmartly/variant_assigner.rb |