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

Method assign

packages/effect/src/unstable/encoding/Toml.ts:133–153  ·  view source on GitHub ↗
(target: Table, keys: ReadonlyArray<string>, value: unknown)

Source from the content-addressed store, hash-verified

131 }
132
133 private assign(target: Table, keys: ReadonlyArray<string>, value: unknown): void {
134 let table = target
135 for (let index = 0; index < keys.length - 1; index++) {
136 const key = keys[index]
137 const existing = table[key]
138 if (existing === undefined) {
139 const child = makeTable()
140 table[key] = child
141 table = child
142 } else if (isTable(existing)) {
143 table = existing
144 } else {
145 this.fail(`Cannot redefine existing key '${keys.slice(0, index + 1).join(".")}'`)
146 }
147 }
148 const key = keys[keys.length - 1]
149 if (hasOwn.call(table, key)) {
150 this.fail(`Cannot redefine existing key '${keys.join(".")}'`)
151 }
152 table[key] = value
153 }
154
155 private parseKeyPath(stop: "=" | "]"): Array<string> {
156 const keys: Array<string> = []

Callers 15

parseMethod · 0.95
parseInlineTableMethod · 0.95
makeFunction · 0.80
makeFunction · 0.80
makeFunction · 0.80
makeFunction · 0.80
makeFunction · 0.80
makeFunction · 0.80
withoutTransformsFunction · 0.80
PgClient.tsFile · 0.80
fromClientFunction · 0.80
makeFunction · 0.80

Calls 4

failMethod · 0.95
makeTableFunction · 0.85
isTableFunction · 0.85
joinMethod · 0.80

Tested by 1

withCodeFunction · 0.64