import type { Fn , Fn2 , Fn3 , Fn4 , FnAny , IObjectOf } from "@thi.ng/api" ; param fn param cache export function memoizeJ < A , B > ( fn , cache ? ) ; export function memoizeJ < A , B , C > ( fn , cache ? ) ; export function memoizeJ < A , B , C , D > ( fn , cache ? ) ; export function memoizeJ < A , B , C , D , E > ( fn , cache ? ) ; export function memoizeJ ( fn , cache ? ) { ! cache && ( cache = { } ) ; return ( ... args ) => { const key = JSON . stringify ( args ) ; if ( key !== undefined ) { return key in cache ! ? cache ! [ key ] : ( cache ! [ key ] = fn . apply ( null , args ) ) ; } return fn . apply ( null , args ) ; } ; }