Browse Source

Allow stacks to start with values

ApisNecros 1 year ago
parent
commit
13ebda5475
1 changed files with 5 additions and 2 deletions
  1. 5 2
      starfish.js

+ 5 - 2
starfish.js

@@ -549,12 +549,15 @@ class CodeBox {
  * The stack class
  */
 class Stack {
-    constructor() {
+    /**
+     * @param {int[]} stackValues An array of values to initialize the stack with
+     */
+    constructor(stackValues = []) {
         /**
          * The stack
          * @type {int[]}
          */
-        this.stack = [];
+        this.stack = stackValues;
         /**
          * A single value saved off the stack
          * @type {int}