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

Method includes

data_structures/deque.ts:512–529  ·  view source on GitHub ↗

* Check whether the deque contains a value, using * https://tc39.es/ecma262/#sec-samevaluezero | SameValueZero * comparison (like code Array.prototype.includes). * * @example Checking for membership * ```ts * import { Deque } from "@std/data-structures/deque"; * i

(value: T)

Source from the content-addressed store, hash-verified

510 * @returns `true` if the deque contains the value, otherwise `false`.
511 */
512 includes(value: T): boolean {
513 const buf = this.#buffer;
514 const head = this.#head;
515 const len = this.#length;
516 const cap = this.#mask + 1;
517 const firstLen = Math.min(len, cap - head);
518 // SameValueZero: === for everything except NaN
519 for (let i = 0; i < firstLen; i++) {
520 const el = buf[head + i];
521 if (el === value || (el !== el && value !== value)) return true;
522 }
523 const rem = len - firstLen;
524 for (let i = 0; i < rem; i++) {
525 const el = buf[i];
526 if (el === value || (el !== el && value !== value)) return true;
527 }
528 return false;
529 }
530
531 /**
532 * Remove all elements and release the backing buffer.

Callers 15

digestFunction · 0.80
crypto_test.tsFile · 0.80
bench.tsFile · 0.80
onListenFunction · 0.80
isStatusFunction · 0.80
verifyMessageFunction · 0.80
hasFunction · 0.80
parseLineFunction · 0.80
ifMatchFunction · 0.80
ifNoneMatchFunction · 0.80
isComplexSegmentFunction · 0.80

Calls 1

minMethod · 0.80

Tested by

no test coverage detected