Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
A simple copy-and-paste implementation of Johannes Baagøe's Alea PRNG
Mostly packaged so I can easily include it in my projeccts. Nothing more
JavaScript's Math.random() is fast, but has problems. First, it isn't seedable, second, its randomness leaves a bit to be desired. Johannes Baagøe has done some great work in trying to find a more modern PRNG algorithm that performs well on JavaScript, and Alea seems to be the one that has come out ahead (benchmarks).
npm install alea
var Alea = require('alea')
var prng = new Alea() // add an optional seed param
var nextRandnum = prng() // just call the return value of Alea
Also adds the ability to sync up two Alea PRNGs via the importState and exportState methods.
var prng1 = new Alea(200)
prng1()
prng1()
// after generating a few random numbers, we will initialize a new PRNG
var prng2 = Alea.importState(prng1.exportState())
// this should echo true, true, true
console.log(prng2() == prng1())
console.log(prng2() == prng1())
console.log(prng2() == prng1())
The theory behind this is that while a server is running a simulation (for example, a game) and clients connect to the server, each client will run its own simulation without having to depend 100% on the server for every update of the simulation state. By importing the current generator state from the server, a client can join in at any time and have an accurate simulation fully in sync with the server.
Everything in this module was made by Johannes Baagøe. I just wanted this in npm. Read more on his homepage.
FAQs
Implementation of the Alea PRNG by Johannes Baagøe
The npm package alea receives a total of 36,176 weekly downloads. As such, alea popularity was classified as popular.
We found that alea demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.