aboutsummaryrefslogtreecommitdiff
path: root/src/modules/string/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/string/index.ts')
-rw-r--r--src/modules/string/index.ts12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts
index aec6b91f..536a1c6a 100644
--- a/src/modules/string/index.ts
+++ b/src/modules/string/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 type { LiteralUnion } from '../../utils/types';
export type Casing = 'upper' | 'lower' | 'mixed';
@@ -103,16 +104,7 @@ const SAMPLE_MAX_LENGTH = 2 ** 20;
*/
export class StringModule {
constructor(private readonly faker: Faker) {
- // Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(
- StringModule.prototype
- ) as Array<keyof StringModule | 'constructor'>) {
- if (name === 'constructor' || typeof this[name] !== 'function') {
- continue;
- }
-
- this[name] = this[name].bind(this);
- }
+ bindThisToMemberFunctions(this);
}
/**