aboutsummaryrefslogtreecommitdiff
path: root/src/modules/random
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/random')
-rw-r--r--src/modules/random/index.ts14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/modules/random/index.ts b/src/modules/random/index.ts
index d0544119..7fa16f40 100644
--- a/src/modules/random/index.ts
+++ b/src/modules/random/index.ts
@@ -1,5 +1,6 @@
import type { Faker } from '../..';
import { FakerError } from '../../errors/faker-error';
+import { bindThisToMemberFunctions } from '../../internal/bind-this-to-member-functions';
import { deprecated } from '../../internal/deprecated';
import type { LiteralUnion } from '../../utils/types';
import type {
@@ -16,18 +17,7 @@ import type {
*/
export class RandomModule {
constructor(private readonly faker: Faker) {
- // Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(
- // eslint-disable-next-line deprecation/deprecation
- RandomModule.prototype
- // eslint-disable-next-line deprecation/deprecation
- ) as Array<keyof RandomModule | 'constructor'>) {
- if (name === 'constructor' || typeof this[name] !== 'function') {
- continue;
- }
-
- this[name] = this[name].bind(this);
- }
+ bindThisToMemberFunctions(this);
}
/**