From 365d6133f59923d17e902999bf2d4df435da0dff Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Wed, 22 Aug 2018 12:11:57 -0700 Subject: [PATCH 1/2] chore: initial commit - commit to publish PR --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 03e05e4..9fc7239 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .DS_Store -/node_modules +/node_modules \ No newline at end of file From 20d818c4bac01e7e592fdb169a4bc8f788a2f816 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Wed, 22 Aug 2018 15:48:41 -0700 Subject: [PATCH 2/2] feat: implementing queue methods - implementing array queue methods - enqueue, dequeue, peek, and empty - not sure "this." or "this.process" at some points. subject to test and fix if required --- src/Queue.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Queue.js b/src/Queue.js index 7b45fdf..c302ee4 100644 --- a/src/Queue.js +++ b/src/Queue.js @@ -19,21 +19,25 @@ class Queue { // Enqueues the given process. Return the enqueue'd process enqueue(process) { - + return this.process.push(process); } // Dequeues the next process in the queue. Return the dequeue'd process dequeue() { - + if (this.isEmpty) { + console.log("Error: Unable to dequeue. The queue is empty.") + } else { + return this.process.shift(); + } } // Return the least-recently added process without removing it from the list of processes peek() { - + return this.process[-1]; } isEmpty() { - + return this.process.length === 0 } getPriorityLevel() {