MCPcopy Create free account
hub / github.com/denoland/std / popFront

Method popFront

data_structures/deque.ts:302–310  ·  view source on GitHub ↗

* Remove and return the front element, or `undefined` if the deque is empty. * * @example Popping from the front * ```ts * import { Deque } from "@std/data-structures/deque"; * import { assertEquals } from "@std/assert"; * * const deque = new Deque([1, 2, 3]); * assertEquals(

()

Source from the content-addressed store, hash-verified

300 * @returns The front element, or `undefined` if empty.
301 */
302 popFront(): T | undefined {
303 if (this.#length === 0) return undefined;
304 const value = this.#buffer[this.#head];
305 this.#buffer[this.#head] = undefined;
306 this.#head = (this.#head + 1) & this.#mask;
307 this.#length--;
308 this.#maybeShrink();
309 return value;
310 }
311
312 /**
313 * Remove and return the first element matching the predicate, scanning from

Callers 6

onAbortMethod · 0.80
closeMethod · 0.80
#nextSenderMethod · 0.80
#deliverToReceiverMethod · 0.80
#dequeueMethod · 0.80
deque_test.tsFile · 0.80

Calls 1

#maybeShrinkMethod · 0.95

Tested by

no test coverage detected