Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.DS_Store
/node_modules
/node_modules
12 changes: 8 additions & 4 deletions src/Queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down