Skip to content

Commit

Permalink
feat: migrate random (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored and damienwebdev committed Jan 14, 2022
1 parent 10b3689 commit efc11f1
Show file tree
Hide file tree
Showing 3 changed files with 390 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/mersenne.ts
Expand Up @@ -5,6 +5,14 @@ export class Mersenne {

constructor() {
this.gen.init_genrand(new Date().getTime() % 1000000000);

// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Mersenne.prototype)) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
this[name] = this[name].bind(this);
}
}

rand(max?: number, min?: number) {
Expand Down

0 comments on commit efc11f1

Please sign in to comment.