Created
September 8, 2015 13:15
-
-
Save raine/133a885c9fbd523ea1b3 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
const cachedReadFile = (function() { | |
const cache = new Map(); | |
return (p) => { | |
if (cache.has(p)) return Promise.resolve(cache.get(p)); | |
else return readFile(p).tap((file) => cache.set(p, file)); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment