from all members: - accepted / - tried
In problem 14. Implement a general memoization function, you are asked to implement a memo function without space concern.
But in reality, it could be a problem if cache bloats.
You might need to restrict the cache capacity, just like memoize-one , it only remembers the latest arguments and result.
Please implement your own
memoizeOne(), it takes 2 arguments
- target function
- (optional) a equality check function to compare current and last arguments
Default equality check function should be a shallow comparison on array items with strict equal
Let's try to solve this problem within 5 mintues.