Skip to content

Instantly share code, notes, and snippets.

@tusharmath
Created January 22, 2017 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tusharmath/e19071651a331febeda0db9a70318f72 to your computer and use it in GitHub Desktop.
Save tusharmath/e19071651a331febeda0db9a70318f72 to your computer and use it in GitHub Desktop.
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