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

Method assign

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

Source from the content-addressed store, hash-verified

163 }
164
165 private assign(target: Table, keys: ReadonlyArray<string>, value: unknown): void {
166 let table = target
167 for (let index = 0; index < keys.length - 1; index++) {
168 const key = keys[index]
169 const existing = table[key]
170 if (existing === undefined) {
171 const child = makeTable()
172 table[key] = child
173 table = child
174 } else if (isTable(existing) && !this.explicitTables.has(existing) && !this.inlineValues.has(existing)) {
175 table = existing
176 } else {
177 this.fail(`Cannot redefine existing key '${keys.slice(0, index + 1).join(".")}'`)
178 }
179 this.dottedTables.add(table)
180 }
181 const key = keys[keys.length - 1]
182 if (hasOwn.call(table, key)) {
183 this.fail(`Cannot redefine existing key '${keys.join(".")}'`)
184 }
185 table[key] = value
186 }
187
188 private parseKeyPath(stop: "=" | "]"): Array<string> {
189 const keys: Array<string> = []

Callers 15

parseMethod · 0.95
parseInlineTableMethod · 0.95
finishFunction · 0.80
githubClientFunction · 0.80
main.tsFile · 0.80
makeFunction · 0.80
makeFunction · 0.80
makeFunction · 0.80
makeFunction · 0.80
makeFunction · 0.80
Client.test.tsFile · 0.80

Calls 8

failMethod · 0.95
makeTableFunction · 0.85
isTableFunction · 0.85
sliceMethod · 0.80
hasMethod · 0.65
addMethod · 0.65
joinMethod · 0.45
callMethod · 0.45

Tested by 15

githubClientFunction · 0.64
resizeFunction · 0.64
mockSizeFunction · 0.64
withCodeFunction · 0.64
getByNameMethod · 0.64
transportErrorFunction · 0.64
retryableErrorFunction · 0.64
cloudflareErrorFunction · 0.64
runFunction · 0.64
customFunction · 0.64
makeFetchFunction · 0.64
closeWatchersFunction · 0.64