Skip to content

Commit

Permalink
fix: fix fromImageElement for return Promise and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkzt committed Jul 30, 2020
1 parent 07c8540 commit 22c966b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/img-trace/src/imgloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export class ImgLoader {
constructor(options: Partial<ImgLoaderOption>) {
this.corsenabled = options.corsenabled ?? true
}

// TODO: improve types.
// if exists callback, return void. if not existed callback, return Promise<ImageData>.
public fromUrl(
url: string,
callback?: (imgd: ImageData) => void
Expand Down Expand Up @@ -57,6 +60,8 @@ export class ImgLoader {
}
}

// TODO: improve types.
// if exists callback, return void. if not existed callback, return Promise<ImageData>.
public fromImageElement(
img: HTMLImageElement,
callback?: (imgd: ImageData) => void
Expand Down Expand Up @@ -89,7 +94,7 @@ export class ImgLoader {
if (callback) {
load(callback)
} else {
new Promise(load)
return new Promise(load)
}
}
}

0 comments on commit 22c966b

Please sign in to comment.