* Utility function to create an object URL from a blob, execute a function with it, and automatically clean it up. * * @param blob - The Blob to create an object URL for * @param fn - Function to execute with the object URL * @returns Promise that resolves to the result of the function * @
(blob: Blob, fn: (url: string) => Promise<T>)
| 478 | * @public |
| 479 | */ |
| 480 | static async usingObjectURL<T>(blob: Blob, fn: (url: string) => Promise<T>): Promise<T> { |
| 481 | const url = URL.createObjectURL(blob) |
| 482 | try { |
| 483 | return await fn(url) |
| 484 | } finally { |
| 485 | URL.revokeObjectURL(url) |
| 486 | } |
| 487 | } |
| 488 | } |
no test coverage detected