mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
37 lines
518 B
JavaScript
37 lines
518 B
JavaScript
|
|
var assert = require('assert');
|
|
|
|
/**
|
|
* Description
|
|
* @method Plan
|
|
* @param {} count
|
|
* @param {} done
|
|
* @return
|
|
*/
|
|
function Plan(count, done) {
|
|
this.done = done;
|
|
this.count = count;
|
|
}
|
|
|
|
/**
|
|
* Description
|
|
* @method ok
|
|
* @param {} expression
|
|
* @return
|
|
*/
|
|
Plan.prototype.ok = function(expression) {
|
|
assert(expression);
|
|
|
|
if (this.count === 0) {
|
|
assert(false, 'Too many assertions called');
|
|
} else {
|
|
this.count--;
|
|
}
|
|
|
|
if (this.count === 0) {
|
|
this.done();
|
|
}
|
|
};
|
|
|
|
module.exports = Plan;
|