Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################################################################
- COMMONJS: ./Utils/index.js
- #######################################################################
- // TODO: add momemt.js to enable TTL of cache items
- const memoize = (fn) => {
- let cache = {}, key;
- return (...args) => {
- key = JSON.stringify(args);
- return cache[key] || (cache[key] = fn.call(null, ...args));
- }
- };
- module.exports = {
- memoize
- };
- #######################################################################
Add Comment
Please, Sign In to add comment