workflow-4-node
Version:
Workflow 4 Node is a .NET Workflow Foundation like framework for Node.js. The goal is to reach feature equivalence and beyond.
56 lines (48 loc) • 1.5 kB
JavaScript
;
var errors = require("../common/errors");
function ResumeBookmarkQueue() {
this._names = new Set();
this._commands = [];
}
ResumeBookmarkQueue.prototype.isEmpty = function () {
return this._commands.length === 0;
};
ResumeBookmarkQueue.prototype.enqueue = function (bookmarkName, reason, result) {
if (!this._names.has(bookmarkName)) {
this._names.add(bookmarkName);
this._commands.push({
name: bookmarkName,
reason: reason,
result: result
});
} else {
throw new errors.ActivityRuntimeError("The '" + bookmarkName + "' bookmark continuation already enqueued.");
}
};
ResumeBookmarkQueue.prototype.dequeue = function () {
if (this._commands.length) {
var command = this._commands[0];
this._commands.splice(0, 1);
this._names.delete(command.name);
return command;
}
return null;
};
ResumeBookmarkQueue.prototype.remove = function (bookmarkName) {
if (this._names.has(bookmarkName)) {
var idx = -1;
for (var i = 0; i < this._commands.length; i++) {
var command = this._commands[i];
if (command.name === bookmarkName) {
idx = i;
break;
}
}
if (idx !== -1) {
this._commands.splice(idx, 1);
}
this._names.delete(bookmarkName);
}
};
module.exports = ResumeBookmarkQueue;
//# sourceMappingURL=resumeBookmarkQueue.js.map