import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'createPathFromBlob',
})
export class CreatePathFromBlobPipe implements PipeTransform {
  transform(blob: Blob): Promise<String> {
    return new Promise((resolve, reject) => {
      const reader = new FileReader();

      reader.onload = (event: ProgressEvent) => {
        resolve(event.target['result'] as string);
      };

      reader.onerror = reject;

      reader.readAsDataURL(blob);
    });
  }
}
