Skip to content

Commit

Permalink
chore: bind methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Jan 14, 2022
1 parent 40bf3ae commit 7530d5c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ export class Git {
'f',
];

constructor(private readonly faker: Faker) {}
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Git.prototype)) {
if (name === 'constructor' || typeof this[name] !== 'function') {
continue;
}
this[name] = this[name].bind(this);
}
}

/**
* branch
Expand Down

0 comments on commit 7530d5c

Please sign in to comment.