Skip to content

Instantly share code, notes, and snippets.

@dtipson
Created August 10, 2015 00:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtipson/b0404d58a54a81a48fed to your computer and use it in GitHub Desktop.
Save dtipson/b0404d58a54a81a48fed to your computer and use it in GitHub Desktop.
//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