MCPcopy Index your code
hub / github.com/trekhleb/javascript-algorithms / peek

Method peek

src/data-structures/queue/Queue.js:23–29  ·  view source on GitHub ↗

* Read the element at the front of the queue without removing it. * @return {*}

()

Source from the content-addressed store, hash-verified

21 * @return {*}
22 */
23 peek() {
24 if (this.isEmpty()) {
25 return null;
26 }
27
28 return this.linkedList.head.value;
29 }
30
31 /**
32 * Add a new element to the end of the queue (the tail of the linked list).

Callers 1

Queue.test.jsFile · 0.45

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected