message: promisified decodeWithRetry
diff: @@ -203,8 +203,9 @@ export class BrowserCodeReader {
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
  const video = await this.attachStreamToVideo(stream, videoSource);
  + const result = await this.decodeWithRetry(video);
  - return new Promise((resolve, reject) => this.decodeWithRetryAndDelay(video, resolve, reject));
  + return result;
  }
  /**
  @@ -235,7 +236,7 @@ export class BrowserCodeReader {
  *
  * @param videoElement
  */
  - playVideoAsync(videoElement: HTMLVideoElement): Promise<void> {
  + protected playVideoAsync(videoElement: HTMLVideoElement): Promise<void> {
  return new Promise((resolve, reject) => this.playVideo(videoElement, () => resolve()));
  }
  @@ -281,7 +282,7 @@ export class BrowserCodeReader {
  reject(new NotFoundException('Video stream has ended before any code could be detected.'));
  };
  - this.videoPlayingEventListener = () => this.decodeWithRetryAndDelay(videoElement, resolve, reject);
  + this.videoPlayingEventListener = () => this.decodeWithRetry(videoElement).then(resolve, reject);
  // defines the video element before starts decoding
  this.videoElement = videoElement;
  @@ -387,7 +388,7 @@ export class BrowserCodeReader {
  this.imageElement = image;
  if (this.isImageLoaded(image)) {
  - this.decodeWithRetry(image, resolve, reject, false, true);
  + this.decodeWithRetry(image, false, true).then(resolve, reject);
  } else {
  this._decodeOnLoadImage(image, resolve, reject);
  }
  @@ -421,7 +422,7 @@ export class BrowserCodeReader {
  }
  private _decodeOnLoadImage(imageElement: HTMLImageElement, resolve: (value?: Result | PromiseLike<Result>) => void, reject: (reason?: any) => void) {
  - this.imageLoadedEventListener = () => this.decodeWithRetry(imageElement, resolve, reject, false, true);
  + this.imageLoadedEventListener = () => this.decodeWithRetry(imageElement, false, true).then(resolve, reject);
  imageElement.addEventListener('load', this.imageLoadedEventListener);
  }
  @@ -466,15 +467,15 @@ export class BrowserCodeReader {
  return imageElement;
  }
  - private decodeWithRetryAndDelay(element: HTMLVisualMediaElement, resolve: (result: Result) => any, reject: (error: any) => any): void {
  - this.timeoutHandler = window.setTimeout(() => this.decodeWithRetry(element, resolve, reject), this.timeBetweenScansMillis);
  - }
  + /**
  + * Continuously decodes from video input.
  + */
  + private async decodeWithRetry(element: HTMLVisualMediaElement, retryIfNotFound = true, retryIfChecksumOrFormatError = true): Promise<Result> {
  - private decodeWithRetry(element: HTMLVisualMediaElement, resolve: (result: Result) => any, reject: (error: any) => any, retryIfNotFound = true, retryIfChecksumOrFormatError = true): void {
  + let result: Result;
  try {
  - const result = this.decode(element);
  - resolve(result);
  + result = this.decode(element);
  } catch (e) {
  const ifNotFound = retryIfNotFound && e instanceof NotFoundException;
  @@ -483,11 +484,13 @@ export class BrowserCodeReader {
  if (ifNotFound || ifChecksumOrFormat) {
  // trying again
  - this.decodeWithRetryAndDelay(element, resolve, reject);
  + result = await this.decodeWithRetry(element, retryIfNotFound, retryIfChecksumOrFormatError);
  } else {
  - reject(e);
  + throw e;
  }
  }
  +
  + return result;
  }
  /**
  