MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / peekFirst

Method peekFirst

Data-Structures/Queue/Queue.js:69–75  ·  view source on GitHub ↗

* @description - Return the item at the front of the queue * @returns {*}

()

Source from the content-addressed store, hash-verified

67 * @returns {*}
68 */
69 peekFirst() {
70 if (this.isEmpty()) {
71 throw new Error('Queue is Empty')
72 }
73
74 return this.head.data
75 }
76
77 /**
78 * @description - Return the item at the tail of the queue

Callers 2

dequeueMethod · 0.95
Queue.test.jsFile · 0.80

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected