aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-11-06 09:40:49 +0100
committerGitHub <[email protected]>2023-11-06 08:40:49 +0000
commit48a7af4f0470115945ab166b540d0bedc7e5eb20 (patch)
treeb6344afcc6f9fca2d16555d5e3495439952b9a57 /src/internal
parent358572d9e76f4cd22bfcb09c092a1eaf3a31f005 (diff)
downloadfaker-48a7af4f0470115945ab166b540d0bedc7e5eb20.tar.xz
faker-48a7af4f0470115945ab166b540d0bedc7e5eb20.zip
refactor: simplify module creation (#2485)
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/module-base.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/internal/module-base.ts b/src/internal/module-base.ts
new file mode 100644
index 00000000..aceba703
--- /dev/null
+++ b/src/internal/module-base.ts
@@ -0,0 +1,25 @@
+import type { Faker } from '../faker';
+import type { SimpleFaker } from '../simple-faker';
+import { bindThisToMemberFunctions } from './bind-this-to-member-functions';
+
+/**
+ * Base class for all modules that use a `SimpleFaker` instance.
+ *
+ * @internal
+ */
+export abstract class SimpleModuleBase {
+ constructor(protected readonly faker: SimpleFaker) {
+ bindThisToMemberFunctions(this);
+ }
+}
+
+/**
+ * Base class for all modules that use a `Faker` instance.
+ *
+ * @internal
+ */
+export abstract class ModuleBase extends SimpleModuleBase {
+ constructor(protected readonly faker: Faker) {
+ super(faker);
+ }
+}