code: function delay(ms, done) {
  
    // Work around IE8 bug whereby a setTimeout callback may still be called
    // after the corresponding clearTimeout is invoked.
    var timer = null;
  
    function finish() {
      if (timer != null) {
        timer = null;
        done(null);
      }
    }
  
    function cancel() {
      if (timer != null) {
        clearTimeout(timer);
        timer = null;
        done.apply(null, arguments);
      }
    }
  
    timer = setTimeout(finish, ms);
  
    return cancel;
  
  }
docs: Perform a cancelable delay. See util/cancelize.js for an explanation of what cancelables are.