Skip to content

Documentation / @sw-file-lib/three / withCache

Function: withCache() ​

ts
function withCache<K, V>(resolver: (key: K) => Promise<V>): (key: K) => Promise<V>;

Defined in: vehicleAssembler/assetResolver.ts:85

Wraps an asynchronous resolver with memoization.

The returned function caches both completed results and in-flight promises, ensuring that concurrent requests for the same key share a single operation.

Type Parameters ​

Type Parameter
K
V

Parameters ​

ParameterTypeDescription
resolver(key: K) => Promise<V>The resolver to memoize.

Returns ​

A cached resolver.

(key: K) => Promise<V>