Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _ = require("lodash")
- function timeIntensiveFunction(callback) {
- setTimeout(function() {
- callback("World")
- }, 1000)
- }
- getAll = _.memoize(function() {
- return new Promise(function(resolve, reject) {
- timeIntensiveFunction(function callback(data) {
- resolve(data);
- })
- });
- });
- getAll().then(function(result) {
- console.log("Hello", result)
- })
Add Comment
Please, Sign In to add comment