MCPcopy
hub / github.com/immutable-js/immutable-js / update

Method update

src/Map.js:569–593  ·  view source on GitHub ↗
(ownerID, shift, keyHash, key, value, didChangeSize, didAlter)

Source from the content-addressed store, hash-verified

567 }
568
569 update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
570 const removed = value === NOT_SET;
571 const keyMatch = is(key, this.entry[0]);
572 if (keyMatch ? value === this.entry[1] : removed) {
573 return this;
574 }
575
576 SetRef(didAlter);
577
578 if (removed) {
579 SetRef(didChangeSize);
580 return; // undefined
581 }
582
583 if (keyMatch) {
584 if (ownerID && ownerID === this.ownerID) {
585 this.entry[1] = value;
586 return this;
587 }
588 return new ValueNode(ownerID, this.keyHash, [key, value]);
589 }
590
591 SetRef(didChangeSize);
592 return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
593 }
594}
595
596// #pragma Iterators

Callers 1

createNodesFunction · 0.95

Calls 4

isFunction · 0.90
SetRefFunction · 0.90
hashFunction · 0.90
mergeIntoNodeFunction · 0.85

Tested by

no test coverage detected