cache = {} function calcx1(a,b){ D = cache[[a,b,c].toString()] return some_formula(a,b,D) } function calcx2(a,b){ D = cache[[a,b,c].toString()] return some_formula(a,b,D) } function dcalc (a,b,c){ cache[[a,b,c].toString()] = cache[[a,b,c].toString()] || вычисляем return function (func){ func(a, b) } } let calcWrap = dcalc(1,1,1) let x1 = calcWrap(calcx1) let x2 = calcWrap(calcx2) /// output: // ReferenceError: вычисляем is not defined
(ваш голос учтен)