File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -11,20 +11,22 @@ export function cn(...names: (string | undefined | false)[]): string {
1111/**
1212 * Convert AsyncBufferFromUrl to AsyncBuffer.
1313 */
14- export function asyncBufferFrom ( from : AsyncBufferFrom ) : Promise < AsyncBuffer > {
14+ export async function asyncBufferFrom ( from : AsyncBufferFrom ) : Promise < AsyncBuffer > {
1515 if ( 'url' in from ) {
1616 // Cached asyncBuffer for urls only
1717 const key = JSON . stringify ( from )
1818 const cached = cache . get ( key )
1919 if ( cached ) return cached
20- const asyncBuffer = asyncBufferFromUrl ( from ) . then ( cachedAsyncBuffer )
21- cache . set ( key , asyncBuffer )
22- return asyncBuffer
20+ const buffer = await asyncBufferFromUrl ( from )
21+ const newCached = cachedAsyncBuffer ( buffer )
22+ // only cache if no error, otherwise let the error bubble up
23+ cache . set ( key , newCached )
24+ return newCached
2325 } else {
2426 return from . file . arrayBuffer ( )
2527 }
2628}
27- const cache = new Map < string , Promise < AsyncBuffer > > ( )
29+ const cache = new Map < string , AsyncBuffer > ( )
2830// TODO(SL): do we really want a singleton?
2931
3032export function getFileDateShort ( file ?: { lastModified ?: string } ) : string {
You can’t perform that action at this time.
0 commit comments