Skip to content

Commit efc11f1

Browse files
Shinigami92damienwebdev
authored andcommitted
feat: migrate random (#91)
1 parent 10b3689 commit efc11f1

File tree

3 files changed

+390
-4
lines changed

3 files changed

+390
-4
lines changed

src/mersenne.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ export class Mersenne {
55

66
constructor() {
77
this.gen.init_genrand(new Date().getTime() % 1000000000);
8+
9+
// Bind `this` so namespaced is working correctly
10+
for (const name of Object.getOwnPropertyNames(Mersenne.prototype)) {
11+
if (name === 'constructor' || typeof this[name] !== 'function') {
12+
continue;
13+
}
14+
this[name] = this[name].bind(this);
15+
}
816
}
917

1018
rand(max?: number, min?: number) {

0 commit comments

Comments
 (0)