Skip to content

Commit

Permalink
Simplify function calls (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peeterush authored Oct 21, 2024
1 parent ffee5e6 commit 920d50f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/magick-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3491,14 +3491,14 @@ export class MagickImage extends NativeInstance implements IMagickImage {
}

private useException<TReturnType>(func: (exception: Exception) => TReturnType): TReturnType {
return Exception.use<TReturnType>(func, error => {
return Exception.use(func, error => {
if (this.onWarning !== undefined)
this.onWarning(new WarningEvent(error));
});
}

private useExceptionPointer<TReturnType>(func: (exception: number) => TReturnType): TReturnType {
return Exception.usePointer<TReturnType>(func, error => {
return Exception.usePointer(func, error => {
if (this.onWarning !== undefined)
this.onWarning(new WarningEvent(error));
});
Expand Down
12 changes: 3 additions & 9 deletions tests/test-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ abstract class TestImageBase<TImageType extends Cloneable<TImageType>> {
if (this._image === undefined)
this._image = this.load();

return this._image.clone(image => {
return func(image);
});
return this._image.clone(func);
}

abstract load(): TImageType;
Expand Down Expand Up @@ -95,19 +93,15 @@ class EmptyTestImage {
use<TReturnType>(func: (image: IMagickImage) => TReturnType): TReturnType;
use<TReturnType>(func: (image: IMagickImage) => Promise<TReturnType>): Promise<TReturnType>;
use<TReturnType>(func: (image: IMagickImage) => TReturnType | Promise<TReturnType>): TReturnType | Promise<TReturnType> {
return MagickImage.create()._use(image => {
return func(image);
});
return MagickImage.create()._use(func);
}
}

class EmptyTestImageCollection {
use<TReturnType>(func: (images: IMagickImageCollection) => TReturnType): TReturnType;
use<TReturnType>(func: (images: IMagickImageCollection) => Promise<TReturnType>): Promise<TReturnType>;
use<TReturnType>(func: (images: IMagickImageCollection) => TReturnType | Promise<TReturnType>): TReturnType | Promise<TReturnType> {
return MagickImageCollection.create()._use(images => {
return func(images);
});
return MagickImageCollection.create()._use(func);
}
}

Expand Down

0 comments on commit 920d50f

Please sign in to comment.