Guest User

Untitled

a guest
Nov 8th, 2017
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _ = require("lodash")
  2.  
  3. function timeIntensiveFunction(callback) {
  4.   setTimeout(function() {
  5.     callback("World")
  6.   }, 1000)
  7. }
  8. getAll = _.memoize(function() {
  9.   return new Promise(function(resolve, reject) {
  10.     timeIntensiveFunction(function callback(data) {
  11.       resolve(data);
  12.     })
  13.   });
  14. });
  15.  
  16. getAll().then(function(result) {
  17.   console.log("Hello", result)
  18. })
Add Comment
Please, Sign In to add comment