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

Function buildEnvTrie

packages/effect/src/ConfigProvider.ts:979–996  ·  view source on GitHub ↗
(env: Record<string, string | undefined>)

Source from the content-addressed store, hash-verified

977}
978
979function buildEnvTrie(env: Record<string, string | undefined>): EnvTrieNode {
980 const trie: EnvTrieNode = {}
981
982 for (const [name, value] of Object.entries(env)) {
983 if (value === undefined) continue
984
985 // Split on "_" and keep empty segments (no special handling for "__")
986 const segments = name.split("_")
987
988 let node = trie
989 for (const seg of segments) {
990 const children = node.children ??= Object.create(null)
991 node = children[seg] ??= {}
992 }
993 }
994
995 return trie
996}
997
998function nodeAtEnv(
999 trie: EnvTrieNode,

Callers 1

fromEnvRecordFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected