MCPcopy Create free account
hub / github.com/activejs/activejs / shift

Method shift

packages/core/src/lib/list-unit.ts:482–494  ·  view source on GitHub ↗

* Removes the first item from the list-value and returns it. \ * Dispatches a new copy of the value, without mutating the current-value. * * It only works if the Unit is not frozen, and the list is not empty isEmpty. * * @returns The shifted item. * * @triggers {

()

Source from the content-addressed store, hash-verified

480 * @category Customised Array.prototype
481 */
482 shift(): Item | undefined {
483 if (this.isFrozen || this.isEmpty) {
484 return;
485 }
486 const listShallowCopy = [...this.rawValue()];
487 const shiftedItem = this.deepCopyMaybe(listShallowCopy.shift());
488 this.updateValueAndCache(listShallowCopy);
489
490 if (this.eventsSubject?.observers.length && !this.isMuted) {
491 this.eventsSubject.next(new EventListUnitShift(shiftedItem));
492 }
493 return shiftedItem;
494 }
495
496 /**
497 * Inserts new items at the start of the list-{@link value}. \

Callers 5

updateCacheFunction · 0.80
units.spec.tsFile · 0.80
utils.tsFile · 0.80
randomMutationFunction · 0.80
list-unit.spec.tsFile · 0.80

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected