MCPcopy
hub / github.com/tldraw/tldraw / usingObjectURL

Method usingObjectURL

packages/utils/src/lib/media/media.ts:480–487  ·  view source on GitHub ↗

* 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>)

Source from the content-addressed store, hash-verified

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}

Callers 3

getVideoSizeMethod · 0.80
getImageSizeMethod · 0.80
downsizeImageFunction · 0.80

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected