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

Function fromIterable

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

Source from the content-addressed store, hash-verified

897
898/** @internal */
899export const fromIterable = <K, V>(entries: Iterable<readonly [K, V]>): HashMap<K, V> => {
900 let root: Node<K, V> = emptyNode
901 let size = 0
902 const added = { value: false }
903
904 for (const [key, value] of entries) {
905 const hash = Hash.hash(key)
906 added.value = false
907 root = root.set(NaN, 0, hash, key, value, added)
908 if (added.value) {
909 size++
910 }
911 }
912
913 return new HashMapImpl(false, 0, root, size)
914}
915
916/** @internal */
917export 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