MCPcopy Create free account
hub / github.com/Effect-TS/effect / set

Method set

packages/effect/src/internal/hashMap.ts:661–701  ·  view source on GitHub ↗
(
    edit: number,
    shift: number,
    hash: number,
    key: K,
    value: V,
    added: { value: boolean }
  )

Source from the content-addressed store, hash-verified

659 }
660
661 set(
662 edit: number,
663 shift: number,
664 hash: number,
665 key: K,
666 value: V,
667 added: { value: boolean }
668 ): Node<K, V> {
669 const idx = mask(hash, shift)
670 const child = this.children[idx]
671
672 if (child) {
673 const newChild = child.set(edit, shift + SHIFT, hash, key, value, added)
674 if (child === newChild) {
675 return this
676 }
677
678 if (this.canEdit(edit)) {
679 this.children[idx] = newChild
680 return this
681 }
682
683 const newChildren = [...this.children]
684 newChildren[idx] = newChild
685 return new ArrayNode(edit, this.count, newChildren)
686 } else {
687 added.value = true
688 const newChild = new LeafNode(edit, hash, key, value)
689
690 if (this.canEdit(edit)) {
691 this.children[idx] = newChild
692 this.count++
693 this._size = undefined
694 return this
695 }
696
697 const newChildren = [...this.children]
698 newChildren[idx] = newChild
699 return new ArrayNode(edit, this.count + 1, newChildren)
700 }
701 }
702
703 remove(
704 edit: number,

Callers

nothing calls this directly

Calls 3

maskFunction · 0.85
canEditMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected