Here is the js implementation of the Mersenne Twister. The code is based on the pseduo-code of the algorithm on wikipedia
Check out the paper that originally detailed the Mersenne Twister: Link