forked from quic-issues/427e7578-d7bf-49c8-aee9-2dd999e25316
implemented frontend including separate message system; started to implement backend
This commit is contained in:
35
yjs-poll/node_modules/lib0/prng/Xorshift32.js
generated
vendored
Normal file
35
yjs-poll/node_modules/lib0/prng/Xorshift32.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @module prng
|
||||
*/
|
||||
|
||||
import * as binary from '../binary.js'
|
||||
|
||||
/**
|
||||
* Xorshift32 is a very simple but elegang PRNG with a period of `2^32-1`.
|
||||
*/
|
||||
export class Xorshift32 {
|
||||
/**
|
||||
* @param {number} seed Unsigned 32 bit number
|
||||
*/
|
||||
constructor (seed) {
|
||||
this.seed = seed
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this._state = seed
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random signed integer.
|
||||
*
|
||||
* @return {Number} A 32 bit signed integer.
|
||||
*/
|
||||
next () {
|
||||
let x = this._state
|
||||
x ^= x << 13
|
||||
x ^= x >> 17
|
||||
x ^= x << 5
|
||||
this._state = x
|
||||
return (x >>> 0) / (binary.BITS32 + 1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user