MCPcopy Index your code
hub / github.com/Effect-TS/effect / modify

Method modify

packages/effect/src/internal/hashMap/node.ts:256–303  ·  view source on GitHub ↗
(
    edit: number,
    shift: number,
    f: HashMap.UpdateFn<V>,
    hash: number,
    key: K,
    size: SizeRef
  )

Source from the content-addressed store, hash-verified

254 ) {}
255
256 modify(
257 edit: number,
258 shift: number,
259 f: HashMap.UpdateFn<V>,
260 hash: number,
261 key: K,
262 size: SizeRef
263 ): Node<K, V> {
264 let count = this.size
265 const children = this.children
266 const frag = hashFragment(shift, hash)
267 const child = children[frag]
268 const newChild = (child || new EmptyNode<K, V>()).modify(
269 edit,
270 shift + SIZE,
271 f,
272 hash,
273 key,
274 size
275 )
276
277 if (child === newChild) return this
278
279 const canEdit = canEditNode(this, edit)
280 let newChildren
281 if (isEmptyNode(child) && !isEmptyNode(newChild)) {
282 // add
283 ++count
284 newChildren = arrayUpdate(canEdit, frag, newChild, children)
285 } else if (!isEmptyNode(child) && isEmptyNode(newChild)) {
286 // remove
287 --count
288 if (count <= MIN_ARRAY_NODE) {
289 return pack(edit, count, frag, children)
290 }
291 newChildren = arrayUpdate(canEdit, frag, new EmptyNode<K, V>(), children)
292 } else {
293 // modify
294 newChildren = arrayUpdate(canEdit, frag, newChild, children)
295 }
296
297 if (canEdit) {
298 this.size = count
299 this.children = newChildren
300 return this
301 }
302 return new ArrayNode(edit, count, newChildren)
303 }
304}
305
306function pack<K, V>(

Callers

nothing calls this directly

Calls 6

hashFragmentFunction · 0.85
canEditNodeFunction · 0.85
isEmptyNodeFunction · 0.85
arrayUpdateFunction · 0.85
packFunction · 0.70
modifyMethod · 0.65

Tested by

no test coverage detected