-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionsStack.js
More file actions
41 lines (34 loc) · 877 Bytes
/
OptionsStack.js
File metadata and controls
41 lines (34 loc) · 877 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
var Options = require('./Options');
function OptionsStack() {
this._stack = [];
Object.defineProperty(this, 'current', {
get: function () {
return this._stack[this._stack.length - 1];
},
set: function (v) {
if (!(v instanceof Options)) {
v = new Options(v);
}
return this._stack.push(v);
}
});
}
OptionsStack.prototype.select = function (id) {
// Redirige el comando al último de la pila.
return this.current.select(id);
};
OptionsStack.prototype.list = function () {
// Redirige el comando al último de la pila.
return this.current.list();
};
OptionsStack.prototype.get = function (id) {
return this.current.get(id);
};
OptionsStack.prototype.cancel = function () {
this._stack.pop();
};
OptionsStack.prototype.clear = function () {
this._stack = [];
};
module.exports = OptionsStack;