|
@@ -27,16 +27,13 @@ module.exports = class Stack {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a value from the stack
|
|
|
|
|
|
+ * Get a value at a given index on the stack
|
|
*
|
|
*
|
|
- * If an index isn't given, retrieves the value at the current
|
|
|
|
- * location of the pointer
|
|
|
|
- *
|
|
|
|
- * @param {?number} index The index of the value to retrieve
|
|
|
|
- * @returns {number} The value at the given index, or 0
|
|
|
|
|
|
+ * @param {number} index The index of the value to retrieve
|
|
|
|
+ * @returns {number} The value at the given index, or 0 if the index hasn't been defined yet
|
|
*/
|
|
*/
|
|
- Get(index = null) {
|
|
|
|
- if (index !== null && (Number.isNaN(index) || !Number.isInteger(index))) {
|
|
|
|
|
|
+ GetAtIndex(index) {
|
|
|
|
+ if (index == null || Number.isNaN(index) || !Number.isInteger(index)) {
|
|
throw new TypeError("index must be an integer");
|
|
throw new TypeError("index must be an integer");
|
|
}
|
|
}
|
|
|
|
|