代码片段:
let memo = {};
let memoize = function(width, scale, lean) {
const memoKey = `${width}-${scale}-${lean}`;
if (!memo[memoKey]) {
const currentH = width * scale;
const result = {
leftSize: Math.sqrt(currentH ** 2 (width * (0.5 - lean)) ** 2),
rightSize: Math.sqrt(currentH ** 2 (width * (0.5 lean)) ** 2),
leftAngle: Math.atan(currentH / ((0.5 - lean) * width)),
rightAngle: Math.atan(currentH / ((0.5 lean) * width))
};
memo[memoKey] = result;
memoize.count ;
}
return memo[memoKey];
}