Guest User

Untitled

a guest
Dec 14th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #######################################################################
  2. COMMONJS: ./Utils/index.js
  3. #######################################################################
  4.  
  5. // TODO: add momemt.js to enable TTL of cache items
  6.  
  7. const memoize = (fn) => {
  8. let cache = {}, key;
  9. return (...args) => {
  10. key = JSON.stringify(args);
  11. return cache[key] || (cache[key] = fn.call(null, ...args));
  12. }
  13. };
  14.  
  15. module.exports = {
  16. memoize
  17. };
  18.  
  19. #######################################################################
Add Comment
Please, Sign In to add comment