MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / removeItem

Method removeItem

src/platform/common/utils/map.ts:488–520  ·  view source on GitHub ↗
(item: Item<K, V>)

Source from the content-addressed store, hash-verified

486 }
487
488 private removeItem(item: Item<K, V>): void {
489 if (item === this._head && item === this._tail) {
490 this._head = undefined;
491 this._tail = undefined;
492 } else if (item === this._head) {
493 // This can only happen if size === 1 which is handled
494 // by the case above.
495 if (!item.next) {
496 throw new Error('Invalid list');
497 }
498 item.next.previous = undefined;
499 this._head = item.next;
500 } else if (item === this._tail) {
501 // This can only happen if size === 1 which is handled
502 // by the case above.
503 if (!item.previous) {
504 throw new Error('Invalid list');
505 }
506 item.previous.next = undefined;
507 this._tail = item.previous;
508 } else {
509 const next = item.next;
510 const previous = item.previous;
511 if (!next || !previous) {
512 throw new Error('Invalid list');
513 }
514 next.previous = previous;
515 previous.next = next;
516 }
517 item.next = undefined;
518 item.previous = undefined;
519 this._state++;
520 }
521
522 private touch(item: Item<K, V>, touch: Touch): void {
523 if (!this._head || !this._tail) {

Callers 2

removeMethod · 0.95
shiftMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected