Created
August 10, 2015 00:51
-
-
Save dtipson/b0404d58a54a81a48fed 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
//returns a promise that resolves after a time | |
function wait(time){ | |
return new Promise(function(resolve){ | |
window.setTimeout(resolve,time); | |
}); | |
} | |
//a function that, if called with just a time, | |
//returns a function that will return a wait... | |
//that resolves with whatever value it was given | |
var delay = _.curry(function(time,value){ | |
return wait(time).then(_.constant(value)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment