function pollGfycat(delay, gfyname) {
  return new Promise(function(resolve, reject) {
    function next() {
      getUploadStatus(delay, gfyname).then(function(res) {
        debug(res);
        if (res.task === "complete") {
          return resolve(res);
        }
        if (res.task === "NotFoundo") {
          return reject("Not found");
        } else {
          updateProgress(res.progress);
          setTimeout(next, delay);
        }
      }, reject);
    }
    // Start first iteration of the loop
    next();
  });
}
/**
 * pollGfycat - Checks the progress of Gfycat upload
 *
 * @param {number} delay How long to wait between polls
 * @param {type} gfyname The Gfycat id
 */
Checks the progress of Gfycat upload
@param {number} delay How long to wait between polls
@param {type} gfyname The Gfycat id
Checks the progress of Gfycat upload @param { number } delay How long to wait between polls @param { type } gfyname The Gfycat id
function pollGfycat(delay, gfyname) {
  return new Promise(function(resolve, reject) {
    function next() {
      getUploadStatus(delay, gfyname).then(function(res) {
        debug(res);
        if (res.task === "complete") {
          return resolve(res);
        }
        if (res.task === "NotFoundo") {
          return reject("Not found");
        } else {
          updateProgress(res.progress);
          setTimeout(next, delay);
        }
      }, reject);
    }
    next();
  });
}
function pollGfycat ( delay , gfyname ) { return new Promise ( function ( resolve , reject ) { function next ( ) { getUploadStatus ( delay , gfyname ) . then ( function ( res ) { debug ( res ) ; if ( res . task === "complete" ) { return resolve ( res ) ; } if ( res . task === "NotFoundo" ) { return reject ( "Not found" ) ; } else { updateProgress ( res . progress ) ; setTimeout ( next , delay ) ; } } , reject ) ; } next ( ) ; } ) ; }
pollGfycat - Checks the progress of Gfycat upload
 @param {number} delay How long to wait between polls
 @param {type} gfyname The Gfycat id
pollGfycat - Checks the progress of Gfycat upload @param { number } delay How long to wait between polls @param { type } gfyname The Gfycat id
// Start first iteration of the loop