Skip to content

Commit

Permalink
chore: dynamically bind functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Jan 11, 2022
1 parent 9119ebb commit b16ec1b
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/datatype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down

0 comments on commit b16ec1b

Please sign in to comment.