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

Function fromIterable

packages/effect/src/internal/hashMap.ts:936–951  ·  view source on GitHub ↗
(entries: Iterable<readonly [K, V]>)

Source from the content-addressed store, hash-verified

934
935/** @internal */
936export const fromIterable = <K, V>(entries: Iterable<readonly [K, V]>): HashMap<K, V> => {
937 let root: Node<K, V> = emptyNode
938 let size = 0
939 const added = { value: false }
940
941 for (const [key, value] of entries) {
942 const hash = Hash.hash(key) | 0
943 added.value = false
944 root = root.set(NaN, 0, hash, key, value, added)
945 if (added.value) {
946 size++
947 }
948 }
949
950 return new HashMapImpl(false, 0, root, size)
951}
952
953/** @internal */
954export const isEmpty = <K, V>(self: HashMap<K, V>): boolean => (self as HashMapImpl<K, V>).size === 0

Callers 1

makeFunction · 0.70

Calls 1

setMethod · 0.65

Tested by

no test coverage detected