import { copyStaticProperties } from './instance' ; import type { Moized } from './types' ; export function createRefreshableMoized < MoizedFn extends Moized > ( moized ) { const { options : { updateCacheForKey } , } = moized ; private description const refreshableMoized = function refreshableMoized ( this , ... args ) { if ( ! updateCacheForKey ( args ) ) { return moized . apply ( this , args ) ; } const result = moized . fn . apply ( this , args ) ; moized . set ( args , result ) ; return result ; } as typeof moized ; copyStaticProperties ( moized , refreshableMoized ) ; return refreshableMoized ; }