Created
January 22, 2017 03:25
-
-
Save tusharmath/e19071651a331febeda0db9a70318f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test () { | |
const cache = {} | |
function create (type) {return {type: type, value: new Date() }} | |
return function (type) { | |
if (cache[type]) return cache[type] | |
const c = create(type) | |
cache[type] = c | |
return c | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment