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

Method splice

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

* Removes items from the list-value and, if necessary, * inserts new items in their place, returning the deleted items. \ * Dispatches a new copy of the value, without mutating the current-value. * * It only works if the Unit is not frozen, and \ * either deleteCount is not 0

(start: number, deleteCount: number, ...items: Item[])

Source from the content-addressed store, hash-verified

539 * @category Customised Array.prototype
540 */
541 splice(start: number, deleteCount: number, ...items: Item[]): Item[] {
542 // tslint:disable-next-line:triple-equals
543 if (this.isFrozen || ((deleteCount == 0 || this.isEmpty) && !items.length)) {
544 return [];
545 }
546 this.checkSerializabilityMaybe(items);
547
548 const listShallowCopy = [...this.rawValue()];
549 const removedItems = this.deepCopyMaybe(
550 listShallowCopy.splice(start, deleteCount, ...items.map(item => this.deepCopyMaybe(item)))
551 );
552 this.updateValueAndCache(listShallowCopy);
553
554 if (this.eventsSubject?.observers.length && !this.isMuted) {
555 this.eventsSubject.next(new EventListUnitSplice(start, deleteCount, removedItems, items));
556 }
557 return removedItems;
558 }
559
560 /**
561 * Fills a section of the list-{@link value} with provided param `item`. \

Callers 9

insertMethod · 0.95
clearCacheFunction · 0.80
updateCacheFunction · 0.80
removeMethod · 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