lib/perform.js
function( kind, promisesDfd ) {
  return function() {
    // operate on this unless we forced a deferred to work on
    var dfd = promisesDfd || this;
    var fnSet = [].slice.call( arguments );

    // as long as this is a progress handler or the state isn't reached add it
    // otherwise call it right now
    if ( kind === 'progress' || dfd.state === 'pending' ) {
      dfd[ kind + 's' ].push( fnSet );
    } else {
      callSet.call( dfd, fnSet, this[ kind + 'Args' ] );
    }

    // if we forced a promiseDfd, return the promise
    if ( promisesDfd ) {
      return dfd.promise;
    }
    // otherwise return the root deferred like normal
    return dfd;
  };
}
function( kind, promisesDfd ) {
  return function() {
    // operate on this unless we forced a deferred to work on
    var dfd = promisesDfd || this;
    var fnSet = [].slice.call( arguments );

    // as long as this is a progress handler or the state isn't reached add it
    // otherwise call it right now
    if ( kind === 'progress' || dfd.state === 'pending' ) {
      dfd[ kind + 's' ].push( fnSet );
    } else {
      callSet.call( dfd, fnSet, this[ kind + 'Args' ] );
    }

    // if we forced a promiseDfd, return the promise
    if ( promisesDfd ) {
      return dfd.promise;
    }
    // otherwise return the root deferred like normal
    return dfd;
  };
}
generator to add callbacks to a bucked and possible fire them