I have a problem with Class Javascript. I created class with constructor and two functions.
export default class Example {
private image: string;
private processedImage: Sharp | undefined;
constructor(image: string) {
this.image = image;
}
resize(): ResizeClb {
this.processedImage = resizeImage(this.image, ...);
return {
merge: this.merge
};
}
merge(images: MergeImages[]): void {
console.log(this.processedImage); // print undefined
this.processedImage = this.processedImage.composite(layers);
}
}
I want call chained functions:
const a = new Example(myImage).resize().merge(...othersImages);
But when I called the chained function I get undefined in this.processedImage line. I can't access to value of the class.
It's work if I not use chains functions.
const a = new Example(myImage);
a.resize();
a.merge(...othersImages); // It work.
It work but I required use chains functions. Thank you!