export function memoize < T > ( fn ) { const memoized = function ( this , ... args ) { const key = args [ 0 ] ; const { cache } = memoized ; if ( cache . has ( key ) ) { return cache . get ( key ) as T ; } const res = fn . apply ( this , args ) ; memoized . cache . set ( key , res ) ; return res ; } ; memoized . cache = new Map < string , T > ( ) ; return memoized ; }