varweakMemoize=functionweakMemoize(func){varcache=newWeakMap();returnfunction(arg){if(cache.has(arg)){// Use non-null assertion because we just checked that the cache `has` it// This allows us to remove `undefined` from the return valuereturncache.get(arg);}varret=func(arg);cache.set(arg,ret);returnret;};};export{weakMemoizeasdefault};