| 10 | - size() |
| 11 | */ |
| 12 | class Stack { |
| 13 | constructor() { |
| 14 | this._data = []; |
| 15 | } |
| 16 | |
| 17 | size() { |
| 18 | return this._data.length; |
| 19 | } |
| 20 | |
| 21 | isEmpty() { |
| 22 | return this.size() == 0; |
| 23 | } |
| 24 | |
| 25 | push(value) { |
| 26 | this._data.push(value); |
| 27 | } |
| 28 | |
| 29 | pop() { |
| 30 | return this._data.pop(); |
| 31 | } |
| 32 | |
| 33 | peek() { |
| 34 | if (this.isEmpty()) return null; |
| 35 | return this._data[this.size() - 1]; |
| 36 | } |
| 37 | |
| 38 | _toArray() { |
| 39 | return this._data; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | module.exports = Stack; |
| 44 |
nothing calls this directly
no outgoing calls
no test coverage detected