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

Function buildEnvTrie

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

Source from the content-addressed store, hash-verified

940}
941
942function buildEnvTrie(env: Record<string, string | undefined>): EnvTrieNode {
943 const trie: EnvTrieNode = {}
944
945 for (const [name, value] of Object.entries(env)) {
946 if (value === undefined) continue
947
948 // Split on "_" and keep empty segments (no special handling for "__")
949 const segments = name.split("_")
950
951 let node = trie
952 for (const seg of segments) {
953 const children = node.children ??= Object.create(null)
954 node = children[seg] ??= {}
955 }
956 }
957
958 return trie
959}
960
961const NUMERIC_INDEX = /^(0|[1-9][0-9]*)$/
962

Callers 1

fromEnvRecordFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected