code: function processTask() {
          setTimeout(function() {
              if (isBusy || queue.length === 0) {
                  return;
              }
  
              isBusy = true;
  
              var next = queue.shift(),
                  result,
                  error;
  
              Platform.async(function(callback) { // Start a promise chain
                  callback();
              })().then(function() {
                  return next.task(); // Run the task
              }).then(function(res) { // task completed successfully
                  isBusy = false;
                  processTask();
                  next.callback(null, res); // resolve the promise returned by the run function
              }, function(err) { // task failed
                  isBusy = false;
                  processTask();
                  next.callback(err); // reject the promise returned by the run function
              });
          }, 0);
      }
docs: Asynchronously executes the first pending task