diff options
| author | Shinigami92 <[email protected]> | 2022-01-11 09:22:33 +0100 |
|---|---|---|
| committer | Damien Retzinger <[email protected]> | 2022-01-14 18:37:49 -0500 |
| commit | 8634a54bfdf5de136ae1a62d64f655935b9a4e79 (patch) | |
| tree | 4755b7cf2cde78739df92627303288160408264f /src | |
| parent | 16c748b8a70f63470684d927a91b1bdef460cebb (diff) | |
| download | faker-8634a54bfdf5de136ae1a62d64f655935b9a4e79.tar.xz faker-8634a54bfdf5de136ae1a62d64f655935b9a4e79.zip | |
chore: dynamically bind functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/datatype.ts | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/datatype.ts b/src/datatype.ts index 05960228..1da3cace 100644 --- a/src/datatype.ts +++ b/src/datatype.ts @@ -10,16 +10,12 @@ export class Datatype { } // Bind `this` so namespaced is working correctly - this.number = this.number.bind(this); - this.float = this.float.bind(this); - this.datetime = this.datetime.bind(this); - this.string = this.string.bind(this); - this.uuid = this.uuid.bind(this); - this.boolean = this.boolean.bind(this); - this.hexaDecimal = this.hexaDecimal.bind(this); - this.json = this.json.bind(this); - this.array = this.array.bind(this); - this.bigInt = this.bigInt.bind(this); + for (const name of Object.getOwnPropertyNames(Datatype.prototype)) { + if (name === 'constructor' || typeof this[name] !== 'function') { + continue; + } + this[name] = this[name].bind(this); + } } /** |
