We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 605e66f commit 3ab384eCopy full SHA for 3ab384e
src/image.ts
@@ -13,6 +13,14 @@ export class Image {
13
readonly lorempicsum: typeof LoremPicsum;
14
15
constructor(private readonly faker: Faker) {
16
+ // Bind `this` so namespaced is working correctly
17
+ for (const name of Object.getOwnPropertyNames(Image.prototype)) {
18
+ if (name === 'constructor' || typeof this[name] !== 'function') {
19
+ continue;
20
+ }
21
+ this[name] = this[name].bind(this);
22
23
+
24
this.lorempixel = new Lorempixel(this.faker);
25
this.unsplash = new Unsplash(this.faker);
26
this.lorempicsum = new LoremPicsum(this.faker);
0 commit comments