Code coverage report for lib/mapreduce/taskqueue.js

Statements: 100% (11 / 11)      Branches: 100% (0 / 0)      Functions: 100% (6 / 6)      Lines: 100% (10 / 10)      Ignored: none     

All files » lib/mapreduce/ » taskqueue.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25            1   1 573   1 1834     1834   1834   1 714     1  
'use strict';
/*
 * Simple task queue to sequentialize actions. Assumes
 * callbacks will eventually fire (once).
 */
 
var Promise = require('./utils').Promise;
 
function TaskQueue() {
  this.promise = new Promise(function (fulfill) {fulfill(); });
}
TaskQueue.prototype.add = function (promiseFactory) {
  this.promise = this.promise.catch(function () {
    // just recover
  }).then(function () {
    return promiseFactory();
  });
  return this.promise;
};
TaskQueue.prototype.finish = function () {
  return this.promise;
};
 
module.exports = TaskQueue;