+ this.watches = [];
+ this._watchStack = 0;
+ this._yielders = 0;
+ },
+
+ afterCommands: function afterCommands(count, cmd, self) {
+ this.watches.push([cmd, self, Math.max(this._watchStack - 1, 0), count || 1]);
+ },
+
+ pushCommand: function pushCommand(cmd) {
+ this._watchStack++;
+ this._yielders = util.yielders;
+ },
+ popCommand: function popCommand(cmd) {
+ this._watchStack = Math.max(this._watchStack - 1, 0);
+ if (util.yielders > this._yielders)
+ this._watchStack = 0;
+
+ this.watches = this.watches.filter(function (elem) {
+ if (this._watchStack <= elem[2])
+ elem[3]--;
+ if (elem[3] <= 0)
+ elem[0].call(elem[1] || null);
+ return elem[3] > 0;
+ }, this);